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

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

Defined Under Namespace

Classes: QueryPhrases, TransactionPhrases

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher) ⇒ MessageBuilder

Returns a new instance of MessageBuilder.



5
6
7
8
9
10
11
12
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 5

def initialize(matcher)
  @matcher = matcher
  @phrase_builder = case matcher
    when Matchers::QueryCountMatcher then QueryPhrases.new(matcher)
    when Matchers::TransactionMatcher then TransactionPhrases.new(matcher)
    else raise ArgumentError
  end
end

Instance Attribute Details

#matcherObject (readonly)

Returns the value of attribute matcher.



3
4
5
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 3

def matcher
  @matcher
end

#phrase_builderObject (readonly)

Returns the value of attribute phrase_builder.



3
4
5
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 3

def phrase_builder
  @phrase_builder
end

Instance Method Details

#failure_messageObject



14
15
16
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 14

def failure_message
  "expected block to #{phrase_builder.prefix}, but it #{phrase_builder.suffix}"
end

#failure_message_when_negatedObject



18
19
20
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 18

def failure_message_when_negated
  "expected block not to #{phrase_builder.prefix}, but it #{phrase_builder.negative_suffix}"
end