1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/spec/core/current_machine_spec.rb
Pan Thomakos e1f625f9f2 Added Fog::CurrentMachine#ip_address.
This function allows you to get the ip address of the current machine. I
found this useful because I wanted to add my personal or production
machine to a specific RDS security group. The call is quite simple and
connects to amazon's checkip website. The class is threadsafe and I have
included specs with it as well. I have also added the
Fog::AWS::RDS::SecurityGroup#authorize_me function to make adding the
current machine to a given RDS security group very easy.
2011-08-17 14:35:03 -07:00

22 lines
600 B
Ruby

require 'spec_helper'
require 'fog/core/current_machine'
describe Fog::CurrentMachine do
context '#ip_address' do
before(:each){ described_class.ip_address = nil }
it 'should be threadsafe' do
Net::HTTP.should_receive(:get_response).once{ Struct.new(:body).new('') }
(1..10).map {
Thread.new { described_class.ip_address }
}.each{ |t| t.join }
end
it 'should remove trailing endline characters' do
Net::HTTP.stub(:get_response){ Struct.new(:body).new("192.168.0.1\n") }
described_class.ip_address.should == '192.168.0.1'
end
end
end