Class: DataMapperMatchers::HasMany
- Inherits:
-
Object
- Object
- DataMapperMatchers::HasMany
- Defined in:
- lib/spec/matchers/dm/has_many.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(name, options) ⇒ HasMany
constructor
A new instance of HasMany.
-
#matches?(model) ⇒ Boolean
args<Model>: Category.
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(name, options) ⇒ HasMany
Returns a new instance of HasMany.
11 12 13 14 |
# File 'lib/spec/matchers/dm/has_many.rb', line 11 def initialize(name, ) @name = name @options = end |
Instance Method Details
#description ⇒ Object
24 25 26 |
# File 'lib/spec/matchers/dm/has_many.rb', line 24 def description "has many" end |
#failure_message ⇒ Object
28 29 30 31 32 |
# File 'lib/spec/matchers/dm/has_many.rb', line 28 def # TODO: filter just has many relationships properties = @model.properties.entries.map { |property| property.name }.inspect "expected to has many #@name, but has just the following properties: #{properties}" end |
#matches?(model) ⇒ Boolean
args<Model>: Category
17 18 19 20 21 22 |
# File 'lib/spec/matchers/dm/has_many.rb', line 17 def matches?(model) @model = model relationship = @model.relationships[@name] return false unless relationship relationship.parent_model == @model && @options.all? { |key, value| relationship.[key] == value } end |
#negative_failure_message ⇒ Object
34 35 36 |
# File 'lib/spec/matchers/dm/has_many.rb', line 34 def "expected to not has many #@name, but had" end |