Skip to content

Commit 2c6fafb

Browse files
BritniBritni
authored andcommitted
use values_matcher? insead of eql? to determine with matching
1 parent c6da310 commit 2c6fafb

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/rspec/rails/matchers/be_a_new.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ def attributes
4949

5050
def attributes_match?(actual)
5151
attributes.stringify_keys.all? do |key, value|
52-
actual.attributes[key].eql?(value) || (value.respond_to?(:expected, true) && actual.attributes[key].include?(value.expected))
52+
values_match?(value, actual.attributes[key])
5353
end
5454
end
5555

5656
def unmatched_attributes
5757
attributes.stringify_keys.reject do |key, value|
58-
actual.attributes[key].eql?(value)
58+
values_match?(value, actual.attributes[key])
5959
end
6060
end
6161
end

spec/rspec/rails/matchers/be_a_new_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def new_record?; true; end
6969
context "one attribute is a composable matcher" do
7070
it "passes" do
7171
expect(record).to be_a_new(record.class).with(
72-
:foo => a_string_matching("foo"))
72+
:foo => a_string_including("foo"))
7373
end
7474

7575
it "fails" do
@@ -111,8 +111,7 @@ def new_record?; true; end
111111
:bar => a_string_matching("barn")
112112
)
113113
}.to raise_error {|e|
114-
expect(e.message).to match(/attributes \{.*\} were not set on #{Regexp.escape record.inspect}/)
115-
expect(e.message).to match(/@expected="foo"/)
114+
expect(e.message).to match(/attribute \{.*\} was not set on #{Regexp.escape record.inspect}/)
116115
expect(e.message).to match(/@expected="barn"/)
117116
}
118117
end

0 commit comments

Comments
 (0)