Skip to content

Commit

Permalink
Bugfix: should_assign_to with false passes if that variable has anoth…
Browse files Browse the repository at this point in the history
…er value
  • Loading branch information
Johannes Barre committed Jul 24, 2009
1 parent f99dd3b commit 7972a1d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def kind_of_expected_class?
end

def equal_to_expected_value?
return true unless @expected_value
return true if @expected_value.nil?
if @expected_value == assigned_value
@negative_failure_message =
"Didn't expect action to assign #{@expected_value.inspect} " <<
Expand Down
3 changes: 3 additions & 0 deletions test/functional/posts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def setup
should_fail do
should_set_the_flash_to /.*/
end
should_fail do
should_assign_to(:post) { false}
end
end

context "on GET to #new" do
Expand Down
5 changes: 4 additions & 1 deletion test/matchers/controller/assign_to_matcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class AssignToMatcherTest < ActionController::TestCase # :nodoc:
should "reject assigning to another variable" do
assert_rejects assign_to(:other), @controller
end
end

should "reject assigning to that variable with false" do
assert_rejects assign_to(:var).with(false), @controller
end
end
end

0 comments on commit 7972a1d

Please sign in to comment.