https://github.com/ndp/assert_changes
test helpers to concisely assert pre-conditions and post-conditions
https://github.com/ndp/assert_changes
Last synced: 4 months ago
JSON representation
test helpers to concisely assert pre-conditions and post-conditions
- Host: GitHub
- URL: https://github.com/ndp/assert_changes
- Owner: ndp
- Created: 2009-05-14T04:16:19.000Z (about 17 years ago)
- Default Branch: master
- Last Pushed: 2009-05-14T08:29:39.000Z (about 17 years ago)
- Last Synced: 2025-10-08T03:55:28.263Z (8 months ago)
- Homepage:
- Size: 82 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
Assertion that a specific state changes during invocation of the
passed in block.
i = 'simple'
assert_changes 'i' => 'whacky' do
i = 'whacky'
end
This can be read "assert i changes to wacky".
Function will verify both the precondition (i is NOT wacky),
and the post-condition.
This means i becomes nil during the block (and therefore non-nil
beforehand):
assert_changes 'i' => nil do ...
If you want to specify a specific transition, you can do so
by providing an array:
assert_changes 'i' => ['simple','whacky'] do
To specify that there should be no changes, use the symbol :no_change.
assert_changes 'i' => :no_change do
Finally, multiple assertions can be passed for larger sets
of state changes:
i, j = 1,2
assert_changes 'i' => [1, 2], 'j' => [2, 1] do
Mixer.mix(i,j)
end