lib/apotomo/test_case.rb in apotomo-1.2.3 vs lib/apotomo/test_case.rb in apotomo-1.2.4

- old
+ new

@@ -17,11 +17,11 @@ # assert_select "div#post-comments", "Comments for this post" # end # # it "should redraw on :update" do # trigger :update - # assert_response "$(\"post-comments\").update ..." + # assert_response "jQuery(\"post-comments\").update ..." # end # # For unit testing, you can grab an instance of your tested widget. # # it "should be visible" do @@ -33,30 +33,31 @@ # Generic test methods to be used in Test::Unit, RSpec, etc. module TestMethods extend ActiveSupport::Concern include Cell::TestCase::CommonTestMethods - + attr_reader :view_assigns - + def setup super # defined in Cell::TestCase::CommonTestMethods. - + @controller.instance_eval do def controller_path 'barn' end end @controller.extend Apotomo::Rails::ControllerMethods end - + # Renders the widget +name+. def render_widget(*args) @view_assigns = extract_state_ivars_for(root[args.first]) do @last_invoke = root.render_widget(*args) end - + cleanup_assigns!(@view_assigns) + @last_invoke end # Triggers an event of +type+. You have to pass the +source+ as second options. # @@ -74,15 +75,20 @@ blk = self.class.has_widgets_blocks 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 - + def parent_controller @controller end + private + def cleanup_assigns!(assigns) + assigns.delete(:lookup_context) # dirty but it works. + end + module ClassMethods def has_widgets_blocks @has_widgets end @@ -96,10 +102,10 @@ # After a #trigger this assertion compares the actually triggered page updates with the passed. # # Example: # # trigger :submit, :source => "post-comments" - # assert_response "alert(\":submit clicked!\")", /\$\("post-comments"\).update/ + # assert_response "alert(\":submit clicked!\")", /\jQuery\("post-comments"\).update/ def assert_response(*content) updates = root.page_updates i = 0 content.each do |assertion|