require 'test_helper' require 'action_view/test_case' class ViewHelperTest < Apotomo::TestCase include ActionDispatch::Assertions::DomAssertions include Apotomo::TestCase::TestController # TODO: move to Apotomo::TestCase, refactor, test. class MouseWidget < Apotomo::Widget end def in_view(subject, &block) if subject.kind_of?(Apotomo::Widget) subject.opts[:block] = block else subject = subject.new(@controller, 'mum', :display, :block => block) end setup_test_states_in(subject) unless subject.respond_to?(:in_view)# add #in_view state to subject cell. subject.class.action_methods << "in_view" subject.invoke(:in_view) end def mouse_mock(id='mum', start_state=:eat, opts={}, &block) mouse = MouseWidget.new(parent_controller, id, start_state, opts) mouse.instance_eval &block if block_given? mouse end context "A widget state view" do teardown do Apotomo.js_framework = :prototype end should_eventually "respond to #multipart_form_to_event" do assert_dom_equal( "
", in_view(MouseWidget) do multipart_form_to_event(:footsteps) end) end should "respond to #url_for_event" do assert_equal("/barn/render_event_response?source=mum&type=footsteps", in_view(MouseWidget) do url_for_event(:footsteps) end) end should "respond to #url_for_event with a namespaced controller" do @controller = namespaced_controller assert_equal("/farm/barn/render_event_response?source=mum&type=footsteps", in_view(MouseWidget) do url_for_event(:footsteps) end) end should "respond to #widget_div" do assert_equal('