4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/rspec_rails_matchers/associations/have_one.rb', line 4
def have_one(association)
Rspec::Matchers::Matcher.new :have_one, association do |_association_|
extend RspecRailsMatchers::Associations::Helpers
match do |model|
associations(model, :has_one).any? { |a| a == _association_ }
end
failure_message_for_should do |model|
RspecRailsMatchers::Message.error(
:expected => [ "%s to have one %s", model, _association_ ],
:actual => [ "%s has one %s", model, associations(model, :has_one) ]
)
end
end
end
|