ridley 4.0.0 → 4.3.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/Rakefile +1 -0
- data/lib/ridley/chef/config.rb +5 -5
- data/lib/ridley/chef/cookbook/metadata.rb +59 -14
- data/lib/ridley/chef/cookbook/syntax_check.rb +57 -19
- data/lib/ridley/chef/cookbook.rb +1 -1
- data/lib/ridley/chef/digester.rb +3 -1
- data/lib/ridley/client.rb +6 -3
- data/lib/ridley/connection.rb +5 -4
- data/lib/ridley/errors.rb +1 -0
- data/lib/ridley/helpers.rb +10 -0
- data/lib/ridley/mixin/params_validate.rb +4 -0
- data/lib/ridley/resources/cookbook_resource.rb +14 -2
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +5 -5
- data/spec/acceptance/client_resource_spec.rb +12 -12
- data/spec/acceptance/cookbook_resource_spec.rb +15 -15
- data/spec/acceptance/data_bag_item_resource_spec.rb +14 -14
- data/spec/acceptance/data_bag_resource_spec.rb +4 -4
- data/spec/acceptance/environment_resource_spec.rb +14 -14
- data/spec/acceptance/node_resource_spec.rb +15 -15
- data/spec/acceptance/role_resource_spec.rb +14 -14
- data/spec/acceptance/sandbox_resource_spec.rb +3 -3
- data/spec/acceptance/search_resource_spec.rb +6 -6
- data/spec/acceptance/user_resource_spec.rb +21 -21
- data/spec/support/each_matcher.rb +2 -2
- data/spec/support/filepath_matchers.rb +2 -2
- data/spec/support/shared_examples/ridley_resource.rb +39 -39
- data/spec/unit/ridley/chef/cookbook/metadata_spec.rb +8 -8
- data/spec/unit/ridley/chef/cookbook/syntax_check_spec.rb +15 -15
- data/spec/unit/ridley/chef/cookbook_spec.rb +159 -114
- data/spec/unit/ridley/chef/digester_spec.rb +2 -2
- data/spec/unit/ridley/chef_object_spec.rb +35 -35
- data/spec/unit/ridley/chef_objects/client_object_spec.rb +2 -2
- data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +12 -12
- data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +7 -7
- data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +4 -1
- data/spec/unit/ridley/chef_objects/environment_object_spec.rb +10 -10
- data/spec/unit/ridley/chef_objects/node_object_spec.rb +28 -28
- data/spec/unit/ridley/chef_objects/role_object_spec.rb +10 -10
- data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +6 -6
- data/spec/unit/ridley/client_spec.rb +59 -21
- data/spec/unit/ridley/connection_spec.rb +7 -7
- data/spec/unit/ridley/errors_spec.rb +3 -3
- data/spec/unit/ridley/middleware/chef_auth_spec.rb +2 -2
- data/spec/unit/ridley/middleware/chef_response_spec.rb +29 -29
- data/spec/unit/ridley/middleware/parse_json_spec.rb +14 -14
- data/spec/unit/ridley/mixins/from_file_spec.rb +3 -3
- data/spec/unit/ridley/resource_spec.rb +5 -5
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +21 -21
- data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/data_bag_resource_spec.rb +6 -3
- data/spec/unit/ridley/resources/environment_resource_spec.rb +4 -4
- data/spec/unit/ridley/resources/role_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/sandbox_resource_spec.rb +7 -7
- data/spec/unit/ridley/resources/search_resource_spec.rb +22 -22
- data/spec/unit/ridley/sandbox_uploader_spec.rb +3 -3
- data/spec/unit/ridley_spec.rb +6 -6
- metadata +62 -64
- data/.ruby-version +0 -1
- data/lib/ridley/middleware/gzip.rb +0 -18
- data/spec/unit/ridley/middleware/gzip_spec.rb +0 -59
|
@@ -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").
|
|
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").
|
|
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").
|
|
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.
|
|
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.
|
|
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").
|
|
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").
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
111
|
-
expect(connection.user.find('reset').authenticate('not a swordfish')).to
|
|
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
|
|
121
|
-
expect(subject.authenticate('salmon')).to
|
|
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
|
|
127
|
-
expect(subject.authenticate('salmon')).to
|
|
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.
|
|
5
|
+
expect(index).to check
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
13
|
-
client.connection.
|
|
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.
|
|
23
|
-
client.connection.
|
|
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.
|
|
37
|
-
client.connection.
|
|
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.
|
|
46
|
-
client.connection.
|
|
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.
|
|
54
|
-
response.
|
|
55
|
-
client.connection.
|
|
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
|
-
|
|
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.
|
|
69
|
+
allow(subject).to receive(:chef_id) { :name }
|
|
70
70
|
subject.attribute(:name)
|
|
71
71
|
object = subject.new(name: "hello")
|
|
72
|
-
response.
|
|
73
|
-
client.connection.
|
|
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.
|
|
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.
|
|
89
|
-
subject.class.
|
|
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.
|
|
98
|
-
updated.
|
|
99
|
-
subject.class.
|
|
100
|
-
subject.
|
|
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.
|
|
108
|
+
before(:each) { allow(subject).to receive(:valid?).and_return(false) }
|
|
109
109
|
|
|
110
110
|
it "raises an InvalidResource error" do
|
|
111
|
-
|
|
111
|
+
expect {
|
|
112
112
|
subject.save
|
|
113
|
-
}.
|
|
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.
|
|
123
|
-
updated.
|
|
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.
|
|
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.
|
|
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.
|
|
136
|
-
subject.update.
|
|
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.
|
|
141
|
+
before(:each) { allow(subject).to receive(:valid?).and_return(false) }
|
|
142
142
|
|
|
143
143
|
it "raises an InvalidResource error" do
|
|
144
|
-
|
|
144
|
+
expect {
|
|
145
145
|
subject.update
|
|
146
|
-
}.
|
|
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.
|
|
154
|
+
allow(subject.class).to receive(:chef_id) { :name }
|
|
155
155
|
subject.mass_assign(name: "reset")
|
|
156
156
|
|
|
157
|
-
subject.chef_id.
|
|
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.
|
|
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.
|
|
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).
|
|
176
|
+
expect(subject.get_attribute(:fake_attribute)).to eql("some_value")
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
end
|
|
@@ -17,36 +17,36 @@ describe Ridley::Chef::Cookbook::Metadata do
|
|
|
17
17
|
:choice => [ "test1", "test2" ],
|
|
18
18
|
:default => "test1"
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
expect {
|
|
21
21
|
subject.attribute("test_cookbook/test", options)
|
|
22
|
-
}.
|
|
22
|
+
}.not_to raise_error
|
|
23
23
|
|
|
24
24
|
options = {
|
|
25
25
|
:type => "boolean",
|
|
26
26
|
:choice => [ true, false ],
|
|
27
27
|
:default => true
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
expect {
|
|
30
30
|
subject.attribute("test_cookbook/test", options)
|
|
31
|
-
}.
|
|
31
|
+
}.not_to raise_error
|
|
32
32
|
|
|
33
33
|
options = {
|
|
34
34
|
:type => "numeric",
|
|
35
35
|
:choice => [ 1337, 420 ],
|
|
36
36
|
:default => 1337
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
expect {
|
|
39
39
|
subject.attribute("test_cookbook/test", options)
|
|
40
|
-
}.
|
|
40
|
+
}.not_to raise_error
|
|
41
41
|
|
|
42
42
|
options = {
|
|
43
43
|
:type => "numeric",
|
|
44
44
|
:choice => [ true, "false" ],
|
|
45
45
|
:default => false
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
expect {
|
|
48
48
|
subject.attribute("test_cookbook/test", options)
|
|
49
|
-
}.
|
|
49
|
+
}.to raise_error
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -12,7 +12,7 @@ describe Ridley::Chef::Cookbook::SyntaxCheck do
|
|
|
12
12
|
subject { syntax_check }
|
|
13
13
|
|
|
14
14
|
before(:each) do
|
|
15
|
-
subject.
|
|
15
|
+
allow(subject).to receive(:chefignore) { chefignore }
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
describe "#ruby_files" do
|
|
@@ -55,7 +55,7 @@ describe Ridley::Chef::Cookbook::SyntaxCheck do
|
|
|
55
55
|
it "checks if a file has already been validated" do
|
|
56
56
|
valid_template_file = cookbook_dir.join("templates/default/temp.txt.erb").to_s
|
|
57
57
|
subject.validated(valid_template_file)
|
|
58
|
-
expect(subject.validated?(valid_template_file)).to
|
|
58
|
+
expect(subject.validated?(valid_template_file)).to be_truthy
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -63,7 +63,7 @@ describe Ridley::Chef::Cookbook::SyntaxCheck do
|
|
|
63
63
|
let(:validated_files) { double('validated_files') }
|
|
64
64
|
|
|
65
65
|
before(:each) do
|
|
66
|
-
subject.
|
|
66
|
+
allow(subject).to receive(:validated_files) { validated_files }
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "records a file as validated" do
|
|
@@ -77,35 +77,35 @@ describe Ridley::Chef::Cookbook::SyntaxCheck do
|
|
|
77
77
|
|
|
78
78
|
describe "#validate_ruby_files" do
|
|
79
79
|
it "asks #untested_ruby_files for a list of files and calls #validate_ruby_file on each" do
|
|
80
|
-
subject.
|
|
81
|
-
expect(subject.validate_ruby_files).to
|
|
80
|
+
allow(subject).to receive(:validate_ruby_file).with(anything()).exactly(9).times { true }
|
|
81
|
+
expect(subject.validate_ruby_files).to be_truthy
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it "marks the successfully validated ruby files" do
|
|
85
|
-
subject.
|
|
86
|
-
expect(subject.validate_ruby_files).to
|
|
85
|
+
allow(subject).to receive(:validated).with(anything()).exactly(9).times
|
|
86
|
+
expect(subject.validate_ruby_files).to be_truthy
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
it "returns false if any ruby file fails to validate" do
|
|
90
|
-
subject.
|
|
91
|
-
expect(subject.validate_ruby_files).to
|
|
90
|
+
allow(subject).to receive(:validate_ruby_file).with(/\.rb$/) { false }
|
|
91
|
+
expect(subject.validate_ruby_files).to be_falsey
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
describe "#validate_templates" do
|
|
96
96
|
it "asks #untested_template_files for a list of erb files and calls #validate_template on each" do
|
|
97
|
-
subject.
|
|
98
|
-
expect(subject.validate_templates).to
|
|
97
|
+
allow(subject).to receive(:validate_template).with(anything()).exactly(9).times { true }
|
|
98
|
+
expect(subject.validate_templates).to be_truthy
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "marks the successfully validated erb files" do
|
|
102
|
-
subject.
|
|
103
|
-
expect(subject.validate_templates).to
|
|
102
|
+
allow(subject).to receive(:validated).with(anything()).exactly(9).times
|
|
103
|
+
expect(subject.validate_templates).to be_truthy
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
it "returns false if any erb file fails to validate" do
|
|
107
|
-
subject.
|
|
108
|
-
expect(subject.validate_templates).to
|
|
107
|
+
allow(subject).to receive(:validate_template).with(/\.erb$/) { false }
|
|
108
|
+
expect(subject.validate_templates).to be_falsey
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
|