1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

spec and related fixes

This commit is contained in:
Wesley Beary 2009-11-03 21:46:27 -08:00
parent d6e857e52d
commit 9ecb6f8a86
13 changed files with 13 additions and 25 deletions

View file

@ -11,7 +11,7 @@ module Fog
model Fog::Rackspace::Servers::Server model Fog::Rackspace::Servers::Server
def all def all
data = connection.list_servers_details.body data = connection.list_servers_detail.body
servers = Fog::Rackspace::Servers::Servers.new({ servers = Fog::Rackspace::Servers::Servers.new({
:connection => connection :connection => connection
}) })

View file

@ -14,7 +14,7 @@ unless Fog.mocking?
response = storage_request( response = storage_request(
:body => data[:body], :body => data[:body],
:expects => 201, :expects => 201,
:headers => data[:headers,] :headers => data[:headers],
:method => 'PUT', :method => 'PUT',
:path => "#{CGI.escape(container)}/#{CGI.escape(object)}" :path => "#{CGI.escape(container)}/#{CGI.escape(object)}"
) )

View file

@ -13,12 +13,9 @@ unless Fog.mocking?
# ==== Returns # ==== Returns
# * response<~Excon::Response>: # * response<~Excon::Response>:
# * 'image'<~Hash>: # * 'image'<~Hash>:
# * 'created'<~Time> - Creation time
# * 'id'<~Integer> - Id of image # * 'id'<~Integer> - Id of image
# * 'name'<~String> - Name of image # * 'name'<~String> - Name of image
# * 'progress'<~String> - Percentage of completion
# * 'serverId'<~Integer> - Id of server # * 'serverId'<~Integer> - Id of server
# * 'status'<~String> - Current status
def create_image(server_id, options = {}) def create_image(server_id, options = {})
data = { data = {
'image' => { 'image' => {

View file

@ -15,7 +15,7 @@ unless Fog.mocking?
# * 'addresses'<~Array>: # * 'addresses'<~Array>:
# * 'public'<~Array> - Public ip addresses # * 'public'<~Array> - Public ip addresses
# * 'private'<~Array> - Private ip addresses # * 'private'<~Array> - Private ip addresses
def list_addresses def list_addresses(server_id)
request( request(
:expects => [200, 203], :expects => [200, 203],
:method => 'GET', :method => 'GET',
@ -33,7 +33,7 @@ else
module Rackspace module Rackspace
class Servers class Servers
def list_addresses def list_addresses(server_id)
end end
end end

View file

@ -13,7 +13,7 @@ unless Fog.mocking?
# * 'name'<~String> - Name of the flavor # * 'name'<~String> - Name of the flavor
def list_flavors def list_flavors
request( request(
:expects => 200, :expects => [200, 203],
:method => 'GET', :method => 'GET',
:path => 'flavors.json' :path => 'flavors.json'
) )

View file

@ -48,12 +48,6 @@ module Fog
}) })
unless response.body.empty? unless response.body.empty?
response.body = JSON.parse(response.body) response.body = JSON.parse(response.body)
if response.body['created']
response.body['created'] = Time.parse(response.body['created'])
end
if response.body['updated']
response.body['updated'] = Time.parse(response.body['updated'])
end
end end
response response
end end

View file

@ -16,13 +16,10 @@ describe 'Rackspace::Servers.create_image' do
end end
it "should return proper attributes" do it "should return proper attributes" do
actual = servers.create_image(@server_id)['image'] actual = servers.create_image(@server_id).body['image']
actual['created'].should be_a(Time) @image_id = actual['id']
actual['id'].should be_an(Integer) actual['id'].should be_an(Integer)
actual['name'].should be_a(String)
actual['progress'].should be_an(Integer)
actual['serverId'].should be_an(Integer) actual['serverId'].should be_an(Integer)
actual['status'].should be_a(String)
end end
end end

View file

@ -9,7 +9,7 @@ describe 'Rackspace::Servers.delete_server' do
end end
it "should return proper attributes" do it "should return proper attributes" do
eventually(128) do eventually do
servers.delete_server(@server_id) servers.delete_server(@server_id)
end end
end end

View file

@ -15,7 +15,7 @@ describe 'Rackspace::Servers.list_addresses' do
end end
it "should return proper attributes" do it "should return proper attributes" do
actual = servers.list_addresses(@server_id) actual = servers.list_addresses(@server_id).body
actual['addresses'].should be_a(Hash) actual['addresses'].should be_a(Hash)
actual['addresses']['private'].should be_an(Array) actual['addresses']['private'].should be_an(Array)
actual['addresses']['public'].should be_an(Array) actual['addresses']['public'].should be_an(Array)

View file

@ -4,7 +4,7 @@ describe 'Rackspace::Servers.list_flavors_detail' do
describe 'success' do describe 'success' do
it "should return proper attributes" do it "should return proper attributes" do
actual = servers.list_flavors_detail actual = servers.list_flavors_detail.body
actual['flavors'].should be_an(Array) actual['flavors'].should be_an(Array)
flavor = actual['flavors'].first flavor = actual['flavors'].first
flavor['disk'].should be_an(Integer) flavor['disk'].should be_an(Integer)

View file

@ -4,7 +4,7 @@ describe 'Rackspace::Servers.list_flavors' do
describe 'success' do describe 'success' do
it "should return proper attributes" do it "should return proper attributes" do
actual = servers.list_flavors actual = servers.list_flavors.body
actual['flavors'].should be_an(Array) actual['flavors'].should be_an(Array)
flavor = actual['flavors'].first flavor = actual['flavors'].first
flavor['id'].should be_an(Integer) flavor['id'].should be_an(Integer)

View file

@ -4,7 +4,7 @@ describe 'Rackspace::Servers.list_images' do
describe 'success' do describe 'success' do
it "should return proper attributes" do it "should return proper attributes" do
actual = servers.list_images actual = servers.list_images.body
actual['images'].should be_an(Array) actual['images'].should be_an(Array)
image = actual['images'].first image = actual['images'].first
image['id'].should be_an(Integer) image['id'].should be_an(Integer)