Sha256: 01e89f8af8d85356144e7291ce9cc934d3c06ed05c8dcf05ca789769223ad8cb

Contents?: true

Size: 832 Bytes

Versions: 19

Compression:

Stored size: 832 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
      Excon.stub({ :method => :get, :path => "/" }, { :body => "" })

      (1..10).map do
        Thread.new { Fog::CurrentMachine.ip_address }
      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

19 entries across 19 versions & 2 rubygems

Version Path
fog-core-1.36.0 spec/current_machine_spec.rb
fog-core-1.35.0 spec/current_machine_spec.rb
fog-core-1.34.0 spec/current_machine_spec.rb
fog-core-1.33.0 spec/current_machine_spec.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-core-1.32.1/spec/current_machine_spec.rb
fog-core-1.32.1 spec/current_machine_spec.rb
fog-core-1.32.0 spec/current_machine_spec.rb
fog-core-1.31.1 spec/current_machine_spec.rb
fog-core-1.31.0 spec/current_machine_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-core-1.30.0/spec/current_machine_spec.rb
fog-core-1.30.0 spec/current_machine_spec.rb
fog-core-1.29.0 spec/current_machine_spec.rb
fog-core-1.28.0 spec/current_machine_spec.rb
fog-core-1.27.4 spec/current_machine_spec.rb
fog-core-1.27.3 spec/current_machine_spec.rb
fog-core-1.27.2 spec/current_machine_spec.rb
fog-core-1.27.1 spec/current_machine_spec.rb
fog-core-1.27.0 spec/current_machine_spec.rb
fog-core-1.25.0 spec/current_machine_spec.rb