Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 23 lines (19 sloc) 0.813 kb
3e2e9bd @dchelimsky add features (moved from rspec-core)
dchelimsky authored
1 Feature: customized message
2
2b7b0d8 @dchelimsky simplify feature
dchelimsky authored
3 RSpec tries to provide useful failure messages, but for cases in which you
4 want more specific information, you can define your own message right in the
5 example. This works for any matcher _other than the operator matchers_.
3e2e9bd @dchelimsky add features (moved from rspec-core)
dchelimsky authored
6
2b7b0d8 @dchelimsky simplify feature
dchelimsky authored
7 Scenario: customize failure message
8 Given a file named "example_spec.rb" with:
733e5d8 @vanstee Identify ruby code for syntax highlighting
vanstee authored
9 """ruby
2b7b0d8 @dchelimsky simplify feature
dchelimsky authored
10 describe Array do
11 context "when created with `new`" do
12 it "is empty" do
13 array = Array.new
14 array << 1 # trigger a failure to demonstrate the message
15 array.should be_empty, "expected empty array, got #{array.inspect}"
16 end
3e2e9bd @dchelimsky add features (moved from rspec-core)
dchelimsky authored
17 end
18 end
19
20 """
0a29866 @dchelimsky upgrade cucumber and aruba
dchelimsky authored
21 When I run `rspec example_spec.rb --format documentation`
2b7b0d8 @dchelimsky simplify feature
dchelimsky authored
22 Then the output should contain "expected empty array, got [1]"
Something went wrong with that request. Please try again.