Sha256: 2bfb98d2a6a86cdee41bbf2813c226ae55da02a042e563ff74c3828b9b6555ff

Contents?: true

Size: 857 Bytes

Versions: 27

Compression:

Stored size: 857 Bytes

Contents

require "spec_helper"

describe Fog::CurrentMachine do
  before do
    @was_mocking = Fog.mock?
    Fog.mock!

    @old_excon_defaults_mock = Excon.defaults[:mock]
    Excon.defaults[:mock] = true
  end

  after do
    Fog.unmock! unless @was_mocking

    Fog::CurrentMachine.ip_address = nil
    Excon.stubs.clear
    Excon.defaults[:mock] = @old_excon_defaults_mock
  end

  describe "ip_address" do
    it "should be thread safe" do

      (1..10).map do
        Thread.new do
          Excon.stub({ :method => :get, :path => "/" }, { :body => "" })
          Fog::CurrentMachine.ip_address
        end
      end.each(&:join)
    end

    it "should remove trailing endline characters" do
      Excon.stub({ :method => :get, :path => "/" }, { :body => "192.168.0.1\n" })
      assert_equal "192.168.0.1", Fog::CurrentMachine.ip_address
    end
  end
end

Version data entries

27 entries across 24 versions & 2 rubygems

Version Path
fog-core-2.3.0 spec/current_machine_spec.rb
fog-core-2.2.4 spec/current_machine_spec.rb
fog-core-2.2.3 spec/current_machine_spec.rb
fog-core-2.2.2 spec/current_machine_spec.rb
fog-core-2.2.1 spec/current_machine_spec.rb
fog-core-2.2.0 spec/current_machine_spec.rb
fog-core-2.1.2 spec/current_machine_spec.rb
fog-core-2.1.1 spec/current_machine_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/spec/current_machine_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-core-1.45.0/spec/current_machine_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-core-2.1.0/spec/current_machine_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-core-1.45.0/spec/current_machine_spec.rb
fog-core-2.1.0 spec/current_machine_spec.rb
fog-core-2.0.0 spec/current_machine_spec.rb
fog-core-1.45.0 spec/current_machine_spec.rb
fog-core-1.44.3 spec/current_machine_spec.rb
fog-core-1.44.2 spec/current_machine_spec.rb
fog-core-1.44.1 spec/current_machine_spec.rb
fog-core-1.44.0 spec/current_machine_spec.rb
fog-core-1.43.0 spec/current_machine_spec.rb