public
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
Search Repo:
Cleaned up should_change macros to generate the should statement using 
inspect calls instead of ticks.
rmm5t (author)
Wed Jul 09 17:49:55 -0700 2008
commit  0dfda70fee4a3336667f32c82d0214ae0018614f
tree    56d8761b29dbf7354cb5a6479a14148fd5b9b597
parent  789a6884f8a4b9e8c5edf0e4465ed7c83b0d9ac4
...
46
47
48
49
50
51
52
 
 
 
 
53
54
55
56
57
58
 
59
60
61
62
63
 
 
 
64
65
66
...
81
82
83
84
 
85
86
 
87
88
89
...
46
47
48
 
 
 
 
49
50
51
52
53
54
 
 
 
 
55
56
57
58
 
 
59
60
61
62
63
64
...
79
80
81
 
82
83
 
84
85
86
87
0
@@ -46,21 +46,19 @@ module ThoughtBot # :nodoc:
0
         # should_change "@post.title" :to => "new" # => assert the value changed from anything other than "new"
0
         def should_change(expression, options = {})
0
           by, from, to = get_options!([options], :by, :from, :to)
0
- stmt = "change '#{expression}'"
0
- stmt << " from '#{from}'" if from
0
- stmt << " to '#{to}'" if to
0
- stmt << " by #{by}" if by
0
+ stmt = "change #{expression.inspect}"
0
+ stmt << " from #{from.inspect}" if from
0
+ stmt << " to #{to.inspect}" if to
0
+ stmt << " by #{by.inspect}" if by
0
 
0
           expression_eval = lambda { eval(expression) }
0
- before = lambda do
0
- @_before_should_change = expression_eval.bind(self).call
0
- assert_equal from, @_before_should_change, "'#{expression}' was not originally '#{from}'" if from
0
- end
0
+ before = lambda { @_before_should_change = expression_eval.bind(self).call }
0
           should stmt, :before => before do
0
             old_value = @_before_should_change
0
             new_value = expression_eval.bind(self).call
0
- assert_not_equal old_value, new_value, "'#{expression}' did not change" unless by == 0
0
- assert_equal to, new_value, "'#{expression}' was not changed to '#{to}'" if to
0
+ assert_equal from, old_value, "#{expression.inspect} was not originally #{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_equal old_value + by, new_value if by
0
           end
0
         end
0
@@ -81,9 +79,9 @@ module ThoughtBot # :nodoc:
0
         def should_not_change(expression)
0
           expression_eval = lambda { eval(expression) }
0
           before = lambda { @_before_should_not_change = expression_eval.bind(self).call }
0
- should "not change '#{expression}'", :before => before do
0
+ should "not change #{expression.inspect}", :before => before do
0
             new_value = expression_eval.bind(self).call
0
- assert_equal @_before_should_not_change, new_value, "'#{expression}' changed"
0
+ assert_equal @_before_should_not_change, new_value, "#{expression.inspect} changed"
0
           end
0
         end
0
       end

Comments

    No one has commented yet.