Sha256: 072ca8a693edd24da6e0843c579d8139976c68fe1fc07e1d0272fe32842bc612

Contents?: true

Size: 1.42 KB

Versions: 44

Compression:

Stored size: 1.42 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

        InovcationOrder =
          {
            :and_return => [:with, nil],
            :and_raise => [:with, nil],
            :and_yield => [:with, :and_yield, nil],
            :and_throw => [:with, nil],
            :and_call_original => [:with, nil],
            :and_wrap_original => [:with, nil]
          }.freeze

        EmptyInvocationOrder = {}.freeze

        def invocation_order
          InovcationOrder
        end

        def verify_invocation_order(rspec_method_name, *_args, &_block)
          return if invocation_order.fetch(rspec_method_name, [nil]).include?(last_message)
          raise NoMethodError, "Undefined method #{rspec_method_name}"
        end
      end
    end
  end
end

Version data entries

44 entries across 39 versions & 19 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
cloudsmith-api-0.30.7 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/stub_chain.rb
tdiary-5.0.9 vendor/bundle/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
color_me_shop-1.0.0 vendor/bundle/ruby/2.5.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
monero_wallet_gen-0.1.0 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
sb_prime_table-0.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
sb_prime_table-0.1.0 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
tdiary-5.0.8 vendor/bundle/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
tdiary-5.0.7 vendor/bundle/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
comidita_ull-0.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb
comidita_ull-0.1.0 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-3.7.0/lib/rspec/mocks/any_instance/stub_chain.rb