Class: RSpec::SubjectCall::Matchers::MeetExpectationsMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/subject_call/matchers/meet_expectations_matcher.rb

Overview

A general purpose matcher that inverts order of operations.

e.g.

expect { A.new(b).method_call_with_side_effect }.to meet_expectations { expect(b).to receive(:command) } }

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ MeetExpectationsMatcher

Returns a new instance of MeetExpectationsMatcher.



11
12
13
# File 'lib/rspec/subject_call/matchers/meet_expectations_matcher.rb', line 11

def initialize(&block)
  @expected_receives = block
end

Instance Method Details

#descriptionObject



20
21
22
# File 'lib/rspec/subject_call/matchers/meet_expectations_matcher.rb', line 20

def description
  'met expectations'
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/rspec/subject_call/matchers/meet_expectations_matcher.rb', line 15

def matches?(subject)
  @expected_receives.call # e.g. expect(x).to receive(:y)
  subject.call # execute the subject (assumed to be a Proc)
end