Minitest Change Assertions
Provides assertions for your Minitest suite to determine if an object has been changed.
Install
gem 'minitest_change_assertions'
Usage
assert_changed
assert_changed 'user.name' do
user.name = 'Bob'
end
assert_changed -> { user.name } do
user.name = 'Bob'
end
assert_changed 'user.name', to: 'Bob' do
user.name = 'Bob'
end
assert_changed -> { user.name }, to: 'Bob' do
user.name = 'Bob'
end
assert_not_changed
assert_not_changed 'user.name' do
user.update(attrs)
end
assert_not_changed -> { user.name } do
user.update(attrs)
end
assert_not_changed 'user.name', to: 'Allen' do
user.name = 'Bob'
end
assert_not_changed -> { user.name }, to: 'Allen' do
user.name = 'Bob'
end
Credits
Created by Weston Ganger - @westonganger
For any consulting or contract work please contact me via my company website: Solid Foundation Web Development