Class: Neo4j::RSpec::Matchers::HasN::BaseMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/rspec/matchers/has_n.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher, value) ⇒ BaseMatcher

Returns a new instance of BaseMatcher.



8
9
10
11
# File 'lib/neo4j/rspec/matchers/has_n.rb', line 8

def initialize(matcher, value)
  @matcher = matcher
  @value = convert_value(value)
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



6
7
8
# File 'lib/neo4j/rspec/matchers/has_n.rb', line 6

def actual
  @actual
end

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/neo4j/rspec/matchers/has_n.rb', line 6

def key
  @key
end

#matcherObject (readonly)

Returns the value of attribute matcher.



6
7
8
# File 'lib/neo4j/rspec/matchers/has_n.rb', line 6

def matcher
  @matcher
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/neo4j/rspec/matchers/has_n.rb', line 6

def value
  @value
end

Instance Method Details

#addObject



13
14
15
16
17
# File 'lib/neo4j/rspec/matchers/has_n.rb', line 13

def add
  matcher.expectation_message << expectation_message
  matcher.association[key] = self
  matcher
end

#add_negativeObject



19
20
21
22
23
# File 'lib/neo4j/rspec/matchers/has_n.rb', line 19

def add_negative
  matcher.expectation_message << negative_expectation_message
  matcher.association[key] = self
  matcher
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
# File 'lib/neo4j/rspec/matchers/has_n.rb', line 25

def matches?(actual)
  @actual = extact_actual(actual)
  if matches
    matcher.negative_result_message = result_message
    false
  else
    matcher.positive_result_message = result_message
    true
  end
end