Method: CommonLib::ActiveSupportExtension::TestCase#assert_changes
- Defined in:
- lib/common_lib/active_support_extension/test_case.rb
#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)
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/common_lib/active_support_extension/test_case.rb', line 170 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 |