Sha256: 087104a66c4334031091ddbfaca639413f8648bcf768484257bbf9f4af4719ae

Contents?: true

Size: 1.82 KB

Versions: 8

Compression:

Stored size: 1.82 KB

Contents

module RSpec
  module Mocks
    module AnyInstance
      # @api private
      class ExpectationChain < Chain
        def expectation_fulfilled?
          @expectation_fulfilled || constrained_to_any_of?(:never, :any_number_of_times)
        end

        def initialize(*args, &block)
          record(*args, &block)
          @expectation_fulfilled = false
        end

        private
        def verify_invocation_order(rspec_method_name, *args, &block)
        end
      end

      # @api private
      class PositiveExpectationChain < ExpectationChain
        def initialize(*args, &block)
          super(:should_receive, *args, &block)
        end

        private

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

      # @api private
      class NegativeExpectationChain < ExpectationChain
        def initialize(*args, &block)
          super(:should_not_receive, *args, &block)
        end

        # `should_not_receive` causes a failure at the point in time the
        # message is wrongly received, rather than during `rspec_verify`
        # at the end of an example. Thus, we should always consider a
        # negative expectation fulfilled for the purposes of end-of-example
        # verification (which is where this is used).
        def expectation_fulfilled?
          true
        end

        private

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

Version data entries

8 entries across 8 versions & 5 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-mocks-2.13.0/lib/rspec/mocks/any_instance/expectation_chain.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/lib/rspec/mocks/any_instance/expectation_chain.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/lib/rspec/mocks/any_instance/expectation_chain.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/lib/rspec/mocks/any_instance/expectation_chain.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/lib/rspec/mocks/any_instance/expectation_chain.rb
rspec-mocks-2.13.1 lib/rspec/mocks/any_instance/expectation_chain.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-mocks-2.13.0/lib/rspec/mocks/any_instance/expectation_chain.rb
rspec-mocks-2.13.0 lib/rspec/mocks/any_instance/expectation_chain.rb