producer-core 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/features/{actions/echo.feature → action_echo.feature} +1 -1
  3. data/features/{actions/file_append.feature → action_file_append.feature} +1 -1
  4. data/features/{actions/file_replace_content.feature → action_file_replace_content.feature} +11 -14
  5. data/features/{actions/file_write.feature → action_file_write.feature} +7 -12
  6. data/features/{actions/mkdir.feature → action_mkdir.feature} +8 -13
  7. data/features/{actions/sh.feature → action_sh.feature} +14 -14
  8. data/features/{cli/dry_run.feature → cli_dry_run.feature} +0 -0
  9. data/features/{cli/usage.feature → cli_usage.feature} +1 -0
  10. data/features/{cli/verbose.feature → cli_verbose.feature} +12 -23
  11. data/features/{recipes/ask.feature → recipe_ask.feature} +1 -0
  12. data/features/{recipes/macro.feature → recipe_macro.feature} +4 -4
  13. data/features/{recipes/source.feature → recipe_source.feature} +3 -1
  14. data/features/{recipes/target.feature → recipe_target.feature} +3 -1
  15. data/features/recipe_test_macro.feature +52 -0
  16. data/features/{recipes/registry.feature → registry.feature} +9 -4
  17. data/features/{ssh/config.feature → ssh_config.feature} +3 -1
  18. data/features/support/env.rb +32 -0
  19. data/features/support/env_aruba_timeout.rb +3 -0
  20. data/features/{tasks/condition.feature → task_condition.feature} +1 -1
  21. data/features/{tests/dir.feature → test_dir.feature} +1 -1
  22. data/features/{tests/env.feature → test_env.feature} +24 -34
  23. data/features/{tests/executable.feature → test_executable.feature} +12 -14
  24. data/features/{tests/file.feature → test_file.feature} +1 -1
  25. data/features/{tests/file_contains.feature → test_file_contains.feature} +1 -1
  26. data/features/{tests/negated_test.feature → test_negated_test.feature} +0 -0
  27. data/features/test_shell_command_status.feature +48 -0
  28. data/lib/producer/core/cli.rb +19 -15
  29. data/lib/producer/core/condition/dsl.rb +17 -8
  30. data/lib/producer/core/condition.rb +2 -2
  31. data/lib/producer/core/env.rb +6 -10
  32. data/lib/producer/core/errors.rb +2 -1
  33. data/lib/producer/core/recipe/dsl.rb +4 -0
  34. data/lib/producer/core/remote.rb +1 -1
  35. data/lib/producer/core/tests/condition_test.rb +23 -0
  36. data/lib/producer/core/version.rb +1 -1
  37. data/lib/producer/core.rb +1 -0
  38. data/spec/producer/core/cli_spec.rb +73 -44
  39. data/spec/producer/core/condition/dsl_spec.rb +33 -5
  40. data/spec/producer/core/env_spec.rb +41 -36
  41. data/spec/producer/core/recipe/dsl_spec.rb +10 -0
  42. data/spec/producer/core/remote_spec.rb +16 -7
  43. data/spec/producer/core/tests/condition_test_spec.rb +55 -0
  44. metadata +56 -55
  45. data/features/recipes/evaluation.feature +0 -9
  46. data/features/tasks/evaluation.feature +0 -11
  47. data/features/tasks/registry.feature +0 -13
  48. data/features/tests/shell_command_status.feature +0 -58
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ module Producer::Core
4
+ module Tests
5
+ describe ConditionTest do
6
+ let(:env) { double 'env' }
7
+ let(:block) { proc { true } }
8
+ let(:arguments) { [:some, :args] }
9
+ subject(:test) { described_class.new(env, block, *arguments) }
10
+
11
+ it_behaves_like 'test'
12
+
13
+ describe '#verify' do
14
+ context 'when condition is met' do
15
+ it 'returns true' do
16
+ expect(test.verify).to be true
17
+ end
18
+ end
19
+
20
+ context 'when condition is not met' do
21
+ let(:block) { proc { false } }
22
+
23
+ it 'returns false' do
24
+ expect(test.verify).to be false
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '#condition' do
30
+ it 'evaluates a conditon' do
31
+ expect(Condition).to receive(:evaluate).with(env, *arguments, &block)
32
+ test.condition
33
+ end
34
+
35
+ it 'returns the evaluated condition' do
36
+ condition = double 'condition'
37
+ allow(Condition).to receive(:evaluate) { condition }
38
+ expect(test.condition).to eq condition
39
+ end
40
+ end
41
+
42
+ describe '#condition_args' do
43
+ it 'returns arguments for condition' do
44
+ expect(test.condition_args).to eq arguments
45
+ end
46
+ end
47
+
48
+ describe '#condition_block' do
49
+ it 'returns condition block' do
50
+ expect(test.condition_block).to eq block
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: producer-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-25 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -122,22 +122,22 @@ files:
122
122
  - LICENSE
