Module: SimplyTestable::Assertions::InstanceMethods
- Defined in:
- lib/simply_testable/assertions.rb
Overview
ClassMethods
Instance Method Summary collapse
-
#assert_changes(expression, message = nil, &block) ⇒ Object
basically a copy of assert_difference, but without any explicit comparison as it is simply stating that something will change (designed for updated_at).
-
#deny_changes(expression, message = nil, &block) ⇒ Object
Just a negation of assert_changes.
Instance Method Details
#assert_changes(expression, message = nil, &block) ⇒ Object
basically a copy of assert_difference, but without any explicit comparison as it is simply stating that something will change (designed for updated_at)
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/simply_testable/assertions.rb', line 18 def assert_changes(expression, = nil, &block) b = block.send(:binding) exps = Array.wrap(expression) before = exps.map { |e| eval(e, b) } yield exps.each_with_index do |e, i| error = "#{e.inspect} didn't change" error = "#{}.\n#{error}" if assert_not_equal(before[i], eval(e, b), error) end end |
#deny_changes(expression, message = nil, &block) ⇒ Object
Just a negation of assert_changes
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/simply_testable/assertions.rb', line 31 def deny_changes(expression, = nil, &block) b = block.send(:binding) exps = Array.wrap(expression) before = exps.map { |e| eval(e, b) } yield exps.each_with_index do |e, i| error = "#{e.inspect} changed" error = "#{}.\n#{error}" if assert_equal(before[i], eval(e, b), error) end end |