|
20 | 20 | it { expect(doc).to have_attribute(:six).with_value(foo: 'bar') } |
21 | 21 |
|
22 | 22 | it 'rejects with an appropriate failure message' do |
23 | | - expect { |
24 | | - expect(doc).to have_attribute(:three) |
25 | | - }.to fail_with('expected attributes to include `three`. Actual attributes were ["one", "two", "four", "six"]') |
| 23 | + expect { expect(doc).to have_attribute(:three) } |
| 24 | + .to raise_error( |
| 25 | + RSpec::Expectations::ExpectationNotMetError, |
| 26 | + 'expected attributes to include `three`. ' \ |
| 27 | + 'Actual attributes were ["one", "two", "four", "six"]' |
| 28 | + ) |
26 | 29 | end |
27 | 30 |
|
28 | | - it 'rejects with an appropriate failure message for chained with_value, simple values' do |
29 | | - expect { |
30 | | - expect(doc).to have_attribute(:one).with_value(2) |
31 | | - }.to fail_with('expected `one` attribute to have value `2` but was `1`') |
| 31 | + it 'fails with a failure message for chained with_value' do |
| 32 | + expect { expect(doc).to have_attribute(:one).with_value(2) } |
| 33 | + .to raise_error( |
| 34 | + RSpec::Expectations::ExpectationNotMetError, |
| 35 | + /expected `one` attribute to have value `2` but was `1`/m |
| 36 | + ) |
32 | 37 | end |
33 | 38 |
|
34 | | - it 'rejects with an appropriate failure message for chained with_value, complex values show diff' do |
35 | | - expect { |
36 | | - expect(doc).to have_attribute(:six).with_value(bar: 'baz') |
37 | | - }.to fail_with(/expected `six` attribute to have value `{:bar=>"baz"}` but was `{:foo=>"bar"}`.*Diff:/m) |
| 39 | + it 'fails with a failure message and diff for chained with_value' do |
| 40 | + expect { expect(doc).to have_attribute(:six).with_value(bar: 'baz') } |
| 41 | + .to raise_error( |
| 42 | + RSpec::Expectations::ExpectationNotMetError, |
| 43 | + /expected `six` .* `{:bar=>"baz"}` but was `{:foo=>"bar"}`.*Diff:/m |
| 44 | + ) |
38 | 45 | end |
39 | 46 | end |
40 | 47 |
|
|
0 commit comments