class RSpec::SubjectCall::Matchers::MeetExpectationsMatcher

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) } }

Public Class Methods

new(&block) click to toggle source
# File lib/rspec/subject_call/matchers/meet_expectations_matcher.rb, line 11
def initialize(&block)
  @expected_receives = block
end

Public Instance Methods

description() click to toggle source
# File lib/rspec/subject_call/matchers/meet_expectations_matcher.rb, line 20
def description
  'met expectations'
end
matches?(subject) click to toggle source
# 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