Sha256: f866d303ebe989f13d23f0e93988d6cf7c0e04015ddece84ecb4f7f5a5f5bf72

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

module RSpec
  module SubjectCall
    module Matchers
      # 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) } }
      #
      class MeetExpectationsMatcher
        def initialize(&block)
          @expected_receives = block
        end

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

        def description
          'met expectations'
        end
      end
    end
  end

  module Matchers
    def meet_expectations(&block)
      ::RSpec::SubjectCall::Matchers::MeetExpectationsMatcher.new(&block)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-subject_call-1.0.2 lib/rspec/subject_call/matchers/meet_expectations_matcher.rb