Sha256: d4ab42e283707932ffd27a71d5a4eaef6f8cf19f39ad7e1c54d04cc3dbf99a3f

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

require 'unit_spec_helper'

module Shoulda::Matchers::Doublespeak
  describe ProxyImplementation do
    describe '#returns' do
      it 'delegates to its stub_implementation' do
        stub_implementation = build_stub_implementation
        implementation = described_class.new(stub_implementation)
        implementation.returns(:value)

        expect(stub_implementation).to have_received(:returns).with(:value)
      end
    end

    describe '#call' do
      it 'delegates to its stub_implementation' do
        stub_implementation = build_stub_implementation
        double = build_double
        implementation = described_class.new(stub_implementation)
        implementation.call(double, :object, :args, :block)

        expect(stub_implementation).
          to have_received(:call).
          with(double, :object, :args, :block)
      end

      it 'calls #call_original_method on the double' do
        stub_implementation = build_stub_implementation
        implementation = described_class.new(stub_implementation)
        double = build_double
        implementation.call(double, :object, :args, :block)

        expect(double).
          to have_received(:call_original_method).
          with(:object, :args, :block)
      end
    end

    def build_stub_implementation
      double('stub_implementation', returns: nil, call: nil)
    end

    def build_double
      double('double', call_original_method: nil)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb
shoulda-matchers-2.8.0 spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb
shoulda-matchers-2.8.0.rc2 spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb
shoulda-matchers-2.8.0.rc1 spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb