aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Scott <e@zzak.io>2014-12-25 12:21:35 -0500
committerZachary Scott <e@zzak.io>2014-12-25 12:21:35 -0500
commitb273c04f15e13a668003b372cc7eedd76b6409f4 (patch)
treea92390a3a0fe26c3491201cd692867a6939f7521
parentd8e0b8ab557a40f1e01e3bb9eeefbcc155901181 (diff)
downloadrails-b273c04f15e13a668003b372cc7eedd76b6409f4.tar.gz
rails-b273c04f15e13a668003b372cc7eedd76b6409f4.tar.bz2
rails-b273c04f15e13a668003b372cc7eedd76b6409f4.zip
Add example to get Errored test to pass in Testing guide [ci skip]
-rw-r--r--guides/source/testing.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md
index c762379cca..f7103adc1c 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -371,6 +371,19 @@ behavior:
$ BACKTRACE=1 bin/rake test test/models/article_test.rb
```
+If we want this test to pass we can modify it to use `assert_raises` like so:
+
+```ruby
+test "should report error" do
+ # some_undefined_variable is not defined elsewhere in the test case
+ assert_raises(NameError) do
+ some_undefined_variable
+ end
+end
+```
+
+This test should now pass.
+
### Available Assertions
By now you've caught a glimpse of some of the assertions that are available. Assertions are the worker bees of testing. They are the ones that actually perform the checks to ensure that things are going as planned.