Class: RspecSequel::Association
- Defined in:
- lib/rspec_sequel/association.rb
Direct Known Subclasses
Matchers::HaveManyToManyMatcher, Matchers::HaveManyToOneMatcher, Matchers::HaveOneToManyMatcher, Matchers::HaveOneToOneMatcher
Instance Method Summary collapse
Methods inherited from Base
#failure_message, #failure_message_when_negated, #hash_to_nice_string, #initialize, #matches?
Constructor Details
This class inherits a constructor from RspecSequel::Base
Instance Method Details
#description ⇒ Object
5 6 7 8 9 |
# File 'lib/rspec_sequel/association.rb', line 5 def description desc = "have a #{association_type} association #{@attribute.inspect}" desc << " with option(s) #{hash_to_nice_string @options}" unless @options.empty? desc end |
#valid?(db, i, c, attribute, options) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rspec_sequel/association.rb', line 11 def valid?(db, i, c, attribute, ) @association = c.association_reflection(attribute) || {} if @association.empty? @suffix << "(no association #{@attribute.inspect} found)" false else matching = @association[:type] == association_type .each{|key, value| if @association[key]!=value @suffix << "expected #{key.inspect} == #{value.inspect} but found #{@association[key].inspect} instead" matching = false end } matching end end |