Skip to content

Commit

Permalink
Fixed view_assigns test for cells accepting options
Browse files Browse the repository at this point in the history
  • Loading branch information
harun committed Nov 8, 2011
1 parent e380f68 commit 0f53bb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/cells/cell/test_case.rb
Expand Up @@ -80,7 +80,7 @@ def setup
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)
@last_invoke = @subject_cell.render_state(state)
end

@last_invoke
Expand Down Expand Up @@ -109,6 +109,10 @@ def cell(name, opts={}, &block)
cell.instance_eval &block if block_given?
cell
end

def assigns(name)
view_assigns[name.to_sym]
end
end

include TestMethods
Expand Down
11 changes: 11 additions & 0 deletions test/test_case_test.rb
Expand Up @@ -48,6 +48,17 @@ def sleep
render_cell(:bassist, :sleep)
assert_equal({:duration => "8h"}, view_assigns)
end

should "return the instance variables from the last #render_cell accepting options" do
BassistCell.class_eval do
def run
@duration = @opts[:duration]
end
end
render_cell(:bassist, :run, :duration=> "8h")
assert_equal("8h", assigns(:duration))
end

end

context "in declarative tests" do
Expand Down

0 comments on commit 0f53bb6

Please sign in to comment.