class RSpec::ActiveRecord::Expectations::Matchers::LoadMatcher

Public Class Methods

new(klass) click to toggle source
# File lib/rspec/activerecord/expectations/matchers/load_matcher.rb, line 4
def initialize(klass)
  @collector = Collector.new
  @klass = klass.to_s
end

Public Instance Methods

failure_message() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/load_matcher.rb, line 20
def failure_message
  "expected block to repeatedly load #{@klass}, but it was loaded #{@count} times"
end
failure_message_when_negated() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/load_matcher.rb, line 24
def failure_message_when_negated
  "expected block not to repeatedly load #{@klass}, but it was loaded #{@count} times"
end
matches?(block) click to toggle source
# File lib/rspec/activerecord/expectations/matchers/load_matcher.rb, line 13
def matches?(block)
  block.call

  @count = @collector.calls_by_name("#{@klass} Load")
  @count > 1
end
supports_block_expectations?() click to toggle source
# File lib/rspec/activerecord/expectations/matchers/load_matcher.rb, line 9
def supports_block_expectations?
  true
end