Sha256: fd248d3d4cd0302391a3466711d38326a7cc2372f0a5b528fab97c3189fb915e

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 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.space.proxy_for(instance)
          method_name, opts = @expectation_args
          opts = (opts || {}).merge(:expected_form => IGNORED_BACKTRACE_LINE)

          stub = proxy.add_stub(method_name, opts, &@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

8 entries across 8 versions & 2 rubygems

Version Path
rspec-mocks-3.0.4 lib/rspec/mocks/any_instance/stub_chain.rb
rspec-mocks-3.0.3 lib/rspec/mocks/any_instance/stub_chain.rb
rspec-mocks-3.0.2 lib/rspec/mocks/any_instance/stub_chain.rb
whos_dated_who-0.1.0 vendor/bundle/gems/rspec-mocks-3.0.1/lib/rspec/mocks/any_instance/stub_chain.rb
whos_dated_who-0.0.1 vendor/bundle/gems/rspec-mocks-3.0.1/lib/rspec/mocks/any_instance/stub_chain.rb
rspec-mocks-3.0.1 lib/rspec/mocks/any_instance/stub_chain.rb
rspec-mocks-3.0.0 lib/rspec/mocks/any_instance/stub_chain.rb
rspec-mocks-3.0.0.rc1 lib/rspec/mocks/any_instance/stub_chain.rb