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
expression_eval = lambda { eval(expression) }
0
- @_before_should_change = expression_eval.bind(self).call
0
- assert_equal from, @_before_should_change, "'#{expression}' was not originally '#{from}'" if from
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
@@ -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"
Comments
No one has commented yet.