Sha256: 1cc7f40939e917b3f08c79fcb1d7c60ab22480e18bf279d1d63227b1012c4e7f

Contents?: true

Size: 956 Bytes

Versions: 7

Compression:

Stored size: 956 Bytes

Contents

require 'spec_helper'

module RSpec::Mocks
  describe Space do

    describe "#proxies_of(klass)" do
      let(:space) { Space.new }
      before { space.outside_example = false }

      it 'returns proxies' do
        space.proxy_for("")
        expect(space.proxies_of(String).map(&:class)).to eq([Proxy])
      end

      it 'returns only the proxies whose object is an instance of the given class' do
        grandparent_class = Class.new
        parent_class      = Class.new(grandparent_class)
        child_class       = Class.new(parent_class)

        grandparent = grandparent_class.new
        parent      = parent_class.new
        child       = child_class.new

        _                 = space.proxy_for(grandparent)
        parent_proxy      = space.proxy_for(parent)
        child_proxy       = space.proxy_for(child)

        expect(space.proxies_of(parent_class)).to match_array([parent_proxy, child_proxy])
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rspec-mocks-2.99.4 spec/rspec/mocks/space_spec.rb
rspec-mocks-2.99.3 spec/rspec/mocks/space_spec.rb
rspec-mocks-2.99.2 spec/rspec/mocks/space_spec.rb
rspec-mocks-2.99.1 spec/rspec/mocks/space_spec.rb
rspec-mocks-2.99.0 spec/rspec/mocks/space_spec.rb
rspec-mocks-2.99.0.rc1 spec/rspec/mocks/space_spec.rb
rspec-mocks-2.99.0.beta2 spec/rspec/mocks/space_spec.rb