Created
March 14, 2009 10:49
-
-
Save methodmissing/79044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_should_rollback_any_changes_if_an_exception_occurred_while_saving | |
| before = [@pirate.catchphrase, @pirate.ship.name] | |
| @pirate.catchphrase = 'Arr' | |
| @pirate.ship.name = 'The Vile Insanity' | |
| # Stub the save method of the @pirate.ship instance to raise an exception | |
| class << @pirate.ship | |
| def save(*args) | |
| super | |
| raise 'Oh noes!' | |
| end | |
| end | |
| assert_raise(RuntimeError) { assert !@pirate.save } | |
| assert_equal before, [@pirate.reload.catchphrase, @pirate.ship.name] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment