mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add servers shared example group
This commit is contained in:
parent
0d496906e6
commit
c43f899e45
6 changed files with 68 additions and 39 deletions
|
@ -108,7 +108,7 @@ Now we will try again, but with Rackspace
|
|||
|
||||
* Follow {@geemus}[http://twitter.com/geemus] on Twitter.
|
||||
* See upcoming work in the {tracker}[http://www.pivotaltracker.com/projects/54635].
|
||||
* Report bugs in {issues}[http://github.com/geemus/fog/issues]
|
||||
* Report bugs in {issues}[http://github.com/geemus/fog/issues].
|
||||
|
||||
== Supports
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/servers_examples'
|
||||
|
||||
describe 'Fog::AWS::EC2::Servers' do
|
||||
|
||||
subject { @server = @servers.create(:image_id => GENTOO_AMI) }
|
||||
it_should_behave_like "Servers"
|
||||
|
||||
subject { @server = @servers.new(:image_id => GENTOO_AMI) }
|
||||
|
||||
before(:each) do
|
||||
@servers = AWS[:ec2].servers
|
||||
|
@ -10,43 +13,9 @@ describe 'Fog::AWS::EC2::Servers' do
|
|||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.destroy
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#all" do
|
||||
|
||||
it "should include persisted servers" do
|
||||
eventually do
|
||||
@servers.all.map {|server| server.id}.should include(subject.id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#get" do
|
||||
|
||||
it "should return a matching server if one exists" do
|
||||
eventually do
|
||||
get = @servers.get(subject.id)
|
||||
subject.attributes.should == get.attributes
|
||||
end
|
||||
end
|
||||
|
||||
it "should return nil if no matching server exists" do
|
||||
@servers.get('i-00000000').should be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#reload" do
|
||||
|
||||
it "should reset attributes to remote state" do
|
||||
servers = @servers.all
|
||||
reloaded = servers.reload
|
||||
servers.attributes.should == reloaded.attributes
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/server_examples'
|
||||
|
||||
describe 'Fog::AWS::EC2::Server' do
|
||||
describe 'Fog::Rackspace::Servers::Server' do
|
||||
|
||||
it_should_behave_like "Server"
|
||||
|
||||
|
|
22
spec/rackspace/models/servers/servers_spec.rb
Normal file
22
spec/rackspace/models/servers/servers_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/servers_examples'
|
||||
|
||||
describe 'Fog::Rackspace::Servers::Servers' do
|
||||
|
||||
it_should_behave_like "Servers"
|
||||
|
||||
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||
subject { @server = @servers.new(:flavor_id => 1, :image_id => 3, :name => 'name') }
|
||||
|
||||
before(:each) do
|
||||
@servers = Rackspace[:servers].servers
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -40,3 +40,4 @@ shared_examples_for "Server" do
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
37
spec/shared_examples/servers_examples.rb
Normal file
37
spec/shared_examples/servers_examples.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
shared_examples_for "Servers" do
|
||||
|
||||
describe "#all" do
|
||||
|
||||
it "should include persisted servers" do
|
||||
subject.save
|
||||
@servers.all.map {|server| server.id}.should include(subject.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#get" do
|
||||
|
||||
it "should return a matching server if one exists" do
|
||||
subject.save
|
||||
get = @servers.get(subject.id)
|
||||
subject.attributes.should == get.attributes
|
||||
end
|
||||
|
||||
it "should return nil if no matching server exists" do
|
||||
@servers.get('0').should be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#reload" do
|
||||
|
||||
it "should reset attributes to remote state" do
|
||||
subject.save
|
||||
servers = @servers.all
|
||||
reloaded = servers.reload
|
||||
servers.attributes.should == reloaded.attributes
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue