producer-core 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/ssh/config.feature +1 -0
- data/features/steps/etc_steps.rb +2 -4
- data/features/steps/execution_steps.rb +3 -0
- data/features/steps/output_steps.rb +23 -0
- data/features/steps/recipe_steps.rb +7 -7
- data/features/steps/remote_steps.rb +4 -4
- data/features/steps/ssh_steps.rb +1 -4
- data/features/support/env.rb +0 -16
- data/features/support/{env_cucumber-doc_string.rb → env_cucumber_doc_string.rb} +0 -0
- data/features/support/env_fake_home.rb +3 -0
- data/features/tests/env.feature +29 -1
- data/lib/producer/core/tests/has_env.rb +12 -1
- data/lib/producer/core/version.rb +1 -1
- data/spec/producer/core/tests/has_env_spec.rb +56 -22
- data/spec/producer/core/tests/has_executable_spec.rb +3 -3
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0948086dee94e6a1363c83af78cbc8fdec0c6d8
|
4
|
+
data.tar.gz: 6994469ae9fce4b8c7184545b453b3304555f648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e783aa0c29560a4c5f6f13c6ea5ab4367ca5031c2f5b766d351b8087bd64b0815deea04d355c0eb70a86a95db0b68076e2a9fb1aae405ca8e5a630635c547d90
|
7
|
+
data.tar.gz: c38e3b3445bbd59f58c0b8467fabf64c2a14c79b20aa9cbc6ca9586e1ba69d41bf84e3dc3e6bebb63d07e46ba5a8d301612318c7c93ae8443ee36d03e8793f22
|
data/features/ssh/config.feature
CHANGED
data/features/steps/etc_steps.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Then(/^the output should contain my current login name$/) do
|
4
|
-
assert_partial_output(Etc.getlogin, all_output)
|
1
|
+
Then /^the output must contain my current login name$/ do
|
2
|
+
assert_partial_output Etc.getlogin, all_output
|
5
3
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Then /^the output must match \/([^\/]+)\/$/ do |pattern|
|
2
|
+
assert_matching_output pattern, all_output
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^the output must contain "([^"]+)"$/ do |content|
|
6
|
+
assert_partial_output content, all_output
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the output must contain:$/ do |content|
|
10
|
+
assert_partial_output content, all_output
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^the output must not contain "([^"]+)"$/ do |content|
|
14
|
+
assert_no_partial_output content, all_output
|
15
|
+
end
|
16
|
+
|
17
|
+
Then /^the output must contain exactly "([^"]+)"$/ do |content|
|
18
|
+
assert_exact_output content, all_output
|
19
|
+
end
|
20
|
+
|
21
|
+
Then /^the output must contain exactly:$/ do |content|
|
22
|
+
assert_exact_output content, all_output
|
23
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
Given
|
1
|
+
Given /^a recipe with:$/ do |recipe_body|
|
2
2
|
write_file 'recipe.rb', recipe_body
|
3
3
|
end
|
4
4
|
|
5
|
-
When
|
6
|
-
run_simple
|
5
|
+
When /^I execute the recipe$/ do
|
6
|
+
run_simple 'producer recipe.rb', false
|
7
7
|
end
|
8
8
|
|
9
|
-
When
|
9
|
+
When /^I successfully execute the recipe$/ do
|
10
10
|
step 'I execute the recipe'
|
11
|
-
assert_exit_status
|
11
|
+
assert_exit_status 0
|
12
12
|
end
|
13
13
|
|
14
|
-
When
|
15
|
-
run_interactive
|
14
|
+
When /^I execute the recipe interactively$/ do
|
15
|
+
run_interactive 'producer recipe.rb'
|
16
16
|
end
|
@@ -10,14 +10,14 @@ Given /^a remote file named "([^"]+)" with "([^"]+)"$/ do |file_name, content|
|
|
10
10
|
write_file file_name, content
|
11
11
|
end
|
12
12
|
|
13
|
-
Then /^the remote directory "([^"]+)"
|
14
|
-
check_directory_presence
|
13
|
+
Then /^the remote directory "([^"]+)" must exists$/ do |path|
|
14
|
+
check_directory_presence [path], true
|
15
15
|
end
|
16
16
|
|
17
|
-
Then /^the remote file "([^"]+)"
|
17
|
+
Then /^the remote file "([^"]+)" must contain "([^"]+)"$/ do |path, content|
|
18
18
|
check_file_content path, content, true
|
19
19
|
end
|
20
20
|
|
21
|
-
Then /^the remote file "([^"]+)"
|
21
|
+
Then /^the remote file "([^"]+)" must contain exactly "([^"]+)"$/ do |path, content|
|
22
22
|
check_exact_file_content path, content
|
23
23
|
end
|
data/features/steps/ssh_steps.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
|
2
|
-
# a tag for features needing a fake home directory.
|
3
|
-
Given(/^an SSH config with:$/) do |config|
|
4
|
-
ENV['HOME'] = File.expand_path current_dir
|
1
|
+
Given /^an SSH config with:$/ do |config|
|
5
2
|
write_file '.ssh/config', config
|
6
3
|
end
|
data/features/support/env.rb
CHANGED
@@ -1,18 +1,2 @@
|
|
1
|
-
module Cucumber
|
2
|
-
class Runtime
|
3
|
-
alias :old_step_match :step_match
|
4
|
-
|
5
|
-
def step_match(step_name, name_to_report = nil)
|
6
|
-
if step_name.include? ' must '
|
7
|
-
name_to_report = step_name.dup
|
8
|
-
step_name.gsub! ' must ', ' should '
|
9
|
-
end
|
10
|
-
|
11
|
-
old_step_match(step_name, name_to_report)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
1
|
require 'aruba/cucumber'
|
17
|
-
|
18
2
|
require 'cucumber/sshd/cucumber'
|
File without changes
|
data/features/tests/env.feature
CHANGED
@@ -21,7 +21,35 @@ Feature: `env?' condition keyword
|
|
21
21
|
target 'some_host.test'
|
22
22
|
|
23
23
|
task :testing_env_var_definition do
|
24
|
-
condition { env? :
|
24
|
+
condition { env? :non_existent_var }
|
25
|
+
|
26
|
+
echo 'evaluated'
|
27
|
+
end
|
28
|
+
"""
|
29
|
+
When I successfully execute the recipe
|
30
|
+
Then the output must not contain "evaluated"
|
31
|
+
|
32
|
+
Scenario: succeeds when remote environment variable value match
|
33
|
+
Given a recipe with:
|
34
|
+
"""
|
35
|
+
target 'some_host.test'
|
36
|
+
|
37
|
+
task :testing_env_var_value do
|
38
|
+
condition { env? :shell, '/bin/sh' }
|
39
|
+
|
40
|
+
echo 'evaluated'
|
41
|
+
end
|
42
|
+
"""
|
43
|
+
When I successfully execute the recipe
|
44
|
+
Then the output must contain "evaluated"
|
45
|
+
|
46
|
+
Scenario: fails when remote environment variable value does not match
|
47
|
+
Given a recipe with:
|
48
|
+
"""
|
49
|
+
target 'some_host.test'
|
50
|
+
|
51
|
+
task :testing_env_var_value do
|
52
|
+
condition { env? :shell, 'non_existent_shell' }
|
25
53
|
|
26
54
|
echo 'evaluated'
|
27
55
|
end
|
@@ -3,7 +3,18 @@ module Producer
|
|
3
3
|
module Tests
|
4
4
|
class HasEnv < Test
|
5
5
|
def verify
|
6
|
-
|
6
|
+
case arguments.size
|
7
|
+
when 1
|
8
|
+
remote.environment.key? key
|
9
|
+
when 2
|
10
|
+
remote.environment[key] == arguments.last
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def key
|
17
|
+
arguments.first.to_s.upcase
|
7
18
|
end
|
8
19
|
end
|
9
20
|
end
|
@@ -3,37 +3,71 @@ require 'spec_helper'
|
|
3
3
|
module Producer::Core
|
4
4
|
module Tests
|
5
5
|
describe HasEnv do
|
6
|
-
let(:env)
|
7
|
-
let(:
|
8
|
-
|
6
|
+
let(:env) { Env.new }
|
7
|
+
let(:var_name) { 'SOME_VAR' }
|
8
|
+
let(:var_value) { 'SOME_VALUE' }
|
9
|
+
let(:remote_env) { { 'SOME_VAR' => 'SOME_VALUE' } }
|
10
|
+
subject(:has_env) { HasEnv.new(env, var_name) }
|
9
11
|
|
10
12
|
it_behaves_like 'test'
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
before do
|
15
|
+
allow(env.remote).to receive(:environment) { remote_env }
|
16
|
+
end
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
context 'when only var name is provided' do
|
19
|
+
describe '#verify' do
|
20
|
+
context 'when remote environment var is defined' do
|
21
|
+
it 'returns true' do
|
22
|
+
expect(has_env.verify).to be true
|
23
|
+
end
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
has_env.verify
|
22
|
-
end
|
25
|
+
context 'when var name is given as a lowercase symbol' do
|
26
|
+
let(:var_name) { :some_var }
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
it 'returns true' do
|
29
|
+
expect(has_env.verify).to be true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when remote environment var is not defined' do
|
35
|
+
let(:var_name) { 'SOME_NON_EXISTENT_VAR' }
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
|
37
|
+
it 'returns false' do
|
38
|
+
expect(has_env.verify).to be false
|
39
|
+
end
|
40
|
+
end
|
32
41
|
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when var name and value are provided' do
|
45
|
+
subject(:has_env) { HasEnv.new(env, var_name, var_value) }
|
46
|
+
|
47
|
+
describe '#verify' do
|
48
|
+
context 'when remote environment var is defined' do
|
49
|
+
context 'when value is the same' do
|
50
|
+
it 'returns true' do
|
51
|
+
expect(has_env.verify).to be true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when value differs' do
|
56
|
+
let(:remote_env) { { 'SOME_VAR' => 'SOME_OTHER_VALUE' } }
|
57
|
+
|
58
|
+
it 'return false' do
|
59
|
+
expect(has_env.verify).to be false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when remote environment var is not defined' do
|
65
|
+
let(:var_name) { 'SOME_NON_EXISTENT_VAR' }
|
33
66
|
|
34
|
-
|
35
|
-
|
36
|
-
|
67
|
+
it 'return false' do
|
68
|
+
expect(has_env.verify).to be false
|
69
|
+
end
|
70
|
+
end
|
37
71
|
end
|
38
72
|
end
|
39
73
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Producer::Core
|
4
4
|
module Tests
|
5
5
|
describe HasExecutable, :env do
|
6
|
-
subject(:
|
6
|
+
subject(:test) { HasExecutable.new(env, executable) }
|
7
7
|
|
8
8
|
it_behaves_like 'test'
|
9
9
|
|
@@ -12,7 +12,7 @@ module Producer::Core
|
|
12
12
|
let(:executable) { 'true' }
|
13
13
|
|
14
14
|
it 'returns true' do
|
15
|
-
expect(
|
15
|
+
expect(test.verify).to be true
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -20,7 +20,7 @@ module Producer::Core
|
|
20
20
|
let(:executable) { 'some_non_existent_executable' }
|
21
21
|
|
22
22
|
it 'returns false' do
|
23
|
-
expect(
|
23
|
+
expect(test.verify).to be false
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: producer-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
@@ -137,11 +137,14 @@ files:
|
|
137
137
|
- features/recipes/target.feature
|
138
138
|
- features/ssh/config.feature
|
139
139
|
- features/steps/etc_steps.rb
|
140
|
+
- features/steps/execution_steps.rb
|
141
|
+
- features/steps/output_steps.rb
|
140
142
|
- features/steps/recipe_steps.rb
|
141
143
|
- features/steps/remote_steps.rb
|
142
144
|
- features/steps/ssh_steps.rb
|
143
145
|
- features/support/env.rb
|
144
|
-
- features/support/
|
146
|
+
- features/support/env_cucumber_doc_string.rb
|
147
|
+
- features/support/env_fake_home.rb
|
145
148
|
- features/tasks/condition.feature
|
146
149
|
- features/tasks/evaluation.feature
|
147
150
|
- features/tasks/registry.feature
|
@@ -262,11 +265,14 @@ test_files:
|
|
262
265
|
- features/recipes/target.feature
|
263
266
|
- features/ssh/config.feature
|
264
267
|
- features/steps/etc_steps.rb
|
268
|
+
- features/steps/execution_steps.rb
|
269
|
+
- features/steps/output_steps.rb
|
265
270
|
- features/steps/recipe_steps.rb
|
266
271
|
- features/steps/remote_steps.rb
|
267
272
|
- features/steps/ssh_steps.rb
|
268
273
|
- features/support/env.rb
|
269
|
-
- features/support/
|
274
|
+
- features/support/env_cucumber_doc_string.rb
|
275
|
+
- features/support/env_fake_home.rb
|
270
276
|
- features/tasks/condition.feature
|
271
277
|
- features/tasks/evaluation.feature
|
272
278
|
- features/tasks/registry.feature
|