Class: RSpec::ActiveRecord::Expectations::MessageBuilder::QueryPhrases

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/activerecord/expectations/message_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher) ⇒ QueryPhrases

Returns a new instance of QueryPhrases.



31
32
33
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 31

def initialize(matcher)
  @matcher = matcher
end

Instance Attribute Details

#matcherObject (readonly)

Returns the value of attribute matcher.



29
30
31
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 29

def matcher
  @matcher
end

Instance Method Details

#negative_suffixObject

using positive suffix from above can cause double negatives



50
51
52
53
54
55
56
57
58
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 50

def negative_suffix
  if matcher.comparison == :exactly
    "did so"
  elsif matcher.actual_count == 1
    "executed one"
  else
    "executed #{matcher.actual_count}"
  end
end

#prefixObject



35
36
37
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 35

def prefix
  "execute #{comparison_phrase} #{query_type_name}"
end

#suffixObject



39
40
41
42
43
44
45
46
47
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 39

def suffix
  if matcher.actual_count == 0
    "didn't execute any"
  elsif matcher.actual_count == 1
    "executed one"
  else
    "executed #{matcher.actual_count}"
  end
end