File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed
spec/rspec/rails/matchers Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,11 @@ def failure_message
32
32
message << "expected #{ actual . inspect } to be a new #{ expected . inspect } "
33
33
end
34
34
unless attributes_match? ( actual )
35
+ describe_unmatched_attributes = surface_descriptions_in ( unmatched_attributes )
35
36
if unmatched_attributes . size > 1
36
- message << "attributes #{ unmatched_attributes . inspect } were not set on #{ actual . inspect } "
37
+ message << "attributes #{ describe_unmatched_attributes . inspect } were not set on #{ actual . inspect } "
37
38
else
38
- message << "attribute #{ unmatched_attributes . inspect } was not set on #{ actual . inspect } "
39
+ message << "attribute #{ describe_unmatched_attributes . inspect } was not set on #{ actual . inspect } "
39
40
end
40
41
end
41
42
end . join ( ' and ' )
Original file line number Diff line number Diff line change @@ -76,11 +76,9 @@ def new_record?; true; end
76
76
expect {
77
77
expect ( record ) . to be_a_new ( record . class ) . with (
78
78
:foo => a_string_matching ( "bar" ) )
79
- } . to raise_error { |e |
80
- expect ( e . message ) . to match ( /attribute \{ .*\} was not set on #{ Regexp . escape record . inspect } / )
81
- expect ( e . message ) . to match ( /@expected="bar"/ )
82
- }
79
+ } . to raise_error ( "attribute {\" foo\" =>(a string matching \" bar\" )} was not set on #{ record . inspect } " )
83
80
end
81
+
84
82
context "matcher is wrong type" do
85
83
it "fails" do
86
84
expect {
@@ -110,10 +108,7 @@ def new_record?; true; end
110
108
:foo => a_string_matching ( "foo" ) ,
111
109
:bar => a_string_matching ( "barn" )
112
110
)
113
- } . to raise_error { |e |
114
- expect ( e . message ) . to match ( /attribute \{ .*\} was not set on #{ Regexp . escape record . inspect } / )
115
- expect ( e . message ) . to match ( /@expected="barn"/ )
116
- }
111
+ } . to raise_error ( "attribute {\" bar\" =>(a string matching \" barn\" )} was not set on #{ record . inspect } " )
117
112
end
118
113
end
119
114
end
You can’t perform that action at this time.
0 commit comments