public
Rubygem
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/thoughtbot/shoulda.git
Modified should_change macro to use the case equality operator (===) for 
checking :from and :to options
rmm5t (author)
Wed Jul 09 18:59:56 -0700 2008
commit  66be6bc125f7869ee41f0d2d49df8b95ba486cb6
tree    955c0aa7099c3e5a04286f20d90c82180ddeccff
parent  0dfda70fee4a3336667f32c82d0214ae0018614f
...
56
57
58
59
 
60
61
 
62
63
64
...
56
57
58
 
59
60
 
61
62
63
64
0
@@ -56,9 +56,9 @@ module ThoughtBot # :nodoc:
0
           should stmt, :before => before do
0
             old_value = @_before_should_change
0
             new_value = expression_eval.bind(self).call
0
- assert_equal from, old_value, "#{expression.inspect} was not originally #{from.inspect}" if from
0
+ assert_operator from, :===, old_value, "#{expression.inspect} did not originally match #{from.inspect}" if from
0
             assert_not_equal old_value, new_value, "#{expression.inspect} did not change" unless by == 0
0
- assert_equal to, new_value, "#{expression.inspect} was not changed to #{to.inspect}" if to
0
+ assert_operator to, :===, new_value, "#{expression.inspect} was not changed to match #{to.inspect}" if to
0
             assert_equal old_value + by, new_value if by
0
           end
0
         end
...
78
79
80
81
 
82
83
 
84
85
86
...
104
105
106
107
108
 
 
109
110
111
...
78
79
80
 
81
82
 
83
84
85
86
...
104
105
106
 
 
107
108
109
110
111
0
@@ -78,9 +78,9 @@ class HelpersTest < Test::Unit::TestCase # :nodoc:
0
     end
0
   end
0
   
0
- context "an array of numbers" do
0
+ context "an array of values" do
0
     setup do
0
- @a = [1, 2, 3]
0
+ @a = [1, 2, "(3)"]
0
     end
0
 
0
     context "after adding another value" do
0
@@ -104,8 +104,8 @@ class HelpersTest < Test::Unit::TestCase # :nodoc:
0
       should_change "@a.length", :from => 3, :to => 6, :by => 3
0
       should_change "@a[0]"
0
       should_change "@a[1]", :from => 2, :to => "b"
0
- should_change "@a[2]", :from => 3
0
- should_change "@a[3]", :to => "d"
0
+ should_change "@a[2]", :from => /\d/, :to => /\w/
0
+ should_change "@a[3]", :to => String
0
     end
0
   end
0
 end

Comments

    No one has commented yet.