Class: SimpleCells::SpecHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_cells/spec_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cell_name, action_name, simple_cell_arguments = {}) ⇒ SpecHelper

Returns a new instance of SpecHelper.



4
5
6
7
8
9
10
# File 'lib/simple_cells/spec_helper.rb', line 4

def initialize(cell_name, action_name, simple_cell_arguments = {})
  @action_name = action_name
  @cell_name = cell_name
  @cell_class_name = "#{cell_name.to_s.camelize}SimpleCell"
  @simple_cell_arguments = simple_cell_arguments
  render
end

Instance Attribute Details

#action_nameObject (readonly)

Returns the value of attribute action_name.



2
3
4
# File 'lib/simple_cells/spec_helper.rb', line 2

def action_name
  @action_name
end

#bodyObject (readonly)

Returns the value of attribute body.



2
3
4
# File 'lib/simple_cells/spec_helper.rb', line 2

def body
  @body
end

#cell_class_nameObject (readonly)

Returns the value of attribute cell_class_name.



2
3
4
# File 'lib/simple_cells/spec_helper.rb', line 2

def cell_class_name
  @cell_class_name
end

#cell_nameObject (readonly)

Returns the value of attribute cell_name.



2
3
4
# File 'lib/simple_cells/spec_helper.rb', line 2

def cell_name
  @cell_name
end

#simple_cell_argumentsObject (readonly)

Returns the value of attribute simple_cell_arguments.



2
3
4
# File 'lib/simple_cells/spec_helper.rb', line 2

def simple_cell_arguments
  @simple_cell_arguments
end

Instance Method Details

#cell_instanceObject



12
13
14
# File 'lib/simple_cells/spec_helper.rb', line 12

def cell_instance
  @cell_instance ||= cell_class_name.constantize.new(view_context: view_context, simple_cell_arguments: simple_cell_arguments)
end

#controllerObject



16
17
18
# File 'lib/simple_cells/spec_helper.rb', line 16

def controller
  @controller ||= ActionController::Base.new
end

#renderObject



20
21
22
23
# File 'lib/simple_cells/spec_helper.rb', line 20

def render
  cell_instance.__send__(action_name)
  @body = cell_instance.render_simple_cell_view(cell_name, action_name)
end

#view_contextObject



25
26
27
# File 'lib/simple_cells/spec_helper.rb', line 25

def view_context
  @view_context ||= controller.view_context
end