ridley 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +1 -1
  4. data/README.md +4 -4
  5. data/lib/ridley/connection.rb +1 -2
  6. data/lib/ridley/errors.rb +1 -0
  7. data/lib/ridley/mixin/params_validate.rb +4 -0
  8. data/lib/ridley/version.rb +1 -1
  9. data/ridley.gemspec +2 -2
  10. data/spec/acceptance/client_resource_spec.rb +12 -12
  11. data/spec/acceptance/cookbook_resource_spec.rb +15 -15
  12. data/spec/acceptance/data_bag_item_resource_spec.rb +14 -14
  13. data/spec/acceptance/data_bag_resource_spec.rb +4 -4
  14. data/spec/acceptance/environment_resource_spec.rb +14 -14
  15. data/spec/acceptance/node_resource_spec.rb +15 -15
  16. data/spec/acceptance/role_resource_spec.rb +14 -14
  17. data/spec/acceptance/sandbox_resource_spec.rb +3 -3
  18. data/spec/acceptance/search_resource_spec.rb +6 -6
  19. data/spec/acceptance/user_resource_spec.rb +21 -21
  20. data/spec/support/each_matcher.rb +2 -2
  21. data/spec/support/filepath_matchers.rb +2 -2
  22. data/spec/support/shared_examples/ridley_resource.rb +39 -39
  23. data/spec/unit/ridley/chef/cookbook/metadata_spec.rb +8 -8
  24. data/spec/unit/ridley/chef/cookbook/syntax_check_spec.rb +15 -15
  25. data/spec/unit/ridley/chef/cookbook_spec.rb +124 -118
  26. data/spec/unit/ridley/chef/digester_spec.rb +2 -2
  27. data/spec/unit/ridley/chef_object_spec.rb +35 -35
  28. data/spec/unit/ridley/chef_objects/client_object_spec.rb +2 -2
  29. data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +12 -12
  30. data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +7 -7
  31. data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +4 -1
  32. data/spec/unit/ridley/chef_objects/environment_object_spec.rb +10 -10
  33. data/spec/unit/ridley/chef_objects/node_object_spec.rb +28 -28
  34. data/spec/unit/ridley/chef_objects/role_object_spec.rb +10 -10
  35. data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +6 -6
  36. data/spec/unit/ridley/client_spec.rb +59 -21
  37. data/spec/unit/ridley/connection_spec.rb +7 -7
  38. data/spec/unit/ridley/errors_spec.rb +3 -3
  39. data/spec/unit/ridley/middleware/chef_auth_spec.rb +2 -2
  40. data/spec/unit/ridley/middleware/chef_response_spec.rb +29 -29
  41. data/spec/unit/ridley/middleware/parse_json_spec.rb +14 -14
  42. data/spec/unit/ridley/mixins/from_file_spec.rb +3 -3
  43. data/spec/unit/ridley/resource_spec.rb +5 -5
  44. data/spec/unit/ridley/resources/cookbook_resource_spec.rb +10 -10
  45. data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +1 -1
  46. data/spec/unit/ridley/resources/data_bag_resource_spec.rb +6 -3
  47. data/spec/unit/ridley/resources/environment_resource_spec.rb +4 -4
  48. data/spec/unit/ridley/resources/role_resource_spec.rb +1 -1
  49. data/spec/unit/ridley/resources/sandbox_resource_spec.rb +7 -7
  50. data/spec/unit/ridley/resources/search_resource_spec.rb +22 -22
  51. data/spec/unit/ridley/sandbox_uploader_spec.rb +3 -3
  52. data/spec/unit/ridley_spec.rb +6 -6
  53. metadata +15 -18
  54. data/lib/ridley/middleware/gzip.rb +0 -18
  55. data/spec/unit/ridley/middleware/gzip_spec.rb +0 -59
@@ -11,7 +11,7 @@ describe "Node API operations", type: "acceptance" do
11
11
  before { chef_node(node_name) }
12
12
 
13
13
  it "returns a Ridley::NodeObject" do
14
- connection.node.find(node_name).should be_a(Ridley::NodeObject)
14
+ expect(connection.node.find(node_name)).to be_a(Ridley::NodeObject)
15
15
  end
16
16
  end
17
17
 
@@ -19,13 +19,13 @@ describe "Node API operations", type: "acceptance" do
19
19
  let(:node_name) { "ridley.localhost" }
20
20
 
21
21
  it "returns a new Ridley::NodeObject object" do
22
- connection.node.create(name: node_name).should be_a(Ridley::NodeObject)
22
+ expect(connection.node.create(name: node_name)).to be_a(Ridley::NodeObject)
23
23
  end
24
24
 
25
25
  it "adds a new node to the server" do
26
26
  connection.node.create(name: node_name)
27
27
 
28
- connection.node.all.should have(1).node
28
+ expect(connection.node.all.size).to eq(1)
29
29
  end
30
30
  end
31
31
 
@@ -34,13 +34,13 @@ describe "Node API operations", type: "acceptance" do
34
34
  before { chef_node(node_name) }
35
35
 
36
36
  it "returns a Ridley::NodeObject" do
37
- connection.node.delete(node_name).should be_a(Ridley::NodeObject)
37
+ expect(connection.node.delete(node_name)).to be_a(Ridley::NodeObject)
38
38
  end
39
39
 
40
40
  it "removes the node from the server" do
41
41
  connection.node.delete(node_name)
42
42
 
43
- connection.node.find(node_name).should be_nil
43
+ expect(connection.node.find(node_name)).to be_nil
44
44
  end
45
45
  end
46
46
 
@@ -53,7 +53,7 @@ describe "Node API operations", type: "acceptance" do
53
53
  it "deletes all nodes from the remote server" do
54
54
  connection.node.delete_all
55
55
 
56
- connection.node.all.should have(0).nodes
56
+ expect(connection.node.all.size).to eq(0)
57
57
  end
58
58
  end
59
59
 
@@ -66,8 +66,8 @@ describe "Node API operations", type: "acceptance" do
66
66
  it "returns an array of Ridley::NodeObject" do
67
67
  obj = connection.node.all
68
68
 
69
- obj.should each be_a(Ridley::NodeObject)
70
- obj.should have(2).nodes
69
+ expect(obj).to each be_a(Ridley::NodeObject)
70
+ expect(obj.size).to eq(2)
71
71
  end
72
72
  end
73
73
 
@@ -77,7 +77,7 @@ describe "Node API operations", type: "acceptance" do
77
77
  let(:target) { connection.node.find(node_name) }
78
78
 
79
79
  it "returns the updated node" do
80
- connection.node.update(target).should eql(target)
80
+ expect(connection.node.update(target)).to eql(target)
81
81
  end
82
82
 
83
83
  it "saves a new set of 'normal' attributes" do
@@ -91,7 +91,7 @@ describe "Node API operations", type: "acceptance" do
91
91
  connection.node.update(target)
92
92
  obj = connection.node.find(target)
93
93
 
94
- obj.normal.should eql(normal)
94
+ expect(obj.normal).to eql(normal)
95
95
  end
96
96
 
97
97
  it "saves a new set of 'default' attributes" do
@@ -105,7 +105,7 @@ describe "Node API operations", type: "acceptance" do
105
105
  connection.node.update(target)
106
106
  obj = connection.node.find(target)
107
107
 
108
- obj.default.should eql(defaults)
108
+ expect(obj.default).to eql(defaults)
109
109
  end
110
110
 
111
111
  it "saves a new set of 'automatic' attributes" do
@@ -119,7 +119,7 @@ describe "Node API operations", type: "acceptance" do
119
119
  connection.node.update(target)
120
120
  obj = connection.node.find(target)
121
121
 
122
- obj.automatic.should eql(automatics)
122
+ expect(obj.automatic).to eql(automatics)
123
123
  end
124
124
 
125
125
  it "saves a new set of 'override' attributes" do
@@ -133,7 +133,7 @@ describe "Node API operations", type: "acceptance" do
133
133
  connection.node.update(target)
134
134
  obj = connection.node.find(target)
135
135
 
136
- obj.override.should eql(overrides)
136
+ expect(obj.override).to eql(overrides)
137
137
  end
138
138
 
139
139
  it "places a node in a new 'chef_environment'" do
@@ -142,7 +142,7 @@ describe "Node API operations", type: "acceptance" do
142
142
  connection.node.update(target)
143
143
  obj = connection.node.find(target)
144
144
 
145
- obj.chef_environment.should eql(environment)
145
+ expect(obj.chef_environment).to eql(environment)
146
146
  end
147
147
 
148
148
  it "saves a new 'run_list' for the node" do
@@ -151,7 +151,7 @@ describe "Node API operations", type: "acceptance" do
151
151
  connection.node.update(target)
152
152
  obj = connection.node.find(target)
153
153
 
154
- obj.run_list.should eql(run_list)
154
+ expect(obj.run_list).to eql(run_list)
155
155
  end
156
156
  end
157
157
  end
@@ -11,7 +11,7 @@ describe "Role API operations", type: "acceptance" do
11
11
  before { chef_role(role_name) }
12
12
 
13
13
  it "returns a Ridley::RoleObject" do
14
- connection.role.find(role_name).should be_a(Ridley::RoleObject)
14
+ expect(connection.role.find(role_name)).to be_a(Ridley::RoleObject)
15
15
  end
16
16
  end
17
17
 
@@ -19,12 +19,12 @@ describe "Role API operations", type: "acceptance" do
19
19
  let(:role_name) { "ridley-role" }
20
20
 
21
21
  it "returns a new Ridley::RoleObject" do
22
- connection.role.create(name: role_name).should be_a(Ridley::RoleObject)
22
+ expect(connection.role.create(name: role_name)).to be_a(Ridley::RoleObject)
23
23
  end
24
24
 
25
25
  it "adds a new role to the server" do
26
26
  connection.role.create(name: role_name)
27
- connection.role.all.should have(1).role
27
+ expect(connection.role.all.size).to eq(1)
28
28
  end
29
29
  end
30
30
 
@@ -33,13 +33,13 @@ describe "Role API operations", type: "acceptance" do
33
33
  before { chef_role(role_name) }
34
34
 
35
35
  it "returns the deleted Ridley::RoleObject resource" do
36
- connection.role.delete(role_name).should be_a(Ridley::RoleObject)
36
+ expect(connection.role.delete(role_name)).to be_a(Ridley::RoleObject)
37
37
  end
38
38
 
39
39
  it "removes the role from the server" do
40
40
  connection.role.delete(role_name)
41
41
 
42
- connection.role.find(role_name).should be_nil
42
+ expect(connection.role.find(role_name)).to be_nil
43
43
  end
44
44
  end
45
45
 
@@ -52,7 +52,7 @@ describe "Role API operations", type: "acceptance" do
52
52
  it "deletes all nodes from the remote server" do
53
53
  connection.role.delete_all
54
54
 
55
- connection.role.all.should have(0).roles
55
+ expect(connection.role.all.size).to eq(0)
56
56
  end
57
57
  end
58
58
 
@@ -65,8 +65,8 @@ describe "Role API operations", type: "acceptance" do
65
65
  it "should return an array of Ridley::RoleObject" do
66
66
  obj = connection.role.all
67
67
 
68
- obj.should have(2).roles
69
- obj.should each be_a(Ridley::RoleObject)
68
+ expect(obj.size).to eq(2)
69
+ expect(obj).to each be_a(Ridley::RoleObject)
70
70
  end
71
71
  end
72
72
 
@@ -76,7 +76,7 @@ describe "Role API operations", type: "acceptance" do
76
76
  let(:target) { connection.role.find(role_name) }
77
77
 
78
78
  it "returns an updated Ridley::RoleObject object" do
79
- connection.role.update(target).should eql(target)
79
+ expect(connection.role.update(target)).to eql(target)
80
80
  end
81
81
 
82
82
  it "saves a new run_list" do
@@ -85,7 +85,7 @@ describe "Role API operations", type: "acceptance" do
85
85
  connection.role.update(target)
86
86
  obj = connection.role.find(target)
87
87
 
88
- obj.run_list.should eql(run_list)
88
+ expect(obj.run_list).to eql(run_list)
89
89
  end
90
90
 
91
91
  it "saves a new env_run_lists" do
@@ -97,7 +97,7 @@ describe "Role API operations", type: "acceptance" do
97
97
  connection.role.update(target)
98
98
  obj = connection.role.find(target)
99
99
 
100
- obj.env_run_lists.should eql(env_run_lists)
100
+ expect(obj.env_run_lists).to eql(env_run_lists)
101
101
  end
102
102
 
103
103
  it "saves a new description" do
@@ -106,7 +106,7 @@ describe "Role API operations", type: "acceptance" do
106
106
  connection.role.update(target)
107
107
  obj = connection.role.find(target)
108
108
 
109
- obj.description.should eql(description)
109
+ expect(obj.description).to eql(description)
110
110
  end
111
111
 
112
112
  it "saves a new default_attributes" do
@@ -120,7 +120,7 @@ describe "Role API operations", type: "acceptance" do
120
120
  connection.role.update(target)
121
121
  obj = connection.role.find(target)
122
122
 
123
- obj.default_attributes.should eql(defaults)
123
+ expect(obj.default_attributes).to eql(defaults)
124
124
  end
125
125
 
126
126
  it "saves a new override_attributes" do
@@ -134,7 +134,7 @@ describe "Role API operations", type: "acceptance" do
134
134
  connection.role.update(target)
135
135
  obj = connection.role.find(target)
136
136
 
137
- obj.override_attributes.should eql(overrides)
137
+ expect(obj.override_attributes).to eql(overrides)
138
138
  end
139
139
  end
140
140
  end
@@ -15,15 +15,15 @@ describe "Sandbox API operations", type: "acceptance" do
15
15
 
16
16
  describe "creating a new sandbox" do
17
17
  it "returns an instance of Ridley::SandboxObject" do
18
- connection.sandbox.create(checksums).should be_a(Ridley::SandboxObject)
18
+ expect(connection.sandbox.create(checksums)).to be_a(Ridley::SandboxObject)
19
19
  end
20
20
 
21
21
  it "contains a value for sandbox_id" do
22
- connection.sandbox.create(checksums).sandbox_id.should_not be_nil
22
+ expect(connection.sandbox.create(checksums).sandbox_id).not_to be_nil
23
23
  end
24
24
 
25
25
  it "returns an instance with the same amount of checksums given to create" do
26
- connection.sandbox.create(checksums).checksums.should have(2).items
26
+ expect(connection.sandbox.create(checksums).checksums.size).to eq(2)
27
27
  end
28
28
  end
29
29
  end
@@ -10,18 +10,18 @@ describe "Search API operations", type: "acceptance" do
10
10
  it "returns an array of indexes" do
11
11
  indexes = connection.search_indexes
12
12
 
13
- indexes.should include("role")
14
- indexes.should include("node")
15
- indexes.should include("client")
16
- indexes.should include("environment")
13
+ expect(indexes).to include("role")
14
+ expect(indexes).to include("node")
15
+ expect(indexes).to include("client")
16
+ expect(indexes).to include("environment")
17
17
  end
18
18
  end
19
19
 
20
20
  describe "searching an index that doesn't exist" do
21
21
  it "it raises a Ridley::Errors::HTTPNotFound error" do
22
- lambda {
22
+ expect {
23
23
  connection.search(:notthere)
24
- }.should raise_error(Ridley::Errors::HTTPNotFound)
24
+ }.to raise_error(Ridley::Errors::HTTPNotFound)
25
25
  end
26
26
  end
27
27
  end
@@ -11,30 +11,30 @@ describe "User API operations", type: "wip" do
11
11
  before { chef_user("reset", admin: false) }
12
12
 
13
13
  it "returns a UserObject" do
14
- connection.user.find("reset").should be_a(Ridley::UserObject)
14
+ expect(connection.user.find("reset")).to be_a(Ridley::UserObject)
15
15
  end
16
16
  end
17
17
 
18
18
  context "when the server does not have the user" do
19
19
  it "returns a nil value" do
20
- connection.user.find("not_there").should be_nil
20
+ expect(connection.user.find("not_there")).to be_nil
21
21
  end
22
22
  end
23
23
  end
24
24
 
25
25
  describe "creating a user" do
26
26
  it "returns a Ridley::UserObject" do
27
- connection.user.create(name: "reset").should be_a(Ridley::UserObject)
27
+ expect(connection.user.create(name: "reset")).to be_a(Ridley::UserObject)
28
28
  end
29
29
 
30
30
  it "adds a user to the chef server" do
31
31
  old = connection.user.all.length
32
32
  connection.user.create(name: "reset")
33
- connection.user.all.should have(old + 1).items
33
+ expect(connection.user.all.size).to eq(old + 1)
34
34
  end
35
35
 
36
36
  it "has a value for #private_key" do
37
- connection.user.create(name: "reset").private_key.should_not be_nil
37
+ expect(connection.user.create(name: "reset").private_key).not_to be_nil
38
38
  end
39
39
  end
40
40
 
@@ -42,13 +42,13 @@ describe "User API operations", type: "wip" do
42
42
  before { chef_user("reset", admin: false) }
43
43
 
44
44
  it "returns a Ridley::UserObject object" do
45
- connection.user.delete("reset").should be_a(Ridley::UserObject)
45
+ expect(connection.user.delete("reset")).to be_a(Ridley::UserObject)
46
46
  end
47
47
 
48
48
  it "removes the user from the server" do
49
49
  connection.user.delete("reset")
50
50
 
51
- connection.user.find("reset").should be_nil
51
+ expect(connection.user.find("reset")).to be_nil
52
52
  end
53
53
  end
54
54
 
@@ -59,12 +59,12 @@ describe "User API operations", type: "wip" do
59
59
  end
60
60
 
61
61
  it "returns an array of Ridley::UserObject objects" do
62
- connection.user.delete_all.should each be_a(Ridley::UserObject)
62
+ expect(connection.user.delete_all).to each be_a(Ridley::UserObject)
63
63
  end
64
64
 
65
65
  it "deletes all users from the remote" do
66
66
  connection.user.delete_all
67
- connection.user.all.should have(0).users
67
+ expect(connection.user.all.size).to eq(0)
68
68
  end
69
69
  end
70
70
 
@@ -75,11 +75,11 @@ describe "User API operations", type: "wip" do
75
75
  end
76
76
 
77
77
  it "returns an array of Ridley::UserObject objects" do
78
- connection.user.all.should each be_a(Ridley::UserObject)
78
+ expect(connection.user.all).to each be_a(Ridley::UserObject)
79
79
  end
80
80
 
81
81
  it "returns all of the users on the server" do
82
- connection.user.all.should have(3).items
82
+ expect(connection.user.all.size).to eq(3)
83
83
  end
84
84
  end
85
85
 
@@ -87,7 +87,7 @@ describe "User API operations", type: "wip" do
87
87
  before { chef_user("reset", admin: false) }
88
88
 
89
89
  it "returns a Ridley::UserObject object with a value for #private_key" do
90
- connection.user.regenerate_key("reset").private_key.should match(/^-----BEGIN RSA PRIVATE KEY-----/)
90
+ expect(connection.user.regenerate_key("reset").private_key).to match(/^-----BEGIN RSA PRIVATE KEY-----/)
91
91
  end
92
92
  end
93
93
 
@@ -95,20 +95,20 @@ describe "User API operations", type: "wip" do
95
95
  before { chef_user('reset', password: 'swordfish') }
96
96
 
97
97
  it "returns true when given valid username & password" do
98
- expect(connection.user.authenticate('reset', 'swordfish')).to be_true
98
+ expect(connection.user.authenticate('reset', 'swordfish')).to be_truthy
99
99
  end
100
100
 
101
101
  it "returns false when given valid username & invalid password" do
102
- expect(connection.user.authenticate('reset', "not a swordfish")).to be_false
102
+ expect(connection.user.authenticate('reset', "not a swordfish")).to be_falsey
103
103
  end
104
104
 
105
105
  it "returns false when given invalid username & valid password" do
106
- expect(connection.user.authenticate("someone-else", 'swordfish')).to be_false
106
+ expect(connection.user.authenticate("someone-else", 'swordfish')).to be_falsey
107
107
  end
108
108
 
109
109
  it "works also on a User object level" do
110
- expect(connection.user.find('reset').authenticate('swordfish')).to be_true
111
- expect(connection.user.find('reset').authenticate('not a swordfish')).to be_false
110
+ expect(connection.user.find('reset').authenticate('swordfish')).to be_truthy
111
+ expect(connection.user.find('reset').authenticate('not a swordfish')).to be_falsey
112
112
  end
113
113
  end
114
114
 
@@ -117,14 +117,14 @@ describe "User API operations", type: "wip" do
117
117
  subject { connection.user.find('reset') }
118
118
 
119
119
  it "changes the password with which user can authenticate" do
120
- expect(subject.authenticate('swordfish')).to be_true
121
- expect(subject.authenticate('salmon')).to be_false
120
+ expect(subject.authenticate('swordfish')).to be_truthy
121
+ expect(subject.authenticate('salmon')).to be_falsey
122
122
 
123
123
  subject.password = 'salmon'
124
124
  subject.save
125
125
 
126
- expect(subject.authenticate('swordfish')).to be_false
127
- expect(subject.authenticate('salmon')).to be_true
126
+ expect(subject.authenticate('swordfish')).to be_falsey
127
+ expect(subject.authenticate('salmon')).to be_truthy
128
128
  end
129
129
  end
130
130
  end
@@ -2,11 +2,11 @@ RSpec::Matchers.define :each do |check|
2
2
  match do |actual|
3
3
  actual.each_with_index do |index, o|
4
4
  @object = o
5
- index.should check
5
+ expect(index).to check
6
6
  end
7
7
  end
8
8
 
9
- failure_message_for_should do |actual|
9
+ failure_message do |actual|
10
10
  "at[#{@object}] #{check.failure_message_for_should}"
11
11
  end
12
12
  end
@@ -9,11 +9,11 @@ RSpec::Matchers.define :be_relative_path do
9
9
  end
10
10
  end
11
11
 
12
- failure_message_for_should do |given|
12
+ failure_message do |given|
13
13
  "Expected '#{given}' to be a relative path but got an absolute path."
14
14
  end
15
15
 
16
- failure_message_for_should_not do |given|
16
+ failure_message_when_negated do |given|
17
17
  "Expected '#{given}' to not be a relative path but got an absolute path."
18
18
  end
19
19
  end
@@ -9,8 +9,8 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
9
9
 
10
10
  describe "::all" do
11
11
  it "sends a get request for the class' resource_path using the given client" do
12
- response.stub(:body) { Hash.new }
13
- client.connection.should_receive(:get).with(subject.resource_path).and_return(response)
12
+ allow(response).to receive(:body) { Hash.new }
13
+ expect(client.connection).to receive(:get).with(subject.resource_path).and_return(response)
14
14
 
15
15
  subject.all(client)
16
16
  end
@@ -19,8 +19,8 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
19
19
  describe "::find" do
20
20
  it "sends a get request to the given client to the resource_path of the class for the given chef_id" do
21
21
  chef_id = "ridley_test"
22
- response.stub(:body) { Hash.new }
23
- client.connection.should_receive(:get).with("#{subject.resource_path}/#{chef_id}").and_return(response)
22
+ allow(response).to receive(:body) { Hash.new }
23
+ expect(client.connection).to receive(:get).with("#{subject.resource_path}/#{chef_id}").and_return(response)
24
24
 
25
25
  subject.find(client, chef_id)
26
26
  end
@@ -33,8 +33,8 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
33
33
  last_name: "winsor"
34
34
  }
35
35
 
36
- response.stub(:body) { attrs }
37
- client.connection.should_receive(:post).with(subject.resource_path, duck_type(:to_json)).and_return(response)
36
+ allow(response).to receive(:body) { attrs }
37
+ expect(client.connection).to receive(:post).with(subject.resource_path, duck_type(:to_json)).and_return(response)
38
38
 
39
39
  subject.create(client, attrs)
40
40
  end
@@ -42,17 +42,17 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
42
42
 
43
43
  describe "::delete" do
44
44
  it "sends a delete request to the given client using the includer's resource_path for the given string" do
45
- response.stub(:body) { Hash.new }
46
- client.connection.should_receive(:delete).with("#{subject.resource_path}/ridley-test").and_return(response)
45
+ allow(response).to receive(:body) { Hash.new }
46
+ expect(client.connection).to receive(:delete).with("#{subject.resource_path}/ridley-test").and_return(response)
47
47
 
48
48
  subject.delete(client, "ridley-test")
49
49
  end
50
50
 
51
51
  it "accepts an object that responds to 'chef_id'" do
52
52
  object = double("obj")
53
- object.stub(:chef_id) { "hello" }
54
- response.stub(:body) { Hash.new }
55
- client.connection.should_receive(:delete).with("#{subject.resource_path}/#{object.chef_id}").and_return(response)
53
+ allow(object).to receive(:chef_id) { "hello" }
54
+ allow(response).to receive(:body) { Hash.new }
55
+ expect(client.connection).to receive(:delete).with("#{subject.resource_path}/#{object.chef_id}").and_return(response)
56
56
 
57
57
  subject.delete(client, object)
58
58
  end
@@ -60,17 +60,17 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
60
60
 
61
61
  describe "::delete_all" do
62
62
  it "sends a delete request for every object in the collection" do
63
- pending
63
+ skip
64
64
  end
65
65
  end
66
66
 
67
67
  describe "::update" do
68
68
  it "sends a put request to the given client using the includer's resource_path with the given object" do
69
- subject.stub(:chef_id) { :name }
69
+ allow(subject).to receive(:chef_id) { :name }
70
70
  subject.attribute(:name)
71
71
  object = subject.new(name: "hello")
72
- response.stub(:body) { Hash.new }
73
- client.connection.should_receive(:put).with("#{subject.resource_path}/#{object.chef_id}", duck_type(:to_json)).and_return(response)
72
+ allow(response).to receive(:body) { Hash.new }
73
+ expect(client.connection).to receive(:put).with("#{subject.resource_path}/#{object.chef_id}", duck_type(:to_json)).and_return(response)
74
74
 
75
75
  subject.update(client, object)
76
76
  end
@@ -81,12 +81,12 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
81
81
 
82
82
  describe "#save" do
83
83
  context "when the object is valid" do
84
- before(:each) { subject.stub(:valid?).and_return(true) }
84
+ before(:each) { allow(subject).to receive(:valid?).and_return(true) }
85
85
 
86
86
  it "sends a create message to the implementing class" do
87
87
  updated = double('updated')
88
- updated.stub(:_attributes_).and_return(Hash.new)
89
- subject.class.should_receive(:create).with(client, subject).and_return(updated)
88
+ allow(updated).to receive(:_attributes_).and_return(Hash.new)
89
+ expect(subject.class).to receive(:create).with(client, subject).and_return(updated)
90
90
 
91
91
  subject.save
92
92
  end
@@ -94,10 +94,10 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
94
94
  context "when there is an HTTPConflict" do
95
95
  it "sends the update message to self" do
96
96
  updated = double('updated')
97
- updated.stub(:[]).and_return(Hash.new)
98
- updated.stub(:_attributes_).and_return(Hash.new)
99
- subject.class.should_receive(:create).and_raise(Ridley::Errors::HTTPConflict.new(updated))
100
- subject.should_receive(:update).and_return(updated)
97
+ allow(updated).to receive(:[]).and_return(Hash.new)
98
+ allow(updated).to receive(:_attributes_).and_return(Hash.new)
99
+ expect(subject.class).to receive(:create).and_raise(Ridley::Errors::HTTPConflict.new(updated))
100
+ expect(subject).to receive(:update).and_return(updated)
101
101
 
