Sha256: 6a9a4dfbc7cbc92be3448c7f9f4e18bc4a3877a2574cb42b2b35d43f9a9210a2

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

require "spec_helper"

module CC
  describe Resolv do
    describe ".with_fixed_dns" do
      it "replaces the default resolver for the duration of the block" do
        fallback = double

        expect(fallback).to receive(:each_address).
          with("google.com").and_yield("overridden")

        Resolv.with_fixed_dns(fallback) do
          expect(::Resolv.getaddress("google.com")).to eq "overridden"
          expect(::Resolv.getaddress("google.com")).to eq "overridden"
        end

        expect(::Resolv.getaddress("google.com")).not_to eq "overridden"
      end
    end

    describe Resolv::Fixed do
      describe "#each_address" do
        it "delegates to the fallback resolver and caches the first address" do
          fallback = double
          fixed = Resolv::Fixed.new(fallback)

          allow(fallback).to receive(:each_address).
            with("host").once.
            and_yield("address-1").
            and_yield("address-2")

          yielded_1 = []
          yielded_2 = []
          fixed.each_address("host") { |a| yielded_1 << a }
          fixed.each_address("host") { |a| yielded_2 << a }

          expect(yielded_1).to eq ["address-1", "address-2"]
          expect(yielded_2).to eq ["address-1"]
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
codeclimate-services-1.11.4 spec/cc/resolve_spec.rb
codeclimate-services-1.11.3 spec/cc/resolve_spec.rb
codeclimate-services-1.11.2 spec/cc/resolve_spec.rb
codeclimate-services-1.11.1 spec/cc/resolve_spec.rb
codeclimate-services-1.11.0 spec/cc/resolve_spec.rb
codeclimate-services-1.10.1 spec/cc/resolve_spec.rb
codeclimate-services-1.10.0 spec/cc/resolve_spec.rb
codeclimate-services-1.9.8 spec/cc/resolve_spec.rb
codeclimate-services-1.9.7 spec/cc/resolve_spec.rb
codeclimate-services-1.9.6 spec/cc/resolve_spec.rb
codeclimate-services-1.9.5 spec/cc/resolve_spec.rb
codeclimate-services-1.9.4 spec/cc/resolve_spec.rb
codeclimate-services-1.9.3 spec/cc/resolve_spec.rb
codeclimate-services-1.9.2 spec/cc/resolve_spec.rb
codeclimate-services-1.9.1 spec/cc/resolve_spec.rb