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

parse the list of zones returned

This commit is contained in:
Michael Hale 2011-02-08 22:03:06 -05:00 committed by geemus
parent 8bda3ba52f
commit 0595cd7dfb
3 changed files with 30 additions and 5 deletions

View file

@ -0,0 +1,23 @@
module Fog
module Parsers
module Dynect
module DNS
class Zone < Fog::Parsers::Base
def reset
@response = {"zones" => []}
end
def end_element(name)
case name
when 'ZoneURI'
@response['zones'] << @value.match(/\/REST\/Zone\/(.+)\//)[1]
end
end
end
end
end
end
end

View file

@ -3,10 +3,11 @@ module Fog
class DNS
class Real
# require 'fog/dns/parsers/dynect/session'
require 'fog/dns/parsers/dynect/zone'
def zone
request(
:parser => Fog::Parsers::Dynect::DNS::Zone.new,
:expects => 200,
:method => "GET",
:path => "Zone",
@ -20,6 +21,7 @@ module Fog
response = Excon::Response.new
response.status = 200
response.body = {
"zones" => ["example.com"]
}
response
end

View file

@ -1,15 +1,15 @@
Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
tests( 'success') do
test "start api session" do
tests "success" do
tests "start api session" do
response = Dynect[:dns].session
returns(true) { response.body['Auth-Token'] =~ /.+=$/ && true }
returns(true) { response.body['API-Version'] == "2.3.1" }
returns(true) { response.status == 200 }
end
test "list zones" do
tests "list zones" do
response = Dynect[:dns].zone
returns(true) { response.body['zones'].size > 0 }
returns(true) { response.body['zones'].first =~ /\.com/ && true }
returns(true) { response.status == 200 }
end
end