Class: Liquid::Rails::Rspec::DropMatchers::AssociationMatcher
- Inherits:
-
Object
- Object
- Liquid::Rails::Rspec::DropMatchers::AssociationMatcher
- Defined in:
- lib/liquid4-rails/rspec/drop_matchers.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #class_name(class_name) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(name, options) ⇒ AssociationMatcher
constructor
A new instance of AssociationMatcher.
- #matches?(actual) ⇒ Boolean
- #scope(scope_name) ⇒ Object
- #with(class_name) ⇒ Object
Constructor Details
#initialize(name, options) ⇒ AssociationMatcher
Returns a new instance of AssociationMatcher.
64 65 66 67 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 64 def initialize(name, ) @name = name @options = end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
62 63 64 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 62 def actual @actual end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
62 63 64 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 62 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
62 63 64 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 62 def @options end |
Instance Method Details
#class_name(class_name) ⇒ Object
91 92 93 94 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 91 def class_name(class_name) @options[:class_name] = class_name self end |
#description ⇒ Object
96 97 98 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 96 def description "have association #{name}" end |
#failure_message ⇒ Object
100 101 102 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 100 def %Q{expected #{actual.inspect} to define "#{name}" as :#{[:type]} association} end |
#failure_message_when_negated ⇒ Object
104 105 106 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 104 def %Q{expected #{actual.inspect} not to define "#{name}" as :#{[:type]} association} end |
#matches?(actual) ⇒ Boolean
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 69 def matches?(actual) @actual = actual association = associations[name] result = association.present? && association[:type] == [:type] result = result && association[:options][:scope] == [:scope] if [:scope] result = result && association[:options][:with] == [:with] if [:with] result = result && association[:options][:class_name] == [:class_name] if [:class_name] result end |
#scope(scope_name) ⇒ Object
86 87 88 89 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 86 def scope(scope_name) @options[:scope] = scope_name self end |
#with(class_name) ⇒ Object
81 82 83 84 |
# File 'lib/liquid4-rails/rspec/drop_matchers.rb', line 81 def with(class_name) @options[:with] = class_name self end |