Skip to content

Instantly share code, notes, and snippets.

@mwhagedorn
Created January 9, 2012 21:46
Show Gist options
  • Save mwhagedorn/1585124 to your computer and use it in GitHub Desktop.
Save mwhagedorn/1585124 to your computer and use it in GitHub Desktop.
Relevant fragment of server_spec
context "server#addresses" do
context "and there is a private address key" do
it "returns the ip address" do
@server.should_receive(:addresses).any_number_of_times.and_return({"private"=>[{"version"=>4, "addr"=>"10.0.2.76"}]})
@server.private_ip_address.should == "10.0.2.76"
end
end
context "and there is not a private address key" do
it "server#private_ip_address returns nil" do
#Stricly speaking this scenario cannot occur
@server.should_receive(:addresses).any_number_of_times.and_return({"public"=>[{"version"=>4, "addr"=>"10.0.2.76"}]})
@server.private_ip_address.should == nil
end
end
context "and there is a public address key" do
it "returns the public ip address key" do
@server.should_receive(:addresses).any_number_of_times.and_return({"private"=>[{"version"=>4, "addr"=>"10.0.2.76"}],
"public"=>[{"version"=>4, "addr"=>"15.10.2.76"}]})
@server.public_ip_address.should == "15.10.2.76"
end
end
context "and there is not a public address key" do
it "server#public_ip_address returns nil" do
@server.should_receive(:addresses).any_number_of_times.and_return({"private"=>[{"version"=>4, "addr"=>"10.0.2.76"}]})
@server.public_ip_address.should == nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment