From b273c04f15e13a668003b372cc7eedd76b6409f4 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Thu, 25 Dec 2014 12:21:35 -0500 Subject: Add example to get Errored test to pass in Testing guide [ci skip] --- guides/source/testing.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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. -- cgit v1.2.3