Class: RSpec::ActiveRecord::Expectations::MessageBuilder
- Inherits:
-
Object
- Object
- RSpec::ActiveRecord::Expectations::MessageBuilder
- Defined in:
- lib/rspec/activerecord/expectations/message_builder.rb
Defined Under Namespace
Classes: QueryPhrases, TransactionPhrases
Instance Attribute Summary collapse
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
-
#phrase_builder ⇒ Object
readonly
Returns the value of attribute phrase_builder.
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(matcher) ⇒ MessageBuilder
constructor
A new instance of MessageBuilder.
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
#matcher ⇒ Object (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_builder ⇒ Object (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_message ⇒ Object
14 15 16 |
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 14 def "expected block to #{phrase_builder.prefix}, but it #{phrase_builder.suffix}" end |
#failure_message_when_negated ⇒ Object
18 19 20 |
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 18 def "expected block not to #{phrase_builder.prefix}, but it #{phrase_builder.negative_suffix}" end |