class RSpec::ActiveRecord::Expectations::Matchers::QueryCountMatcher
Attributes
collector[R]
comparison[R]
quantifier[R]
query_type[R]
Public Class Methods
new()
click to toggle source
# File lib/rspec/activerecord/expectations/matchers/query_count_matcher.rb, line 6 def initialize @collector = Collector.new @message_builder = MessageBuilder.new(self) @match_method = nil @quantifier = nil @query_type = nil end
Public Instance Methods
actual_count()
click to toggle source
helper for message builder
# File lib/rspec/activerecord/expectations/matchers/query_count_matcher.rb, line 98 def actual_count @collector.queries_of_type(@query_type) end
exactly(n)
click to toggle source
# File lib/rspec/activerecord/expectations/matchers/query_count_matcher.rb, line 72 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/query_count_matcher.rb, line 15 def failure_message @message_builder.failure_message end
failure_message_when_negated()
click to toggle source
# File lib/rspec/activerecord/expectations/matchers/query_count_matcher.rb, line 19 def failure_message_when_negated @message_builder.failure_message_when_negated end
greater_than(n)
click to toggle source
# File lib/rspec/activerecord/expectations/matchers/query_count_matcher.rb, line 56 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/query_count_matcher.rb, line 64 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/query_count_matcher.rb, line 40 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/query_count_matcher.rb, line 48 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/query_count_matcher.rb, line 27 def matches?(block) raise NoComparisonError unless @match_method raise NoQueryTypeError unless @collector.valid_type?(@query_type) block.call result = @match_method.call @collector.finalize result end
supports_block_expectations?()
click to toggle source
# File lib/rspec/activerecord/expectations/matchers/query_count_matcher.rb, line 23 def supports_block_expectations? true end