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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efce6312a8a297ea13fb953ca8f082610a4c629c
4
- data.tar.gz: 87ed5ba505ff874af45ae009b4a69f9f0226a708
3
+ metadata.gz: b0948086dee94e6a1363c83af78cbc8fdec0c6d8
4
+ data.tar.gz: 6994469ae9fce4b8c7184545b453b3304555f648
5
5
  SHA512:
6
- metadata.gz: 8fedb8c256e59d211b3b5dbd3af122d896c298e7b6bba7a7a0bab4467f06b54c2b2facaf5c6616d75ab43bbe7568b61e338b62e2feb30724f63653bcc53b2d2d
7
- data.tar.gz: 4bdae0fd686786ea6f6e5b4d18d8a5449f0f127bb4e64d543500082c31351c0e990f31ddf95fc75c10ea25bc8168e30eeb78c1fb65504c8c23438d13d38cbb23
6
+ metadata.gz: e783aa0c29560a4c5f6f13c6ea5ab4367ca5031c2f5b766d351b8087bd64b0815deea04d355c0eb70a86a95db0b68076e2a9fb1aae405ca8e5a630635c547d90
7
+ data.tar.gz: c38e3b3445bbd59f58c0b8467fabf64c2a14c79b20aa9cbc6ca9586e1ba69d41bf84e3dc3e6bebb63d07e46ba5a8d301612318c7c93ae8443ee36d03e8793f22
@@ -12,6 +12,7 @@ Feature: SSH settings
12
12
  When I successfully execute the recipe
13
13
  Then the output must contain my current login name
14
14
 
15
+ @fake_home
15
16
  Scenario: uses configured SSH user name for a given host
16
17
  Given an SSH config with:
17
18
  """
@@ -1,5 +1,3 @@
1
- # FIXME: our monkey patch currently prevent us from using `must' in step
2
- # definitions.
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,3 @@
1
+ Then /^the exit status must be (\d+)$/ do |exit_status|
2
+ assert_exit_status exit_status.to_i
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(/^a recipe with:$/) do |recipe_body|
1
+ Given /^a recipe with:$/ do |recipe_body|
2
2
  write_file 'recipe.rb', recipe_body
3
3
  end
4
4
 
5
- When(/^I execute the recipe$/) do
6
- run_simple('producer recipe.rb', false)
5
+ When /^I execute the recipe$/ do
6
+ run_simple 'producer recipe.rb', false
7
7
  end
8
8
 
9
- When(/^I successfully execute the recipe$/) do
9
+ When /^I successfully execute the recipe$/ do
10
10
  step 'I execute the recipe'
11
- assert_exit_status(0)
11
+ assert_exit_status 0
12
12
  end
13
13
 
14
- When(/^I execute the recipe interactively$/) do
15
- run_interactive('producer recipe.rb')
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 "([^"]+)" should exists$/ do |path|
14
- check_directory_presence([path], true)
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 "([^"]+)" should contain "([^"]+)"/ do |path, content|
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 "([^"]+)" should contain exactly "([^"]+)"/ do |path, content|
21
+ Then /^the remote file "([^"]+)" must contain exactly "([^"]+)"$/ do |path, content|
22
22
  check_exact_file_content path, content
23
23
  end
@@ -1,6 +1,3 @@
1
- # FIXME: current home directory shouldn't be changed here, maybe we should use
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
@@ -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'
@@ -0,0 +1,3 @@
1
+ Before('@fake_home') do
2
+ ENV['HOME'] = File.expand_path(current_dir)
3
+ end
@@ -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? :inexistent_var }
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
- remote.environment.key? arguments.first.to_s.upcase
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
@@ -1,5 +1,5 @@
1
1
  module Producer
2
2
  module Core
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  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) { Env.new }
7
- let(:variable_name) { :some_variable_name }
8
- subject(:has_env) { HasEnv.new(env, variable_name) }
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
- describe '#verify' do
13
- let(:environment) { double 'environment' }
14
+ before do
15
+ allow(env.remote).to receive(:environment) { remote_env }
16
+ end
14
17
 
15
- before do
16
- allow(env.remote).to receive(:environment) { environment }
17
- end
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
- it 'stringifies the queried variable name' do
20
- expect(environment).to receive(:key?).with(kind_of(String))
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
- it 'upcases the queried variable name' do
25
- expect(environment).to receive(:key?).with('SOME_VARIABLE_NAME')
26
- has_env.verify
27
- end
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
- it 'returns true when remote environment var is defined' do
30
- allow(environment).to receive(:key?) { true }
31
- expect(has_env.verify).to be true
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
- it 'returns false when remote environment var is not defined' do
35
- allow(environment).to receive(:key?) { false }
36
- expect(has_env.verify).to be false
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(:has_env) { HasExecutable.new(env, executable) }
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(has_env.verify).to be true
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(has_env.verify).to be false
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.1
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/env_cucumber-doc_string.rb
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/env_cucumber-doc_string.rb
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