Class: RSpec::ActiveRecord::Expectations::MessageBuilder::TransactionPhrases
- Inherits:
-
Object
- Object
- RSpec::ActiveRecord::Expectations::MessageBuilder::TransactionPhrases
- Defined in:
- lib/rspec/activerecord/expectations/message_builder.rb
Instance Attribute Summary collapse
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
Instance Method Summary collapse
-
#initialize(matcher) ⇒ TransactionPhrases
constructor
A new instance of TransactionPhrases.
- #negative_suffix ⇒ Object
- #prefix ⇒ Object
- #suffix ⇒ Object
Constructor Details
#initialize(matcher) ⇒ TransactionPhrases
Returns a new instance of TransactionPhrases.
93 94 95 |
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 93 def initialize(matcher) @matcher = matcher end |
Instance Attribute Details
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
91 92 93 |
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 91 def matcher @matcher end |
Instance Method Details
#negative_suffix ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 130 def negative_suffix if matcher.comparison == :exactly "did so" else suffix end end |
#prefix ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 97 def prefix nouns = matcher.quantifier == 1 ? "transaction" : "transactions" verb = case matcher.query_type when :transaction_queries then "execute" when :rollback_queries then "roll back" when :commit_queries then "commit" end "#{verb} #{comparison} #{nouns}" end |
#suffix ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/rspec/activerecord/expectations/message_builder.rb', line 108 def suffix singular_verb = case matcher.query_type when :transaction_queries then "execute" when :rollback_queries then "roll back" when :commit_queries then "commit" end plural_verb = case matcher.query_type when :transaction_queries then "executed" when :rollback_queries then "rolled back" when :commit_queries then "committed" end if matcher.actual_count == 0 "didn't #{singular_verb} any" elsif matcher.actual_count == 1 "#{plural_verb} one" else "#{plural_verb} #{matcher.actual_count}" end end |