mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Modified should_change macro to use the case equality operator (===) for checking :from and :to options
This commit is contained in:
parent
0dfda70fee
commit
66be6bc125
2 changed files with 6 additions and 6 deletions
|
@ -56,9 +56,9 @@ module ThoughtBot # :nodoc:
|
|||
should stmt, :before => before do
|
||||
old_value = @_before_should_change
|
||||
new_value = expression_eval.bind(self).call
|
||||
assert_equal from, old_value, "#{expression.inspect} was not originally #{from.inspect}" if from
|
||||
assert_operator from, :===, old_value, "#{expression.inspect} did not originally match #{from.inspect}" if from
|
||||
assert_not_equal old_value, new_value, "#{expression.inspect} did not change" unless by == 0
|
||||
assert_equal to, new_value, "#{expression.inspect} was not changed to #{to.inspect}" if to
|
||||
assert_operator to, :===, new_value, "#{expression.inspect} was not changed to match #{to.inspect}" if to
|
||||
assert_equal old_value + by, new_value if by
|
||||
end
|
||||
end
|
||||
|
|
|
@ -78,9 +78,9 @@ class HelpersTest < Test::Unit::TestCase # :nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
context "an array of numbers" do
|
||||
context "an array of values" do
|
||||
setup do
|
||||
@a = [1, 2, 3]
|
||||
@a = [1, 2, "(3)"]
|
||||
end
|
||||
|
||||
context "after adding another value" do
|
||||
|
@ -104,8 +104,8 @@ class HelpersTest < Test::Unit::TestCase # :nodoc:
|
|||
should_change "@a.length", :from => 3, :to => 6, :by => 3
|
||||
should_change "@a[0]"
|
||||
should_change "@a[1]", :from => 2, :to => "b"
|
||||
should_change "@a[2]", :from => 3
|
||||
should_change "@a[3]", :to => "d"
|
||||
should_change "@a[2]", :from => /\d/, :to => /\w/
|
||||
should_change "@a[3]", :to => String
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue