spice 1.0.0.rc → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +0 -14
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/TODO.md +2 -1
- data/lib/spice.rb +47 -72
- data/lib/spice/authentication.rb +23 -45
- data/lib/spice/base.rb +104 -0
- data/lib/spice/client.rb +8 -48
- data/lib/spice/config.rb +37 -19
- data/lib/spice/connection.rb +33 -117
- data/lib/spice/connection/clients.rb +26 -6
- data/lib/spice/connection/cookbooks.rb +19 -14
- data/lib/spice/connection/data_bags.rb +31 -20
- data/lib/spice/connection/environments.rb +6 -7
- data/lib/spice/connection/nodes.rb +23 -6
- data/lib/spice/connection/roles.rb +5 -5
- data/lib/spice/connection/search.rb +12 -12
- data/lib/spice/cookbook.rb +3 -29
- data/lib/spice/cookbook_version.rb +9 -61
- data/lib/spice/core_ext/array.rb +7 -0
- data/lib/spice/core_ext/enumerable.rb +11 -0
- data/lib/spice/core_ext/hash.rb +49 -0
- data/lib/spice/core_ext/mash.rb +219 -0
- data/lib/spice/data_bag.rb +3 -37
- data/lib/spice/data_bag_item.rb +7 -47
- data/lib/spice/environment.rb +12 -27
- data/lib/spice/error.rb +22 -10
- data/lib/spice/identity_map.rb +8 -0
- data/lib/spice/node.rb +13 -34
- data/lib/spice/request.rb +73 -11
- data/lib/spice/response/parse_json.rb +8 -3
- data/lib/spice/role.rb +8 -33
- data/lib/spice/version.rb +1 -1
- data/spec/fixtures/client.pem +27 -0
- data/spec/fixtures/clients/create.json +4 -0
- data/spec/fixtures/clients/index.json +5 -0
- data/spec/fixtures/clients/reregister.json +5 -0
- data/spec/fixtures/clients/show.json +8 -0
- data/spec/fixtures/clients/update.json +5 -0
- data/spec/fixtures/cookbook_versions/show.json +108 -0
- data/spec/fixtures/cookbook_versions/update.json +62 -0
- data/spec/fixtures/cookbooks/index-0.10.json +28 -0
- data/spec/fixtures/cookbooks/index-0.9.json +4 -0
- data/spec/fixtures/cookbooks/show-0.10.json +15 -0
- data/spec/fixtures/cookbooks/show-apache2-0.9.json +5 -0
- data/spec/fixtures/cookbooks/show-unicorn-0.9.json +5 -0
- data/spec/fixtures/data_bag_items/create.json +1 -0
- data/spec/fixtures/data_bag_items/show.json +4 -0
- data/spec/fixtures/data_bag_items/update.json +4 -0
- data/spec/fixtures/data_bags/create.json +3 -0
- data/spec/fixtures/data_bags/index.json +3 -0
- data/spec/fixtures/data_bags/show.json +3 -0
- data/spec/fixtures/environments/cookbook.json +15 -0
- data/spec/fixtures/environments/cookbooks.json +28 -0
- data/spec/fixtures/environments/create.json +1 -0
- data/spec/fixtures/environments/delete.json +8 -0
- data/spec/fixtures/environments/index.json +3 -0
- data/spec/fixtures/environments/show.json +8 -0
- data/spec/fixtures/environments/update.json +8 -0
- data/spec/fixtures/nodes/cookbooks.json +41 -0
- data/spec/fixtures/nodes/create.json +1 -0
- data/spec/fixtures/nodes/delete.json +17 -0
- data/spec/fixtures/nodes/index.json +3 -0
- data/spec/fixtures/nodes/show.json +17 -0
- data/spec/fixtures/nodes/update.json +13 -0
- data/spec/fixtures/roles/create.json +1 -0
- data/spec/fixtures/roles/delete.json +11 -0
- data/spec/fixtures/roles/index.json +3 -0
- data/spec/fixtures/roles/show.json +12 -0
- data/spec/fixtures/roles/update.json +11 -0
- data/spec/fixtures/search/client.json +1 -0
- data/spec/fixtures/search/data_bag.json +1 -0
- data/spec/fixtures/search/environment.json +1 -0
- data/spec/fixtures/search/node.json +1 -0
- data/spec/fixtures/search/role.json +1 -0
- data/spec/spec_helper.rb +5 -4
- data/spec/spice/base_spec.rb +34 -0
- data/spec/spice/client_spec.rb +0 -61
- data/spec/spice/config_spec.rb +14 -0
- data/spec/spice/connection/clients_spec.rb +82 -0
- data/spec/spice/connection/cookbooks_spec.rb +86 -0
- data/spec/spice/connection/data_bags_spec.rb +126 -0
- data/spec/spice/connection_spec.rb +63 -0
- data/spec/spice/cookbook_spec.rb +0 -61
- data/spec/spice/data_bag_item_spec.rb +7 -0
- data/spec/spice/data_bag_spec.rb +0 -160
- data/spec/spice/environment_spec.rb +0 -89
- data/spec/spice/node_spec.rb +0 -74
- data/spec/spice/role_spec.rb +0 -61
- data/spec/spice_spec.rb +8 -116
- data/spec/support/helpers.rb +58 -0
- data/spice.gemspec +13 -15
- metadata +227 -87
- data/.watchr +0 -22
- data/lib/spice/connection/authentication.rb +0 -47
- data/lib/spice/mock.rb +0 -46
- data/lib/spice/persistence.rb +0 -62
- data/spec/spice/chef_spec.rb +0 -52
- data/spec/spice/search_spec.rb +0 -2
- data/spec/support/chef_requests.rb +0 -0
- data/spec/support/client_requests.rb +0 -95
- data/spec/support/cookbook_requests.rb +0 -95
- data/spec/support/data_bag_item_requests.rb +0 -138
- data/spec/support/data_bag_requests.rb +0 -95
- data/spec/support/environment_requests.rb +0 -221
- data/spec/support/node_requests.rb +0 -138
- data/spec/support/respond_with_matcher.rb +0 -53
- data/spec/support/role_requests.rb +0 -95
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spice::Connection do
|
4
|
+
let(:keys) { Spice::Config::VALID_OPTIONS_KEYS }
|
5
|
+
|
6
|
+
after do
|
7
|
+
Spice.reset
|
8
|
+
end
|
9
|
+
|
10
|
+
context "with module configuration" do
|
11
|
+
before do
|
12
|
+
Spice.setup do |s|
|
13
|
+
keys.each do |key|
|
14
|
+
s.send("#{key}=", key)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should inherit module configuration" do
|
20
|
+
connection = Spice::Connection.new
|
21
|
+
keys.each do |key|
|
22
|
+
connection.send(key).should == key
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "with class configuration" do
|
28
|
+
before do
|
29
|
+
@configuration = {
|
30
|
+
:user_agent => "Spice Fake User Agent",
|
31
|
+
:server_url => "http://chef.example.com:4000",
|
32
|
+
:chef_version => "0.9.18",
|
33
|
+
:client_name => "admin",
|
34
|
+
:client_key => Spice.read_key_file(fake_key),
|
35
|
+
:connection_options => { :timeout => 10 },
|
36
|
+
:middleware => Proc.new {}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
context "during initialization" do
|
41
|
+
it "should override module configuration" do
|
42
|
+
connection = Spice::Connection.new(@configuration)
|
43
|
+
keys.each do |key|
|
44
|
+
connection.send(key).should == @configuration[key]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "after initialization" do
|
50
|
+
it "should override module configuration after initialization" do
|
51
|
+
connection = Spice::Connection.new
|
52
|
+
@configuration.each do |key, value|
|
53
|
+
connection.send("#{key}=", value)
|
54
|
+
end
|
55
|
+
keys.each do |key|
|
56
|
+
connection.send(key).should == @configuration[key]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/spice/cookbook_spec.rb
CHANGED
@@ -2,67 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Spice
|
4
4
|
describe Cookbook do
|
5
|
-
describe ".all" do
|
6
|
-
before { stub_cookbook_list }
|
7
|
-
subject { Cookbook.all }
|
8
|
-
|
9
|
-
it { should have_body(cookbook_list_response) }
|
10
|
-
it { should respond_with(200) }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ".show" do
|
14
|
-
context "if the cookbook is found" do
|
15
|
-
before { stub_cookbook_show }
|
16
|
-
subject { Cookbook.show(:name => "testcookbook") }
|
17
|
-
|
18
|
-
it { should have_body(cookbook_show_response) }
|
19
|
-
it { should respond_with(200) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context "if the cookbook is not found" do
|
23
|
-
before { stub_cookbook_show(404) }
|
24
|
-
subject { Cookbook.show(:name => "testcookbook") }
|
25
|
-
|
26
|
-
it { should_not have_body(cookbook_show_response) }
|
27
|
-
it { should respond_with(404) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe ".create" do
|
32
|
-
context "if the cookbook can be created" do
|
33
|
-
before { stub_cookbook_create }
|
34
|
-
subject { Cookbook.create(:name => "testcookbook") }
|
35
|
-
|
36
|
-
it { should have_body(cookbook_create_response) }
|
37
|
-
it { should respond_with(201) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context "if the cookbook already exists" do
|
41
|
-
before { stub_cookbook_create(409) }
|
42
|
-
subject { Cookbook.create(:name => "testcookbook") }
|
43
|
-
|
44
|
-
it { should have_body(cookbook_conflict) }
|
45
|
-
it { should respond_with(409) }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe ".delete" do
|
50
|
-
context "if the cookbook can be deleted" do
|
51
|
-
before { stub_cookbook_delete }
|
52
|
-
subject { Cookbook.delete(:name => "testcookbook") }
|
53
|
-
|
54
|
-
it { should have_body(cookbook_delete_response) }
|
55
|
-
it { should respond_with(200) }
|
56
|
-
end
|
57
5
|
|
58
|
-
context "if the cookbook cannot be deleted" do
|
59
|
-
before { stub_cookbook_delete(404) }
|
60
|
-
subject { Cookbook.delete(:name => "testcookbook") }
|
61
|
-
|
62
|
-
it { should have_body(cookbook_not_found) }
|
63
|
-
it { should respond_with(404) }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
6
|
end
|
68
7
|
end
|
data/spec/spice/data_bag_spec.rb
CHANGED
@@ -2,166 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Spice
|
4
4
|
describe DataBag do
|
5
|
-
describe ".all" do
|
6
|
-
before { stub_data_bag_list }
|
7
|
-
subject { DataBag.all }
|
8
|
-
|
9
|
-
it { should have_body(data_bag_list_response) }
|
10
|
-
it { should respond_with(200) }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ".show" do
|
14
|
-
context "if the data bag is found" do
|
15
|
-
before { stub_data_bag_show }
|
16
|
-
subject { DataBag.show(:name => "users") }
|
17
|
-
|
18
|
-
it { should have_body(data_bag_show_response) }
|
19
|
-
it { should respond_with(200) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context "if the data bag is not found" do
|
23
|
-
before { stub_data_bag_show(404) }
|
24
|
-
subject { DataBag.show(:name => "users") }
|
25
|
-
|
26
|
-
it { should_not have_body(data_bag_show_response) }
|
27
|
-
it { should respond_with(404) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe ".create" do
|
32
|
-
context "if the data bag can be created" do
|
33
|
-
before { stub_data_bag_create }
|
34
|
-
subject { DataBag.create(:name => "users") }
|
35
|
-
|
36
|
-
it { should have_body(data_bag_create_response) }
|
37
|
-
it { should respond_with(201) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context "if the data bag already exists" do
|
41
|
-
before { stub_data_bag_create(409) }
|
42
|
-
subject { DataBag.create(:name => "users") }
|
43
|
-
|
44
|
-
it { should have_body(data_bag_conflict) }
|
45
|
-
it { should respond_with(409) }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe ".delete" do
|
50
|
-
context "if the data bag can be deleted" do
|
51
|
-
before { stub_data_bag_delete }
|
52
|
-
subject { DataBag.delete(:name => "users") }
|
53
|
-
|
54
|
-
it { should have_body(data_bag_delete_response) }
|
55
|
-
it { should respond_with(200) }
|
56
|
-
end
|
57
|
-
|
58
|
-
context "if the data bag cannot be deleted" do
|
59
|
-
before { stub_data_bag_delete(404) }
|
60
|
-
subject { DataBag.delete(:name => "users") }
|
61
|
-
|
62
|
-
it { should have_body(data_bag_not_found) }
|
63
|
-
it { should respond_with(404) }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe ".show_item" do
|
68
|
-
context "if the data bag item exists" do
|
69
|
-
before { stub_data_bag_item_show }
|
70
|
-
subject { DataBag.show_item(:name => "users", :id => "adam") }
|
71
|
-
|
72
|
-
it { should have_body(data_bag_item_show_response) }
|
73
|
-
it { should respond_with(200) }
|
74
|
-
end
|
75
|
-
|
76
|
-
context "if the data bag item does not exist" do
|
77
|
-
before { stub_data_bag_item_show(404) }
|
78
|
-
subject { DataBag.show_item(:name => "users", :id => "adam") }
|
79
|
-
|
80
|
-
it { should have_body(data_bag_item_not_found) }
|
81
|
-
it { should respond_with(404) }
|
82
|
-
end
|
83
|
-
end
|
84
5
|
|
85
|
-
describe ".create_item" do
|
86
|
-
context "if the data bag item can be created" do
|
87
|
-
before { stub_data_bag_item_create }
|
88
|
-
subject do
|
89
|
-
Spice::DataBag.create_item(
|
90
|
-
:name => "users", :id => "adam", :real_name => "Adam Jacob"
|
91
|
-
)
|
92
|
-
end
|
93
|
-
|
94
|
-
it { should have_body(data_bag_item_create_response) }
|
95
|
-
it { should respond_with(201) }
|
96
|
-
end
|
97
|
-
|
98
|
-
context "if the data bag item cannot be created" do
|
99
|
-
before { stub_data_bag_item_create(409) }
|
100
|
-
subject do
|
101
|
-
Spice::DataBag.create_item(
|
102
|
-
:name => "users", :id => "adam", :real_name => "Adam Jacob"
|
103
|
-
)
|
104
|
-
end
|
105
|
-
|
106
|
-
it { should have_body(data_bag_item_conflict) }
|
107
|
-
it { should respond_with(409) }
|
108
|
-
end
|
109
|
-
|
110
|
-
context "if the data bag does not exist" do
|
111
|
-
before { stub_data_bag_item_create(404) }
|
112
|
-
subject do
|
113
|
-
Spice::DataBag.create_item(
|
114
|
-
:name => "users", :id => "adam", :real_name => "Adam Jacob"
|
115
|
-
)
|
116
|
-
end
|
117
|
-
|
118
|
-
it { should have_body(data_bag_not_found) }
|
119
|
-
it { should respond_with(404) }
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe ".update_item" do
|
124
|
-
context "if the data bag item can be updated" do
|
125
|
-
before { stub_data_bag_item_update }
|
126
|
-
subject do
|
127
|
-
Spice::DataBag.update_item(
|
128
|
-
:name => "users", :id => "adam", :title => "Supreme Awesomer"
|
129
|
-
)
|
130
|
-
end
|
131
|
-
|
132
|
-
it { should have_body(data_bag_item_update_response) }
|
133
|
-
it { should respond_with(200) }
|
134
|
-
end
|
135
|
-
|
136
|
-
context "if the data bag item cannot be updated" do
|
137
|
-
before { stub_data_bag_item_update(404) }
|
138
|
-
subject do
|
139
|
-
Spice::DataBag.update_item(
|
140
|
-
:name => "users", :id => "adam", :title => "Supreme Awesomer"
|
141
|
-
)
|
142
|
-
end
|
143
|
-
it { should have_body(data_bag_item_not_found) }
|
144
|
-
it { should respond_with(404) }
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
describe ".delete_item" do
|
149
|
-
context "if the data bag item can be deleted" do
|
150
|
-
before { stub_data_bag_item_delete }
|
151
|
-
subject{ Spice::DataBag.delete_item(:name => "users", :id => "adam") }
|
152
|
-
|
153
|
-
it { should have_body(data_bag_item_delete_response) }
|
154
|
-
it { should respond_with(200) }
|
155
|
-
end
|
156
|
-
|
157
|
-
context "if the data bag item cannot be deleted" do
|
158
|
-
before { stub_data_bag_item_delete(404) }
|
159
|
-
subject{ Spice::DataBag.delete_item(:name => "users", :id => "adam") }
|
160
|
-
|
161
|
-
it { should have_body(data_bag_item_not_found) }
|
162
|
-
it { should respond_with(404) }
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
6
|
end
|
167
7
|
end
|
@@ -2,95 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Spice
|
4
4
|
describe Environment do
|
5
|
-
describe ".all" do
|
6
|
-
before { stub_environment_list }
|
7
|
-
subject { Environment.all }
|
8
|
-
|
9
|
-
it { should have_body(environment_list_response) }
|
10
|
-
it { should respond_with(200) }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ".show" do
|
14
|
-
context "if the environment is found" do
|
15
|
-
before { stub_environment_show }
|
16
|
-
subject { Environment.show(:name => "dev") }
|
17
|
-
|
18
|
-
it { should have_body(environment_show_response) }
|
19
|
-
it { should respond_with(200) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context "if the environment is not found" do
|
23
|
-
before { stub_environment_show(404) }
|
24
|
-
subject { Environment.show(:name => "dev") }
|
25
|
-
|
26
|
-
it { should_not have_body(environment_show_response) }
|
27
|
-
it { should respond_with(404) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe ".create" do
|
32
|
-
context "if the environment can be created" do
|
33
|
-
before { stub_environment_create }
|
34
|
-
subject { Environment.create(:name => "dev") }
|
35
|
-
|
36
|
-
it { should have_body(environment_create_response) }
|
37
|
-
it { should respond_with(201) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context "if the environment already exists" do
|
41
|
-
before { stub_environment_create(409) }
|
42
|
-
subject { Environment.create(:name => "dev") }
|
43
|
-
|
44
|
-
it { should have_body(environment_conflict) }
|
45
|
-
it { should respond_with(409) }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe ".delete" do
|
50
|
-
context "if the environment can be deleted" do
|
51
|
-
before { stub_environment_delete }
|
52
|
-
subject { Environment.delete(:name => "dev") }
|
53
|
-
|
54
|
-
it { should have_body(environment_delete_response) }
|
55
|
-
it { should respond_with(200) }
|
56
|
-
end
|
57
|
-
|
58
|
-
context "if the environment cannot be deleted" do
|
59
|
-
before { stub_environment_delete(404) }
|
60
|
-
subject { Environment.delete(:name => "dev") }
|
61
|
-
|
62
|
-
it { should have_body(environment_not_found) }
|
63
|
-
it { should respond_with(404) }
|
64
|
-
end
|
65
|
-
end
|
66
5
|
|
67
|
-
describe ".list_cookbooks" do
|
68
|
-
context "if cookbooks exists" do
|
69
|
-
before { stub_environment_cookbooks_list }
|
70
|
-
subject { Environment.list_cookbooks(:name => "dev") }
|
71
|
-
|
72
|
-
it { should have_body(environment_cookbooks_list_response) }
|
73
|
-
it { should respond_with(200) }
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe ".show_cookbook" do
|
78
|
-
context "if the cookbook exists" do
|
79
|
-
before { stub_environment_cookbook_show }
|
80
|
-
subject { Environment.show_cookbook(:name => "dev", :cookbook => "apache") }
|
81
|
-
|
82
|
-
it { should have_body(environment_cookbook_show_response) }
|
83
|
-
it { should respond_with(200) }
|
84
|
-
end
|
85
|
-
|
86
|
-
context "if the cookbook does not exist" do
|
87
|
-
before { stub_environment_cookbook_show(404) }
|
88
|
-
subject { Environment.show_cookbook(:name => "dev", :cookbook => "apache") }
|
89
|
-
|
90
|
-
it { should have_body(environment_not_found) }
|
91
|
-
it { should respond_with(404) }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
6
|
end
|
96
7
|
end
|
data/spec/spice/node_spec.rb
CHANGED
@@ -2,80 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Spice
|
4
4
|
describe Node do
|
5
|
-
describe ".all" do
|
6
|
-
before { stub_node_list }
|
7
|
-
subject { Node.all }
|
8
|
-
|
9
|
-
it { should have_body(node_list_response) }
|
10
|
-
it { should respond_with(200) }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ".show" do
|
14
|
-
context "if the node is found" do
|
15
|
-
before { stub_node_show }
|
16
|
-
subject { Node.show(:name => "testnode") }
|
17
|
-
|
18
|
-
it { should have_body(node_show_response) }
|
19
|
-
it { should respond_with(200) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context "if the node is not found" do
|
23
|
-
before { stub_node_show(404) }
|
24
|
-
subject { Node.show(:name => "testnode") }
|
25
|
-
|
26
|
-
it { should_not have_body(node_show_response) }
|
27
|
-
it { should respond_with(404) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe ".create" do
|
32
|
-
context "if the node can be created" do
|
33
|
-
before { stub_node_create }
|
34
|
-
subject { Node.create(:name => "testnode") }
|
35
|
-
|
36
|
-
it { should have_body(node_create_response) }
|
37
|
-
it { should respond_with(201) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context "if the node has a run list" do
|
41
|
-
before { stub_node_create_with_run_list }
|
42
|
-
subject do
|
43
|
-
Node.create(
|
44
|
-
:name => "testnode",
|
45
|
-
:run_list => ["recipe[unicorn]" ]
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
it { should have_body(node_create_response_with_run_list) }
|
50
|
-
it { should respond_with(201) }
|
51
|
-
end
|
52
|
-
|
53
|
-
context "if the node already exists" do
|
54
|
-
before { stub_node_create(409) }
|
55
|
-
subject { Node.create(:name => "testnode") }
|
56
|
-
|
57
|
-
it { should have_body(node_conflict) }
|
58
|
-
it { should respond_with(409) }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe ".delete" do
|
63
|
-
context "if the node can be deleted" do
|
64
|
-
before { stub_node_delete }
|
65
|
-
subject { Node.delete(:name => "testnode") }
|
66
|
-
|
67
|
-
it { should have_body(node_delete_response) }
|
68
|
-
it { should respond_with(200) }
|
69
|
-
end
|
70
5
|
|
71
|
-
context "if the node cannot be deleted" do
|
72
|
-
before { stub_node_delete(404) }
|
73
|
-
subject { Node.delete(:name => "testnode") }
|
74
|
-
|
75
|
-
it { should have_body(node_not_found) }
|
76
|
-
it { should respond_with(404) }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
6
|
end
|
81
7
|
end
|