2011-01-10 01:12:48 -05:00
|
|
|
require 'vcloud/spec_helper'
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
if Fog.mocking?
|
|
|
|
describe "Fog::Vcloud::Terremark::Ecloud::InternetService", :type => :mock_tmrk_ecloud_model do
|
|
|
|
subject { @vcloud.vdcs[0].public_ips[0].internet_services[0] }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
describe :class do
|
|
|
|
subject { Fog::Vcloud::Terremark::Ecloud::InternetService }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it { should have_identity :href }
|
2010-11-22 09:15:23 -05:00
|
|
|
it { should have_only_these_attributes [:href, :name, :id, :protocol, :port, :enabled, :description, :public_ip, :timeout, :redirect_url, :monitor, :backup_service_data] }
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "with no uri" do
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
subject { Fog::Vcloud::Terremark::Ecloud::InternetService.new() }
|
|
|
|
it { should have_all_attributes_be_nil }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "as a collection member" do
|
|
|
|
subject { @vcloud.vdcs[0].public_ips[0].internet_services[0].reload; @vcloud.vdcs[0].public_ips[0].internet_services[0] }
|
|
|
|
|
|
|
|
let(:public_ip) {
|
|
|
|
pip = @vcloud.get_public_ip(@vcloud.vdcs[0].public_ips[0].internet_services[0].public_ip[:Href]).body
|
|
|
|
pip.delete_if{ |k,v| [:xmlns, :xmlns_i].include?(k)}
|
|
|
|
pip
|
|
|
|
}
|
|
|
|
let(:composed_public_ip_data) { @vcloud.vdcs[0].public_ips[0].internet_services[0].send(:_compose_ip_data) }
|
|
|
|
let(:composed_service_data) { @vcloud.vdcs[0].public_ips[0].internet_services[0].send(:_compose_service_data) }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::InternetService }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-11-22 10:54:03 -05:00
|
|
|
its(:href) { should == @mock_service.href }
|
|
|
|
its(:identity) { should == @mock_service.href }
|
|
|
|
its(:name) { should == @mock_service.name }
|
|
|
|
its(:id) { should == @mock_service.object_id.to_s }
|
|
|
|
its(:protocol) { should == @mock_service.protocol }
|
|
|
|
its(:port) { should == @mock_service.port.to_s }
|
|
|
|
its(:enabled) { should == @mock_service.enabled.to_s }
|
|
|
|
its(:description) { should == @mock_service.description }
|
|
|
|
its(:public_ip) { should == public_ip }
|
|
|
|
its(:timeout) { should == @mock_service.timeout.to_s }
|
|
|
|
its(:redirect_url) { should == @mock_service.redirect_url }
|
|
|
|
its(:monitor) { should == nil }
|
|
|
|
its(:backup_service_uri) { should be_nil }
|
2010-06-07 12:18:06 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
specify { composed_public_ip_data[:href].should == public_ip[:Href].to_s }
|
|
|
|
specify { composed_public_ip_data[:name].should == public_ip[:Name] }
|
|
|
|
specify { composed_public_ip_data[:id].should == public_ip[:Id] }
|
2010-06-07 12:18:06 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
specify { composed_service_data[:href].should == subject.href.to_s }
|
|
|
|
specify { composed_service_data[:name].should == subject.name }
|
|
|
|
specify { composed_service_data[:id].should == subject.id.to_s }
|
|
|
|
specify { composed_service_data[:protocol].should == subject.protocol }
|
|
|
|
specify { composed_service_data[:port].should == subject.port.to_s }
|
|
|
|
specify { composed_service_data[:enabled].should == subject.enabled.to_s }
|
|
|
|
specify { composed_service_data[:description].should == subject.description }
|
|
|
|
specify { composed_service_data[:timeout].should == subject.timeout.to_s }
|
2010-11-22 09:15:23 -05:00
|
|
|
|
|
|
|
context "with a backup internet service" do
|
|
|
|
before { @mock_service[:backup_service] = @mock_backup_service }
|
|
|
|
|
2010-11-22 10:54:03 -05:00
|
|
|
its(:backup_service_uri) { should == @mock_backup_service.href }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#backup_service_uri=" do
|
|
|
|
specify do
|
|
|
|
expect { subject.backup_service_uri = @mock_backup_service.href }.
|
|
|
|
to change { subject.backup_service_uri }.from(nil).to(@mock_backup_service.href)
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
expect { subject.backup_service_uri = @mock_backup_service.href }.
|
|
|
|
to change { subject.send(:_compose_service_data)[:backup_service_uri] }.from(nil).to(@mock_backup_service.href)
|
|
|
|
end
|
2010-11-22 09:15:23 -05:00
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-05-27 21:27:12 -04:00
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
else
|
2010-05-27 21:27:12 -04:00
|
|
|
end
|