Class: AssociationAccessors::Test::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/association_accessors/test/matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(association_name) ⇒ Matcher

Returns a new instance of Matcher.



10
11
12
# File 'lib/association_accessors/test/matcher.rb', line 10

def initialize association_name
  @association_name = association_name
end

Instance Attribute Details

#associationObject (readonly)

Returns the value of attribute association.



8
9
10
# File 'lib/association_accessors/test/matcher.rb', line 8

def association
  @association
end

#association_nameObject (readonly)

Returns the value of attribute association_name.



8
9
10
# File 'lib/association_accessors/test/matcher.rb', line 8

def association_name
  @association_name
end

#attributeObject (readonly)

Returns the value of attribute attribute.



8
9
10
# File 'lib/association_accessors/test/matcher.rb', line 8

def attribute
  @attribute
end

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



8
9
10
# File 'lib/association_accessors/test/matcher.rb', line 8

def failure_message
  @failure_message
end

#subjectObject (readonly)

Returns the value of attribute subject.



8
9
10
# File 'lib/association_accessors/test/matcher.rb', line 8

def subject
  @subject
end

Instance Method Details

#descriptionObject



14
15
16
# File 'lib/association_accessors/test/matcher.rb', line 14

def description
  "have association accessor for #{association_name.inspect} with attribute #{attribute.inspect}."
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'lib/association_accessors/test/matcher.rb', line 18

def matches? subject
  @subject = subject
  @association = get_association

  check_attribute!

  has_accessors?
end

#with_attribute(attribute) ⇒ Object



27
28
29
30
# File 'lib/association_accessors/test/matcher.rb', line 27

def with_attribute attribute
  @attribute = attribute
  self
end