Testing Cells

11 views
Skip to first unread message

Harun Pathan

unread,
Nov 4, 2011, 11:44:20 AM11/4/11
to cells-an...@googlegroups.com
Hi,

I am using cells 3.3.9 in rails2.3.14 application.

I wanted to test cells with using view_assigns[:symb], but getting an error

ArgumentError: wrong number of arguments (2 for 1)
    .bundle/ruby/1.8/gems/cells-3.3.9/lib/cells/cell/test_case.rb:83:in `render_state'
    .bundle/ruby/1.8/gems/cells-3.3.9/lib/cells/cell/test_case.rb:83:in `render_cell'
    .bundle/ruby/1.8/gems/cells-3.3.9/lib/cells/cell/test_case.rb:93:in `extract_state_ivars_for'
    .bundle/ruby/1.8/gems/cells-3.3.9/lib/cells/cell/test_case.rb:82:in `render_cell'
    test/cells/blog_post_cell_test.rb:11:in `__bind_1320421186_77782'
    .bundle/ruby/1.8/gems/shoulda-2.11.3/lib/shoulda/context.rb:382:in `call'
    .bundle/ruby/1.8/gems/shoulda-2.11.3/lib/shoulda/context.rb:382:in `test: show should return first published blog post. '
    .bundle/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'
    .bundle/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/testing/setup_and_teardown.rb:62:in `run'

My testcase:


class BlogPostCellTest < Cell::TestCase
  context "show" do
    should "return first published blog post" do
      war = Factory.create(:blog_post, :title => "War", :is_live => 0)
      peace = Factory.create(:blog_post, :title => "Peace", :is_live => 1)
      category = Factory.create(:blog_category, :title => "War&Peace", :blog_posts => [war, peace])

      render_cell :blog_post, :show, :category => category.title

      assert_equal category, view_assigns[:blog_category]
      assert_equal peace, view_assigns[:post]
    end
end

After investigations, found test_case.rb has 

      def render_cell(name, state, *args)
        @subject_cell = ::Cell::Base.create_cell_for(@controller, name, *args)
        @view_assigns = extract_state_ivars_for(@subject_cell) do
          @last_invoke = @subject_cell.render_state(state, *args)
        end
        @last_invoke
      end

Whereas base.rb has

      def render_state(state)
         ---
      end

If we change @last_invoke = @subject_cell.render_state(state, *args) to @last_invoke = @subject_cell.render_state(state),
it works. 

This looks like a defect.

thoughts?

Thanks,
Harun @harunpathan


Harun Pathan

unread,
Nov 4, 2011, 1:42:23 PM11/4/11
to cells-an...@googlegroups.com
This case is happening only for cells with options.

Thanks,
harun
--
Thanks,
Harun @harunpathan


Reply all
Reply to author
Forward
0 new messages