123
123
  - Rakefile
124
124
  - bin/producer
125
- - features/actions/echo.feature
126
- - features/actions/file_append.feature
127
- - features/actions/file_replace_content.feature
128
- - features/actions/file_write.feature
129
- - features/actions/mkdir.feature
130
- - features/actions/sh.feature
131
- - features/cli/dry_run.feature
132
- - features/cli/usage.feature
133
- - features/cli/verbose.feature
134
- - features/recipes/ask.feature
135
- - features/recipes/evaluation.feature
136
- - features/recipes/macro.feature
137
- - features/recipes/registry.feature
138
- - features/recipes/source.feature
139
- - features/recipes/target.feature
140
- - features/ssh/config.feature
125
+ - features/action_echo.feature
126
+ - features/action_file_append.feature
127
+ - features/action_file_replace_content.feature
128
+ - features/action_file_write.feature
129
+ - features/action_mkdir.feature
130
+ - features/action_sh.feature
131
+ - features/cli_dry_run.feature
132
+ - features/cli_usage.feature
133
+ - features/cli_verbose.feature
134
+ - features/recipe_ask.feature
135
+ - features/recipe_macro.feature
136
+ - features/recipe_source.feature
137
+ - features/recipe_target.feature
138
+ - features/recipe_test_macro.feature
139
+ - features/registry.feature
140
+ - features/ssh_config.feature
141
141
  - features/steps/etc_steps.rb
142
142
  - features/steps/execution_steps.rb
143
143
  - features/steps/output_steps.rb
@@ -145,18 +145,17 @@ files:
145
145
  - features/steps/remote_steps.rb
146
146
  - features/steps/ssh_steps.rb
147
147
  - features/support/env.rb
148
+ - features/support/env_aruba_timeout.rb
148
149
  - features/support/env_cucumber_doc_string.rb
149
150
  - features/support/env_fake_home.rb
150
- - features/tasks/condition.feature
151
- - features/tasks/evaluation.feature
152
- - features/tasks/registry.feature
153
- - features/tests/dir.feature
154
- - features/tests/env.feature
155
- - features/tests/executable.feature
156
- - features/tests/file.feature
157
- - features/tests/file_contains.feature
158
- - features/tests/negated_test.feature
159
- - features/tests/shell_command_status.feature
151
+ - features/task_condition.feature
152
+ - features/test_dir.feature
153
+ - features/test_env.feature
154
+ - features/test_executable.feature
155
+ - features/test_file.feature
156
+ - features/test_file_contains.feature
157
+ - features/test_negated_test.feature
158
+ - features/test_shell_command_status.feature
160
159
  - lib/producer/core.rb
161
160
  - lib/producer/core/action.rb
162
161
  - lib/producer/core/actions/echo.rb
@@ -182,6 +181,7 @@ files:
182
181
  - lib/producer/core/test.rb
183
182
  - lib/producer/core/testing.rb
184
183
  - lib/producer/core/testing/mock_remote.rb
184
+ - lib/producer/core/tests/condition_test.rb
185
185
  - lib/producer/core/tests/file_contains.rb
186
186
  - lib/producer/core/tests/has_dir.rb
187
187
  - lib/producer/core/tests/has_env.rb
@@ -216,6 +216,7 @@ files:
216
216
  - spec/producer/core/task_spec.rb
217
217
  - spec/producer/core/test_spec.rb
218
218
  - spec/producer/core/testing/mock_remote_spec.rb
219
+ - spec/producer/core/tests/condition_test_spec.rb
219
220
  - spec/producer/core/tests/file_contains_spec.rb
220
221
  - spec/producer/core/tests/has_dir_spec.rb
221
222
  - spec/producer/core/tests/has_env_spec.rb
@@ -249,27 +250,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
250
  version: '0'
250
251
  requirements: []
251
252
  rubyforge_project:
252
- rubygems_version: 2.2.2
253
+ rubygems_version: 2.4.5
253
254
  signing_key:
254
255
  specification_version: 4
255
256
  summary: Provisioning tool
256
257
  test_files:
257
- - features/actions/echo.feature
258
- - features/actions/file_append.feature
259
- - features/actions/file_replace_content.feature
260
- - features/actions/file_write.feature
261
- - features/actions/mkdir.feature
262
- - features/actions/sh.feature
263
- - features/cli/dry_run.feature
264
- - features/cli/usage.feature
265
- - features/cli/verbose.feature
266
- - features/recipes/ask.feature
267
- - features/recipes/evaluation.feature
268
- - features/recipes/macro.feature
269
- - features/recipes/registry.feature
270
- - features/recipes/source.feature
271
- - features/recipes/target.feature
272
- - features/ssh/config.feature
258
+ - features/action_echo.feature
259
+ - features/action_file_append.feature
260
+ - features/action_file_replace_content.feature
261
+ - features/action_file_write.feature
262
+ - features/action_mkdir.feature
263
+ - features/action_sh.feature
264
+ - features/cli_dry_run.feature
265
+ - features/cli_usage.feature
266
+ - features/cli_verbose.feature
267
+ - features/recipe_ask.feature
268
+ - features/recipe_macro.feature
269
+ - features/recipe_source.feature
270
+ - features/recipe_target.feature
271
+ - features/recipe_test_macro.feature
272
+ - features/registry.feature
273
+ - features/ssh_config.feature
273
274
  - features/steps/etc_steps.rb
274
275
  - features/steps/execution_steps.rb
275
276
  - features/steps/output_steps.rb
@@ -277,18 +278,17 @@ test_files:
277
278
  - features/steps/remote_steps.rb
278
279
  - features/steps/ssh_steps.rb
279
280
  - features/support/env.rb
281
+ - features/support/env_aruba_timeout.rb
280
282
  - features/support/env_cucumber_doc_string.rb
281
283
  - features/support/env_fake_home.rb
282
- - features/tasks/condition.feature
283
- - features/tasks/evaluation.feature
284
- - features/tasks/registry.feature
285
- - features/tests/dir.feature
286
- - features/tests/env.feature
287
- - features/tests/executable.feature
288
- - features/tests/file.feature
289
- - features/tests/file_contains.feature
290
- - features/tests/negated_test.feature
291
- - features/tests/shell_command_status.feature
284
+ - features/task_condition.feature
285
+ - features/test_dir.feature
286
+ - features/test_env.feature
287
+ - features/test_executable.feature
288
+ - features/test_file.feature
289
+ - features/test_file_contains.feature
290
+ - features/test_negated_test.feature
291
+ - features/test_shell_command_status.feature
292
292
  - spec/fixtures/recipes/empty.rb
293
293
  - spec/fixtures/recipes/some_recipe.rb
294
294
  - spec/fixtures/recipes/throw.rb
@@ -314,6 +314,7 @@ test_files:
314
314
  - spec/producer/core/task_spec.rb
315
315
  - spec/producer/core/test_spec.rb
316
316
  - spec/producer/core/testing/mock_remote_spec.rb
317
+ - spec/producer/core/tests/condition_test_spec.rb
317
318
  - spec/producer/core/tests/file_contains_spec.rb
318
319
  - spec/producer/core/tests/has_dir_spec.rb
319
320
  - spec/producer/core/tests/has_env_spec.rb
@@ -1,9 +0,0 @@
1
- Feature: recipe evaluation
2
-
3
- Scenario: evaluates ruby code in a recipe
4
- Given a recipe with:
5
- """
6
- puts 'hello from recipe'
7
- """
8
- When I successfully execute the recipe
9
- Then the output must contain exactly "hello from recipe\n"
@@ -1,11 +0,0 @@
1
- Feature: task evaluation
2
-
3
- Scenario: evaluates ruby code in task blocks
4
- Given a recipe with:
5
- """
6
- task :hello do
7
- puts 'hello from recipe'
8
- end
9
- """
10
- When I successfully execute the recipe
11
- Then the output must contain exactly "hello from recipe\n"
@@ -1,13 +0,0 @@
1
- Feature: access to registry from task DSL
2
-
3
- Scenario: `get' keyword fetches a value from the registry
4
- Given a recipe with:
5
- """
6
- set :some_key, 'some_value'
7
-
8
- task :output_some_key do
9
- echo get :some_key
10
- end
11
- """
12
- When I successfully execute the recipe
13
- Then the output must contain "some_value"
@@ -1,58 +0,0 @@
1
- @sshd
2
- Feature: `` condition keyword
3
-
4
- Scenario: succeeds when remote command execution is a success
5
- Given a recipe with:
6
- """
7
- target 'some_host.test'
8
-
9
- task :testing_remote_command do
10
- condition { `true` }
11
-
12
- echo 'evaluated'
13
- end
14
- """
15
- When I successfully execute the recipe
16
- Then the output must contain "evaluated"
17
-
18
- Scenario: succeeds when remote executable is available
19
- Given a recipe with:
20
- """
21
- target 'some_host.test'
22
-
23
- task :testing_remote_command do
24
- condition { `false` }
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: `sh' alias, succeeds when remote executable is available
33
- Given a recipe with:
34
- """
35
- target 'some_host.test'
36
-
37
- task :testing_remote_command do
38
- condition { sh 'false' }
39
-
40
- echo 'evaluated'
41
- end
42
- """
43
- When I successfully execute the recipe
44
- Then the output must not contain "evaluated"
45
-
46
- Scenario: succeeds when remote executable is available
47
- Given a recipe with:
48
- """
49
- target 'some_host.test'
50
-
51
- task :testing_remote_command do
52
- condition { sh 'false' }
53
-
54
- echo 'evaluated'
55
- end
56
- """
57
- When I successfully execute the recipe
58
- Then the output must not contain "evaluated"