Class: RSpec::ActiveRecord::Expectations::Matchers::LoadMatcher
- Inherits:
-
Object
- Object
- RSpec::ActiveRecord::Expectations::Matchers::LoadMatcher
- Defined in:
- lib/rspec/activerecord/expectations/matchers/load_matcher.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(klass) ⇒ LoadMatcher
constructor
A new instance of LoadMatcher.
- #matches?(block) ⇒ Boolean
- #supports_block_expectations? ⇒ Boolean
Constructor Details
#initialize(klass) ⇒ LoadMatcher
Returns a new instance of LoadMatcher.
4 5 6 7 |
# File 'lib/rspec/activerecord/expectations/matchers/load_matcher.rb', line 4 def initialize(klass) @collector = Collector.new @klass = klass.to_s end |
Instance Method Details
#failure_message ⇒ Object
20 21 22 |
# File 'lib/rspec/activerecord/expectations/matchers/load_matcher.rb', line 20 def "expected block to repeatedly load #{@klass}, but it was loaded #{@count} times" end |
#failure_message_when_negated ⇒ Object
24 25 26 |
# File 'lib/rspec/activerecord/expectations/matchers/load_matcher.rb', line 24 def "expected block not to repeatedly load #{@klass}, but it was loaded #{@count} times" end |
#matches?(block) ⇒ Boolean
13 14 15 16 17 18 |
# 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? ⇒ Boolean
9 10 11 |
# File 'lib/rspec/activerecord/expectations/matchers/load_matcher.rb', line 9 def supports_block_expectations? true end |