vcloud-walker 3.2.2 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,169 @@
1
+ require 'spec_helper'
2
+
3
+ class CommandRun
4
+ attr_accessor :stdout, :stderr, :exitstatus
5
+
6
+ def initialize(args)
7
+ out = StringIO.new
8
+ err = StringIO.new
9
+
10
+ $stdout = out
11
+ $stderr = err
12
+
13
+ begin
14
+ Vcloud::Walker::Cli.new(args).run
15
+ @exitstatus = 0
16
+ rescue SystemExit => e
17
+ # Capture exit(n) value.
18
+ @exitstatus = e.status
19
+ end
20
+
21
+ @stdout = out.string.strip
22
+ @stderr = err.string.strip
23
+
24
+ $stdout = STDOUT
25
+ $stderr = STDERR
26
+ end
27
+ end
28
+
29
+ describe Vcloud::Walker::Cli do
30
+ subject { CommandRun.new(args) }
31
+ let(:mock_output) do
32
+ [{
33
+ :name => 'gruffalo',
34
+ :desc => { :eyes => 'orange', :tongue => 'black' },
35
+ },{
36
+ :name => 'mouse',
37
+ :desc => { :tail => 'scaly', :whiskers => 'wire' },
38
+ }]
39
+ end
40
+
41
+ describe "normal usage" do
42
+ context "when given resource_type" do
43
+ let(:args) { %w{things} }
44
+
45
+ it "should pass resource_type and exit normally" do
46
+ expect(Vcloud::Walker).to receive(:walk).with('things').and_return(mock_output)
47
+ expect(subject.exitstatus).to eq(0)
48
+ end
49
+ end
50
+
51
+ context "when asked to display version" do
52
+ let(:args) { %w{--version} }
53
+
54
+ it "should not call Walker" do
55
+ expect(Vcloud::Walker).not_to receive(:walk)
56
+ end
57
+
58
+ it "should print version and exit normally" do
59
+ expect(subject.stdout).to eq(Vcloud::Walker::VERSION)
60
+ expect(subject.exitstatus).to eq(0)
61
+ end
62
+ end
63
+
64
+ context "when asked to display help" do
65
+ let(:args) { %w{--help} }
66
+
67
+ it "should not call Walker" do
68
+ expect(Vcloud::Walker).not_to receive(:walk)
69
+ end
70
+
71
+ it "should print usage and exit normally" do
72
+ expect(subject.stderr).to match(/\AUsage: \S+ \[options\] resource_type\n/)
73
+ expect(subject.exitstatus).to eq(0)
74
+ end
75
+ end
76
+ end
77
+
78
+ describe "output formats" do
79
+ context "when no format is specified" do
80
+ let(:args) { %w{things} }
81
+ let(:expected_stdout) { <<EOS
82
+ [
83
+ {
84
+ "name": "gruffalo",
85
+ "desc": {
86
+ "eyes": "orange",
87
+ "tongue": "black"
88
+ }
89
+ },
90
+ {
91
+ "name": "mouse",
92
+ "desc": {
93
+ "tail": "scaly",
94
+ "whiskers": "wire"
95
+ }
96
+ }
97
+ ]
98
+ EOS
99
+ }
100
+
101
+ it "should output in JSON with no trailing newline" do
102
+ expect(Vcloud::Walker).to receive(:walk).with('things').and_return(mock_output)
103
+ expect(subject.stdout).to eq(expected_stdout.chomp)
104
+ end
105
+ end
106
+
107
+ context "when given --yaml" do
108
+ let(:args) { %w{--yaml things} }
109
+ let(:expected_stdout) { <<EOS
110
+ ---
111
+ - :name: gruffalo
112
+ :desc:
113
+ :eyes: orange
114
+ :tongue: black
115
+ - :name: mouse
116
+ :desc:
117
+ :tail: scaly
118
+ :whiskers: wire
119
+ EOS
120
+ }
121
+
122
+ it "should output in YAML with no trailing newline" do
123
+ expect(Vcloud::Walker).to receive(:walk).with('things').and_return(mock_output)
124
+ expect(subject.stdout).to eq(expected_stdout.chomp)
125
+ end
126
+ end
127
+ end
128
+
129
+ describe "incorrect usage" do
130
+ shared_examples "print usage and exit abnormally" do |error|
131
+ it "should not call Walker" do
132
+ expect(Vcloud::Walker).not_to receive(:walk)
133
+ end
134
+
135
+ it "should print error message and usage" do
136
+ expect(subject.stderr).to match(/\A\S+: #{error}\nUsage: \S+/)
137
+ end
138
+
139
+ it "should exit abnormally for incorrect usage" do
140
+ expect(subject.exitstatus).to eq(2)
141
+ end
142
+ end
143
+
144
+ context "when given more than resource_type argument" do
145
+ let(:args) { %w{type_one type_two} }
146
+
147
+ it_behaves_like "print usage and exit abnormally", "must supply resource_type"
148
+ end
149
+
150
+ context "when given an unrecognised argument" do
151
+ let(:args) { %w{--this-is-garbage} }
152
+
153
+ it_behaves_like "print usage and exit abnormally", "invalid option: --this-is-garbage"
154
+ end
155
+ end
156
+
157
+ describe "error handling" do
158
+ context "when underlying code raises an exception" do
159
+ let(:args) { %w{things} }
160
+
161
+ it "should print error without backtrace and exit abnormally" do
162
+ expect(Vcloud::Walker).to receive(:walk).
163
+ with('things').and_raise("something went horribly wrong")
164
+ expect(subject.stderr).to eq("something went horribly wrong")
165
+ expect(subject.exitstatus).to eq(1)
166
+ end
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+ require 'rspec/mocks'
3
+
4
+ describe Vcloud::Walker::Resource::Catalogs do
5
+
6
+ it "should summarize catalogs" do
7
+ set_login_credential
8
+ mock_fog_item = double(
9
+ :catalog_item,
10
+ :id => "12345",
11
+ :name => 'ubuntu 11.04',
12
+ :description => 'image for ubuntu 11.04',
13
+ :vapp_template_id => 'vapp-template-01'
14
+ )
15
+ mock_fog_catalog = double(
16
+ :catalog,
17
+ :id => 'catalog_id_1',
18
+ :name => 'Default catalog',
19
+ :description => 'default catalog for infrastructure',
20
+ :catalog_items => double(:catalog_items, :all => [mock_fog_item])
21
+ )
22
+ catalog_summary = Vcloud::Walker::Resource::Catalogs.new([mock_fog_catalog]).to_summary
23
+ expect(catalog_summary.count).to eq(1)
24
+ expect(catalog_summary.first[:items].count).to eq(1)
25
+ expect(catalog_summary).to eq([{
26
+ :id => "catalog_id_1",
27
+ :name => "Default catalog",
28
+ :description => "default catalog for infrastructure",
29
+ :items => [{
30
+ :id => "12345",
31
+ :name => "ubuntu 11.04",
32
+ :description => "image for ubuntu 11.04",
33
+ :vapp_template_id => "vapp-template-01"
34
+ }],
35
+ }])
36
+ end
37
+
38
+ end
@@ -44,23 +44,32 @@ module Vcloud
44
44
  describe Vcloud::Walker::Resource::Entity do
45
45
  it 'should be able to nested collections inside entities' do
46
46
  collection = [double(:name => 'collection 1'), double(:name => 'collection 2')]
47
- test_class = Vcloud::Walker::Resource::TestClass.new(double(:description => 'test class desc', :collection => collection))
48
-
49
- test_class.to_summary.should == {:test_data => [{:name => "collection 1"}, {:name => "collection 2"}], :description => "test class desc"}
47
+ test_class = Vcloud::Walker::Resource::TestClass.new(
48
+ double(:description => 'test class desc', :collection => collection)
49
+ )
50
+ expect(test_class.to_summary).to eq({
51
+ :test_data => [
52
+ {:name => "collection 1"}, {:name => "collection 2"}
53
+ ],
54
+ :description => "test class desc"
55
+ })
50
56
  end
51
57
 
52
58
  it 'should summaries a class as a hash and remove @ from the symbol names' do
53
59
  collection = [double(:name => 'collection 1'), double(:name => 'collection 2')]
54
- test_class = Vcloud::Walker::Resource::TestClass.new(double(:description => 'test class desc', :collection => collection))
55
- test_class.instance_variables.should eq([:@test_data, :@description])
60
+ test_class = Vcloud::Walker::Resource::TestClass.new(
61
+ double(:description => 'test class desc', :collection => collection)
62
+ )
63
+ expect(test_class.instance_variables).to eq([:@test_data, :@description])
56
64
  test_summary = test_class.to_summary
57
- test_summary.keys.should eq([:test_data, :description])
65
+ expect(test_summary.keys).to eq([:test_data, :description])
58
66
  end
59
67
 
60
68
  it 'should be able to nest entity inside entity' do
61
- nested_entities = Vcloud::Walker::Resource::TestNestedEntity.new(double(:data, :name => 'Data 1'))
69
+ nested_entities = Vcloud::Walker::Resource::TestNestedEntity.new(
70
+ double(:data, :name => 'Data 1')
71
+ )
62
72
  expect(nested_entities.to_summary).to eq({:test_data=>{:name=>"Data 1"}})
63
-
64
73
  end
65
74
 
66
75
  end
@@ -10,43 +10,33 @@ describe Vcloud::Walker::Resource::Networks do
10
10
  end
11
11
 
12
12
  it "should walk all networks within given org" do
13
-
14
13
  mock_fog_network = mock_fog_network_object
15
-
16
14
  networks = Vcloud::Walker::Resource::Networks.new([mock_fog_network, mock_fog_network])
17
-
18
- networks.count.should == 2
15
+ expect(networks.count).to eq(2)
19
16
  end
20
17
 
21
-
22
18
  it "should be happy with one network" do
23
-
24
19
  mock_fog_network = mock_fog_network_object
25
-
26
20
  networks = Vcloud::Walker::Resource::Networks.new([mock_fog_network])
27
-
28
- networks.count.should == 1
21
+ expect(networks.count).to eq(1)
29
22
  end
30
23
 
31
24
  it "should handle having no networks" do
32
25
  networks = Vcloud::Walker::Resource::Networks.new([])
33
-
34
- networks.count.should == 0
26
+ expect(networks.count).to eq(0)
35
27
  end
36
28
 
37
-
38
29
  it "should map parameters of a network to the local entity" do
39
30
  mock_fog_network = mock_fog_network_object
40
31
  expect(mock_fog_network).to receive(:dns1).and_return('sausage')
41
32
 
42
33
  networks = Vcloud::Walker::Resource::Networks.new([mock_fog_network])
43
34
 
44
- networks.count.should == 1
45
- networks.first.id.should == :network_id_1
46
- networks.first.name.should == :name
47
- networks.first.dns_suffix == :dns_suffix
48
- networks.first.dns1 == 'sausage'
49
-
35
+ expect(networks.count).to eq(1)
36
+ expect(networks.first.id).to eq(:network_id_1)
37
+ expect(networks.first.name).to eq(:name)
38
+ expect(networks.first.dns_suffix).to eq(:dns_suffix)
39
+ expect(networks.first.dns1).to eq('sausage')
50
40
  end
51
41
 
52
42
  end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vcloud::Walker::Resource::Organization do
4
+
5
+ it "should retrieve networks" do
6
+ fog_networks = double(:fog_networks)
7
+ expect(Vcloud::Walker::FogInterface).to receive(:get_networks).and_return(fog_networks)
8
+ expect(Vcloud::Walker::Resource::Networks).to receive(:new).with(fog_networks).
9
+ and_return(double(:walker_networks, :to_summary => [:network => "Network 1"]))
10
+ expect(Vcloud::Walker::Resource::Organization.networks).to eq([:network => "Network 1"])
11
+ end
12
+
13
+ it "should retrieve catalogs" do
14
+ fog_catalogs = double(:fog_catalogs)
15
+ expect(Vcloud::Walker::FogInterface).to receive(:get_catalogs).and_return(fog_catalogs)
16
+ expect(Vcloud::Walker::Resource::Catalogs).to receive(:new).with(fog_catalogs).
17
+ and_return(double(:walker_catalogs, :to_summary => [:catalog => "Catalog 1"]))
18
+ expect(Vcloud::Walker::Resource::Organization.catalogs).to eq([:catalog => "Catalog 1"])
19
+ end
20
+
21
+ it "should retrieve vdcs" do
22
+ fog_vdcs = double(:fog_vdcs)
23
+ expect(Vcloud::Walker::FogInterface).to receive(:get_vdcs).and_return(fog_vdcs)
24
+ expect(Vcloud::Walker::Resource::Vdcs).to receive(:new).with(fog_vdcs).
25
+ and_return(double(:walker_vdcs, :to_summary => [:vdc => "VDC 1"]))
26
+ expect(Vcloud::Walker::Resource::Organization.vdcs).to eq([:vdc => "VDC 1"])
27
+ end
28
+
29
+ it "should retrieve edgegateways" do
30
+ fog_edgegateways = [{
31
+ :id => 'urn:vcloud:gateway:1',
32
+ :href => 'host/1',
33
+ :name => 'Gateway 1',
34
+ :Configuration => { :EdgeGatewayServiceConfiguration => {}}
35
+ }]
36
+ expect(Vcloud::Walker::FogInterface).to receive(:get_edge_gateways).
37
+ and_return(fog_edgegateways)
38
+
39
+ expect(Vcloud::Walker::Resource::Organization.edgegateways).to eq([{
40
+ :id => '1',
41
+ :name => 'Gateway 1',
42
+ :href => 'host/1',
43
+ :Configuration => { :EdgeGatewayServiceConfiguration => {} },
44
+ }])
45
+ end
46
+
47
+ it "should retrive entire organization" do
48
+ expect(Vcloud::Walker::Resource::Organization).to receive(:edgegateways).
49
+ and_return([:edgegateway => 'Gateway 1'])
50
+ expect(Vcloud::Walker::Resource::Organization).to receive(:vdcs).
51
+ and_return([:vdc => "VDC 1"])
52
+ expect(Vcloud::Walker::Resource::Organization).to receive(:catalogs).
53
+ and_return([:catalog => "Catalog 1"])
54
+ expect(Vcloud::Walker::Resource::Organization).to receive(:networks).
55
+ and_return([:network => "Network 1"])
56
+
57
+ expect(Vcloud::Walker::Resource::Organization.organization).to eq({
58
+ :vdcs => [{ :vdc => "VDC 1" }],
59
+ :networks => [{ :network => "Network 1" }],
60
+ :catalogs => [{ :catalog => "Catalog 1" }],
61
+ :edgegateways => [{ :edgegateway => "Gateway 1" }]
62
+ })
63
+ end
64
+
65
+ end
66
+
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vcloud::Walker::Resource::VApp do
4
+
5
+ context 'populate summary vapp model' do
6
+ before(:each) do
7
+ fog_vapp = Fog::ServiceLayerStub.vapp_body
8
+ @metadata = {:name => 'web-app-1', :shutdown => true}
9
+ expect(Vcloud::Core::Vapp).to receive(:get_metadata).with("vapp-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee").and_return(@metadata)
10
+ expect(Vcloud::Walker::Resource::Vms).to receive(:new).with(fog_vapp[:Children][:Vm])
11
+
12
+ @vapp_summary = Vcloud::Walker::Resource::VApp.new(fog_vapp)
13
+ end
14
+
15
+ it 'should report id from the href' do
16
+ expect(@vapp_summary.id).to eq('vapp-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee')
17
+ end
18
+
19
+ it "should report metadata" do
20
+ expect(@vapp_summary.metadata.count).to eq(2)
21
+ expect(@vapp_summary.metadata).to eq(@metadata)
22
+ end
23
+ end
24
+
25
+ context 'malformed vApp with no networks attached' do
26
+ before(:each) {
27
+ allow(Vcloud::Core::Vapp).to receive(:get_metadata)
28
+ allow(Vcloud::Walker::Resource::Vms).to receive(:new)
29
+ }
30
+
31
+ describe "network_config" do
32
+ shared_examples "network_config" do
33
+ it 'should report an empty network_config without any errors' do
34
+ vapp = Vcloud::Walker::Resource::VApp.new(fog_vapp)
35
+ expect(vapp.network_config).to eq([])
36
+ end
37
+ end
38
+
39
+ context 'missing vapp[:NetworkConfigSection]' do
40
+ let(:fog_vapp) {
41
+ v = Fog::ServiceLayerStub.vapp_body
42
+ v.delete(:NetworkConfigSection)
43
+ v
44
+ }
45
+
46
+ include_examples "network_config"
47
+ end
48
+
49
+ context 'missing vapp[:NetworkConfigSection][:NetworkConfig]' do
50
+ let(:fog_vapp) {
51
+ v = Fog::ServiceLayerStub.vapp_body
52
+ v[:NetworkConfigSection].delete(:NetworkConfig)
53
+ v
54
+ }
55
+
56
+ include_examples "network_config"
57
+ end
58
+ end
59
+
60
+ describe "network_section" do
61
+ shared_examples "network_section" do
62
+ it 'should report an empty network_section without any errors' do
63
+ vapp = Vcloud::Walker::Resource::VApp.new(fog_vapp)
64
+ expect(vapp.network_section).to eq({})
65
+ end
66
+ end
67
+
68
+ context 'missing vapp[:"ovf:NetworkSection"]' do
69
+ let(:fog_vapp) {
70
+ v = Fog::ServiceLayerStub.vapp_body
71
+ v.delete(:"ovf:NetworkSection")
72
+ v
73
+ }
74
+
75
+ include_examples "network_section"
76
+ end
77
+
78
+ context 'missing vapp[:"ovf:NetworkSection"][:"ovf:Network"]' do
79
+ let(:fog_vapp) {
80
+ v = Fog::ServiceLayerStub.vapp_body
81
+ v[:"ovf:NetworkSection"].delete(:"ovf:Network")
82
+ v
83
+ }
84
+
85
+ include_examples "network_section"
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'fog'
3
+
4
+ describe Vcloud::Walker::Resource::Vdcs do
5
+ let(:api_session) { double(:fog_session) }
6
+
7
+ context 'vdcs' do
8
+
9
+ it "should summarize vdcs" do
10
+ expect(Fog::Compute::VcloudDirector).to receive(:new).with(any_args()).and_return(api_session)
11
+ mock_fog_vdcs = StubCollectionBuilders.vdcs(StubVdc.new.vapps([mock_vapp]).build)
12
+ expect(api_session).to receive(:get_vapp).with(1).and_return(Fog::ServiceLayerStub.mock_vapp)
13
+ expect(Vcloud::Core::Vm).to receive(:get_metadata).with("vm-d19d84a5-c950-4497-a638-23eccc4226a5").and_return({})
14
+ expect(Vcloud::Core::Vapp).to receive(:get_metadata).with("vapp-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee").and_return({})
15
+
16
+ vdcs_summary = Vcloud::Walker::Resource::Vdcs.new(mock_fog_vdcs).to_summary
17
+
18
+ vdc_summary = vdcs_summary.first
19
+ expect(vdc_summary[:vapps].count).to eq(1)
20
+ expect(vdc_summary[:vapps].first[:vms].count).to eq(1)
21
+ end
22
+
23
+ private
24
+
25
+ def mock_vapp
26
+ double(:vapp, :id => 1)
27
+ end
28
+
29
+ end
30
+ end
@@ -7,7 +7,7 @@ describe Vcloud::Walker::Resource::Vm do
7
7
  fog_vm = assemble_sample_vm_data Fog::ServiceLayerStub.vcloud_director_five_one_ids
8
8
 
9
9
  @metadata = {:name => 'web-app-1', :shutdown => true}
10
- Vcloud::Core::Vm.should_receive(:get_metadata)
10
+ expect(Vcloud::Core::Vm).to receive(:get_metadata)
11
11
  .with("vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
12
12
  .and_return(@metadata)
13
13
 
@@ -15,65 +15,65 @@ describe Vcloud::Walker::Resource::Vm do
15
15
  end
16
16
 
17
17
  it 'should report id from the href' do
18
- @vm_summary.id.should == 'vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
18
+ expect(@vm_summary.id).to eq('vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee')
19
19
  end
20
20
 
21
21
  it "should populate vmware tool version" do
22
- @vm_summary.vmware_tools.should == {:version => "2147483647"}
22
+ expect(@vm_summary.vmware_tools).to eq({:version => "2147483647"})
23
23
  end
24
24
 
25
25
  it "should populate virtual system type" do
26
- @vm_summary.virtual_system_type.should == "vmx-08"
26
+ expect(@vm_summary.virtual_system_type).to eq("vmx-08")
27
27
  end
28
28
 
29
29
  it "should populate operating system" do
30
- @vm_summary.operating_system.should == 'Ubuntu Linux (64-bit)'
30
+ expect(@vm_summary.operating_system).to eq('Ubuntu Linux (64-bit)')
31
31
  end
32
32
 
33
33
  it "should populate network connection interface" do
34
- @vm_summary.primary_network_connection_index.should == '0'
35
- @vm_summary.network_connections.count.should == 1
36
- @vm_summary.network_connections.first[:network].should == 'Default'
34
+ expect(@vm_summary.primary_network_connection_index).to eq('0')
35
+ expect(@vm_summary.network_connections.count).to eq(1)
36
+ expect(@vm_summary.network_connections.first[:network]).to eq('Default')
37
37
  end
38
38
 
39
39
  it "should populate storage profile" do
40
- @vm_summary.storage_profile[:name].should == "TEST-STORAGE-PROFILE"
40
+ expect(@vm_summary.storage_profile[:name]).to eq("TEST-STORAGE-PROFILE")
41
41
  end
42
42
 
43
43
  it "should populate storage profile id" do
44
- @vm_summary.storage_profile[:id].should == "00000000-aaaa-bbbb-aaaa-000000000000"
44
+ expect(@vm_summary.storage_profile[:id]).to eq("00000000-aaaa-bbbb-aaaa-000000000000")
45
45
  end
46
46
 
47
47
  context "hardware resource info" do
48
48
 
49
49
  it "report cpu" do
50
- @vm_summary.cpu.should == '2 virtual CPU(s)'
50
+ expect(@vm_summary.cpu).to eq('2 virtual CPU(s)')
51
51
  end
52
52
 
53
53
  it "report memory" do
54
- @vm_summary.memory.should == '4096 MB of memory'
54
+ expect(@vm_summary.memory).to eq('4096 MB of memory')
55
55
  end
56
56
 
57
57
  it "report disk info" do
58
- @vm_summary.disks.count.should == 2
59
- @vm_summary.disks.first.should == {:name => "Hard disk 1", :size => 11265}
60
- @vm_summary.disks.last.should == {:name => "Hard disk 2", :size => 307200}
58
+ expect(@vm_summary.disks.count).to eq(2)
59
+ expect(@vm_summary.disks.first).to eq({:name => "Hard disk 1", :size => 11265})
60
+ expect(@vm_summary.disks.last).to eq({:name => "Hard disk 2", :size => 307200})
61
61
  end
62
62
 
63
63
  it "report network card info" do
64
- @vm_summary.network_cards.count.should == 1
65
- @vm_summary.network_cards[0].should == {
64
+ expect(@vm_summary.network_cards.count).to eq(1)
65
+ expect(@vm_summary.network_cards[0]).to eq({
66
66
  :mac_address => '00:50:56:00:00:01',
67
67
  :name => "Network adapter 0",
68
68
  :type => "E1000"
69
- }
69
+ })
70
70
  end
71
71
 
72
72
  end
73
73
 
74
74
  it "report metadata" do
75
- @vm_summary.metadata.count.should == 2
76
- @vm_summary.metadata.should == @metadata
75
+ expect(@vm_summary.metadata.count).to eq(2)
76
+ expect(@vm_summary.metadata).to eq(@metadata)
77
77
  end
78
78
 
79
79
  end
@@ -84,7 +84,7 @@ describe Vcloud::Walker::Resource::Vm do
84
84
  fog_vm = assemble_sample_vm_data Fog::ServiceLayerStub.vcloud_director_5_5_with_v5_1_api_ids
85
85
 
86
86
  @metadata = {:name => 'web-app-1', :shutdown => true}
87
- Vcloud::Core::Vm.should_receive(:get_metadata)
87
+ expect(Vcloud::Core::Vm).to receive(:get_metadata)
88
88
  .with("vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
89
89
  .and_return(@metadata)
90
90
 
@@ -92,9 +92,9 @@ describe Vcloud::Walker::Resource::Vm do
92
92
  end
93
93
 
94
94
  it "report disk info for 5.1 api on 5.5" do
95
- @vm_summary.disks.count.should == 2
96
- @vm_summary.disks.first.should == {:name => "Hard disk 1", :size => 11265}
97
- @vm_summary.disks.last.should == {:name => "Hard disk 2", :size => 307200}
95
+ expect(@vm_summary.disks.count).to eq(2)
96
+ expect(@vm_summary.disks.first).to eq({:name => "Hard disk 1", :size => 11265})
97
+ expect(@vm_summary.disks.last).to eq({:name => "Hard disk 2", :size => 307200})
98
98
  end
99
99
 
100
100
  end
@@ -9,48 +9,46 @@ module Vcloud
9
9
 
10
10
  it "should correctly pass catalogs" do
11
11
  test_array = [ "name" => "catalogs" ]
12
- Vcloud::Walker::Resource::Organization.stub(:catalogs).and_return(test_array)
12
+ allow(Vcloud::Walker::Resource::Organization).to receive(:catalogs).and_return(test_array)
13
13
  result_array = Vcloud::Walker.walk("catalogs")
14
- result_array.should include("name" => "catalogs")
14
+ expect(result_array).to include("name" => "catalogs")
15
15
  end
16
16
 
17
17
  it "should correctly pass vdcs" do
18
18
  test_array = [ "name" => "vdcs" ]
19
- Vcloud::Walker::Resource::Organization.stub(:vdcs).and_return(test_array)
19
+ allow(Vcloud::Walker::Resource::Organization).to receive(:vdcs).and_return(test_array)
20
20
  result_array = Vcloud::Walker.walk("vdcs")
21
- result_array.should include("name" => "vdcs")
21
+ expect(result_array).to include("name" => "vdcs")
22
22
  end
23
23
 
24
24
  it "should correctly pass networks" do
25
25
  test_array = [ "name" => "networks" ]
26
- Vcloud::Walker::Resource::Organization.stub(:networks).and_return(test_array)
26
+ allow(Vcloud::Walker::Resource::Organization).to receive(:networks).and_return(test_array)
27
27
  result_array = Vcloud::Walker.walk("networks")
28
- result_array.should include("name" => "networks")
28
+ expect(result_array).to include("name" => "networks")
29
29
  end
30
30
 
31
31
  it "should correctly pass edgegateways" do
32
32
  test_array = [ "name" => "edgegateways" ]
33
- Vcloud::Walker::Resource::Organization.stub(:edgegateways).and_return(test_array)
33
+ allow(Vcloud::Walker::Resource::Organization).to receive(:edgegateways).and_return(test_array)
34
34
  result_array = Vcloud::Walker.walk("edgegateways")
35
- result_array.should include("name" => "edgegateways")
35
+ expect(result_array).to include("name" => "edgegateways")
36
36
  end
37
37
 
38
38
  it "should correctly pass organization" do
39
39
  test_array = [ "name" => "organization" ]
40
- Vcloud::Walker::Resource::Organization.stub(:organization).and_return(test_array)
40
+ allow(Vcloud::Walker::Resource::Organization).to receive(:organization).and_return(test_array)
41
41
  result_array = Vcloud::Walker.walk("organization")
42
- result_array.should include("name" => "organization")
42
+ expect(result_array).to include("name" => "organization")
43
43
  end
44
44
 
45
45
  end
46
46
 
47
47
  context "invalid resources" do
48
-
49
48
  it "should reject input that is not a valid resouce" do
50
- result_array = Vcloud::Walker.walk("invalid")
51
- result_array.should be_nil
49
+ expect{ Vcloud::Walker.walk("invalid") }.
50
+ to raise_error("Invalid resource 'invalid'. Possible options are 'catalogs','vdcs','networks','edgegateways','organization'.")
52
51
  end
53
-
54
52
  end
55
53
 
56
54
  end