Sha256: 36705f83263e9e59fc4ef1cbe76983665e7a83da7d5a5b7f545154a8119e016e

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

module RSpec
  module Mocks
    module AnyInstance
      # @private
      class StubChain < Chain

        # @private
        def expectation_fulfilled?
          true
        end

        private

        def create_message_expectation_on(instance)
          proxy = ::RSpec::Mocks.proxy_for(instance)
          expected_from = IGNORED_BACKTRACE_LINE
          stub = proxy.add_stub(expected_from, *@expectation_args, &@expectation_block)
          @recorder.stubs[stub.message] << stub

          if RSpec::Mocks.configuration.yield_receiver_to_any_instance_implementation_blocks?
            stub.and_yield_receiver_to_implementation
          end

          stub
        end

        def invocation_order
          @invocation_order ||= {
            :with => [nil],
            :and_return => [:with, nil],
            :and_raise => [:with, nil],
            :and_yield => [:with, nil],
            :and_call_original => [:with, nil]
          }
        end

        def verify_invocation_order(rspec_method_name, *args, &block)
          unless invocation_order[rspec_method_name].include?(last_message)
            raise(NoMethodError, "Undefined method #{rspec_method_name}")
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
opal-rspec-cj-0.4.4 vendor_lib/rspec/mocks/any_instance/stub_chain.rb
opal-rspec-0.4.3 vendor_lib/rspec/mocks/any_instance/stub_chain.rb
opal-rspec-0.4.2 vendor_lib/rspec/mocks/any_instance/stub_chain.rb
opal-rspec-0.4.1 vendor_lib/rspec/mocks/any_instance/stub_chain.rb
opal-rspec-0.4.0 vendor_lib/rspec/mocks/any_instance/stub_chain.rb
opal-rspec-0.4.0.beta4 vendor_lib/rspec/mocks/any_instance/stub_chain.rb
rspec-mocks-3.0.0.beta1 lib/rspec/mocks/any_instance/stub_chain.rb