class RSpec::ActiveRecord::Expectations::Matchers::TransactionMatcher

Attributes

collector[R]
comparison[R]
quantifier[R]
query_type[R]

Public Class Methods

new(transaction_type) click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 6
def initialize(transaction_type)
  @collector    = Collector.new
  @query_type  = transaction_type
  @message_builder = MessageBuilder.new(self)

  self.at_least(1)
end

Public Instance Methods

actual_count() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 94
def actual_count
  @collector.queries_of_type(@query_type)
end
at_least(n)
at_most(n)
exactly(n) click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 70
def exactly(n)
  @quantifier   = n
  @comparison = :exactly
  @match_method = -> { actual_count == @quantifier }
  self
end
failure_message() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 14
def failure_message
  @message_builder.failure_message
end
failure_message_when_negated() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 18
def failure_message_when_negated
  @message_builder.failure_message_when_negated
end
fewer_than(n)
Alias for: less_than
greater_than(n) click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 54
def greater_than(n)
  @quantifier   = n
  @comparison = :greater_than
  @match_method = -> { actual_count > @quantifier }
  self
end
Also aliased as: more_than
greater_than_or_equal_to(n) click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 62
def greater_than_or_equal_to(n)
  @quantifier   = n
  @comparison = :greater_than_or_equal_to
  @match_method = -> { actual_count >= @quantifier }
  self
end
Also aliased as: at_least
less_than(n) click to toggle source

QUANTIFIERS

# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 38
def less_than(n)
  @quantifier   = n
  @comparison = :less_than
  @match_method = -> { actual_count < @quantifier }
  self
end
Also aliased as: fewer_than
less_than_or_equal_to(n) click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 46
def less_than_or_equal_to(n)
  @quantifier   = n
  @comparison = :less_than_or_equal_to
  @match_method = -> { actual_count <= @quantifier }
  self
end
Also aliased as: at_most
matches?(block) click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 26
def matches?(block)
  raise NoComparisonError unless @match_method

  block.call
  result = @match_method.call
  @collector.finalize

  result
end
more_than(n)
Alias for: greater_than
once() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 77
def once
  exactly(1).time
end
supports_block_expectations?() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 22
def supports_block_expectations?
  true
end
thrice() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 85
def thrice # hehe
  exactly(3).times
end
time()
Alias for: times
times() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 89
def times
  self # NOOP
end
Also aliased as: time
twice() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/transaction_matcher.rb, line 81
def twice
  exactly(2).times
end