Module: Apotomo::TestCase::TestMethods
- Extended by:
- ActiveSupport::Concern
- Includes:
- Cell::TestCase::CommonTestMethods
- Included in:
- Apotomo::TestCase
- Defined in:
- lib/apotomo/test_case.rb
Overview
Generic test methods to be used in Test::Unit, RSpec, etc.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#view_assigns ⇒ Object
readonly
Returns the value of attribute view_assigns.
Instance Method Summary collapse
- #parent_controller ⇒ Object
-
#render_widget(*args) ⇒ Object
Renders the widget
name
. -
#root ⇒ Object
Returns the widget tree from TestCase.has_widgets.
- #setup ⇒ Object
-
#trigger(type, source, options = {}) ⇒ Object
Triggers an event of
type
.
Instance Attribute Details
#view_assigns ⇒ Object (readonly)
Returns the value of attribute view_assigns.
39 40 41 |
# File 'lib/apotomo/test_case.rb', line 39 def view_assigns @view_assigns end |
Instance Method Details
#parent_controller ⇒ Object
81 82 83 |
# File 'lib/apotomo/test_case.rb', line 81 def parent_controller @controller end |
#render_widget(*args) ⇒ Object
Renders the widget name
.
53 54 55 56 57 58 59 60 |
# File 'lib/apotomo/test_case.rb', line 53 def (*args) @view_assigns = extract_state_ivars_for(root[args.first]) do @last_invoke = root.(*args) end cleanup_assigns!(@view_assigns) @last_invoke end |
#root ⇒ Object
Returns the widget tree from TestCase.has_widgets.
74 75 76 77 78 79 |
# File 'lib/apotomo/test_case.rb', line 74 def root blk = self.class. or raise "Please setup a widget tree using has_widgets()" @root ||= Apotomo::Widget.new(parent_controller, "root").tap do |root| self.instance_exec(root, &blk) end end |
#setup ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/apotomo/test_case.rb', line 41 def setup super # defined in Cell::TestCase::CommonTestMethods. @controller.instance_eval do def controller_path 'barn' end end @controller.extend Apotomo::Rails::ControllerMethods end |
#trigger(type, source, options = {}) ⇒ Object
Triggers an event of type
. You have to pass the source
as second options.
Example:
trigger :submit, :comments
67 68 69 70 71 |
# File 'lib/apotomo/test_case.rb', line 67 def trigger(type, source, ={}) source = root.(source) source.fire(type, ) root.page_updates end |