102
102
  subject.save
103
103
  end
@@ -105,12 +105,12 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
105
105
  end
106
106
 
107
107
  context "when the object is invalid" do
108
- before(:each) { subject.stub(:valid?).and_return(false) }
108
+ before(:each) { allow(subject).to receive(:valid?).and_return(false) }
109
109
 
110
110
  it "raises an InvalidResource error" do
111
- lambda {
111
+ expect {
112
112
  subject.save
113
- }.should raise_error(Ridley::Errors::InvalidResource)
113
+ }.to raise_error(Ridley::Errors::InvalidResource)
114
114
  end
115
115
  end
116
116
  end
@@ -119,31 +119,31 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
119
119
  context "when the object is valid" do
120
120
  let(:updated) do
121
121
  updated = double('updated')
122
- updated.stub(:[]).and_return(Hash.new)
123
- updated.stub(:_attributes_).and_return(Hash.new)
122
+ allow(updated).to receive(:[]).and_return(Hash.new)
123
+ allow(updated).to receive(:_attributes_).and_return(Hash.new)
124
124
  updated
125
125
  end
126
126
 
127
- before(:each) { subject.stub(:valid?).and_return(true) }
127
+ before(:each) { allow(subject).to receive(:valid?).and_return(true) }
128
128
 
129
129
  it "sends an update message to the implementing class" do
130
- subject.class.should_receive(:update).with(anything, subject).and_return(updated)
130
+ expect(subject.class).to receive(:update).with(anything, subject).and_return(updated)
131
131
  subject.update
132
132
  end
133
133
 
134
134
  it "returns true" do
135
- subject.class.should_receive(:update).with(anything, subject).and_return(updated)
136
- subject.update.should eql(true)
135
+ expect(subject.class).to receive(:update).with(anything, subject).and_return(updated)
136
+ expect(subject.update).to eql(true)
137
137
  end
138
138
  end
139
139
 
140
140
  context "when the object is invalid" do
141
- before(:each) { subject.stub(:valid?).and_return(false) }
141
+ before(:each) { allow(subject).to receive(:valid?).and_return(false) }
142
142
 
143
143
  it "raises an InvalidResource error" do
144
- lambda {
144
+ expect {
145
145
  subject.update
146
- }.should raise_error(Ridley::Errors::InvalidResource)
146
+ }.to raise_error(Ridley::Errors::InvalidResource)
147
147
  end
148
148
  end
149
149
  end
@@ -151,10 +151,10 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
151
151
  describe "#chef_id" do
152
152
  it "returns the value of the chef_id attribute" do
153
153
  subject.class.attribute(:name)
154
- subject.class.stub(:chef_id) { :name }
154
+ allow(subject.class).to receive(:chef_id) { :name }
155
155
  subject.mass_assign(name: "reset")
156
156
 
157
- subject.chef_id.should eql("reset")
157
+ expect(subject.chef_id).to eql("reset")
158
158
  end
159
159
  end
160
160
 
@@ -163,17 +163,17 @@ shared_examples_for "a Ridley Resource" do |resource_klass|
163
163
 
164
164
  before(:each) do
165
165
  subject.class.attribute(:fake_attribute)
166
- subject.class.stub(:find).with(client, subject).and_return(updated_subject)
166
+ allow(subject.class).to receive(:find).with(client, subject).and_return(updated_subject)
167
167
  end
168
168
 
169
169
  it "returns itself" do
170
- subject.reload.should eql(subject)
170
+ expect(subject.reload).to eql(subject)
171
171
  end
172
172
 
173
173
  it "sets the attributes of self to include those of the reloaded object" do
174
174
  subject.reload
175
175
 
176
- subject.get_attribute(:fake_attribute).should eql("some_value")
176
+ expect(subject.get_attribute(:fake_attribute)).to eql("some_value")
177
177
  end
178
178
  end
179
179
  end