producer-core 0.1.15 → 0.1.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54159e4f77534537d3907df5c163f8625a10eee2
4
- data.tar.gz: 4477e96cb8863e4a8b1f192cbbf72d134cc58a5b
3
+ metadata.gz: 153b05ea6e95f6d5581779768786fe976302d410
4
+ data.tar.gz: 9be25d6883039b45ffe56000aa0b1c759ca907a0
5
5
  SHA512:
6
- metadata.gz: f5c973e21cba0028b335e65b7e15907196347065bb44a16fef4a5cdc765c0e0f49b9145c17b2aa1cdd753f7f9df746bc4b9a6e200020082631e93a4656e04eab
7
- data.tar.gz: 9b21fd80402af11295d8f4b5087890e4d017d6ae75aa416b6cdc900b5d729bf58a4eb35d839b2d25f3ce1137abed8704e786e278cfc16c357d2a5eb63eece882
6
+ metadata.gz: 66029273ccafd41676b00d72f780f97a0cc19d60c52e467b041ef4c8955da96c86a802cabee060f1aff1059ab52f5a557a978edbae1a0fce27dd85c2db4c5aec
7
+ data.tar.gz: d28e5dddf8927383e725d17374de508619e6df622aff7e78e8718aff7d4834ba33c6daa5af87db2643961ee2acfb1d8d060262bf36a41d620d58acd6f7341ac1
@@ -0,0 +1,30 @@
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"
@@ -13,6 +13,7 @@ module Producer
13
13
  end
14
14
  end
15
15
 
16
+ define_test :`, Tests::ShellCommandStatus
16
17
  define_test :file_contains, Tests::FileContains
17
18
  define_test :has_env, Tests::HasEnv
18
19
  define_test :has_executable, Tests::HasExecutable
@@ -0,0 +1,18 @@
1
+ module Producer
2
+ module Core
3
+ module Tests
4
+ class ShellCommandStatus < Test
5
+ def verify
6
+ remote.execute(command)
7
+ true
8
+ rescue RemoteCommandExecutionError
9
+ false
10
+ end
11
+
12
+ def command
13
+ arguments.first
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  module Producer
2
2
  module Core
3
- VERSION = '0.1.15'
3
+ VERSION = '0.1.16'
4
4
  end
5
5
  end
data/lib/producer/core.rb CHANGED
@@ -21,6 +21,7 @@ require 'producer/core/tests/has_dir'
21
21
  require 'producer/core/tests/has_env'
22
22
  require 'producer/core/tests/has_executable'
23
23
  require 'producer/core/tests/has_file'
24
+ require 'producer/core/tests/shell_command_status'
24
25
 
25
26
  require 'producer/core/cli'
26
27
  require 'producer/core/condition'
@@ -8,6 +8,7 @@ module Producer::Core
8
8
  subject(:dsl) { DSL.new(env, &block) }
9
9
 
10
10
  %w[
11
+ `
11
12
  file_contains
12
13
  has_dir
13
14
  has_env
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ module Producer::Core
4
+ module Tests
5
+ describe ShellCommandStatus, :env do
6
+ let(:command) { 'true' }
7
+ subject(:test) { described_class.new(env, command) }
8
+
9
+ it_behaves_like 'test'
10
+
11
+ describe '#verify' do
12
+ context 'command return status is 0' do
13
+ it 'returns true' do
14
+ expect(test.verify).to be true
15
+ end
16
+ end
17
+
18
+ context 'command return status is not 0' do
19
+ let(:command) { 'false' }
20
+
21
+ it 'returns false' do
22
+ expect(test.verify).to be false
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '#command' do
28
+ it 'returns the first argument' do
29
+ expect(test.command).to eq command
30
+ end
31
+ end
32
+ end
33
+ end
34
+ 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.1.15
4
+ version: 0.1.16
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-03-05 00:00:00.000000000 Z
11
+ date: 2014-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -138,6 +138,7 @@ files:
138
138
  - features/tests/has_executable.feature
139
139
  - features/tests/has_file.feature
140
140
  - features/tests/negated_test.feature
141
+ - features/tests/shell_command_status.feature
141
142
  - lib/producer/core.rb
142
143
  - lib/producer/core/action.rb
143
144
  - lib/producer/core/actions/echo.rb
@@ -167,6 +168,7 @@ files:
167
168
  - lib/producer/core/tests/has_env.rb
168
169
  - lib/producer/core/tests/has_executable.rb
169
170
  - lib/producer/core/tests/has_file.rb
171
+ - lib/producer/core/tests/shell_command_status.rb
170
172
  - lib/producer/core/version.rb
171
173
  - lib/producer/core/worker.rb
172
174
  - producer-core.gemspec
@@ -199,6 +201,7 @@ files:
199
201
  - spec/producer/core/tests/has_env_spec.rb
200
202
  - spec/producer/core/tests/has_executable_spec.rb
201
203
  - spec/producer/core/tests/has_file_spec.rb
204
+ - spec/producer/core/tests/shell_command_status_spec.rb
202
205
  - spec/producer/core/worker_spec.rb
203
206
  - spec/spec_helper.rb
204
207
  - spec/support/exit_helpers.rb
@@ -261,6 +264,7 @@ test_files:
261
264
  - features/tests/has_executable.feature
262
265
  - features/tests/has_file.feature
263
266
  - features/tests/negated_test.feature
267
+ - features/tests/shell_command_status.feature
264
268
  - spec/fixtures/recipes/empty.rb
265
269
  - spec/fixtures/recipes/some_recipe.rb
266
270
  - spec/fixtures/recipes/throw.rb
@@ -290,6 +294,7 @@ test_files:
290
294
  - spec/producer/core/tests/has_env_spec.rb
291
295
  - spec/producer/core/tests/has_executable_spec.rb
292
296
  - spec/producer/core/tests/has_file_spec.rb
297
+ - spec/producer/core/tests/shell_command_status_spec.rb
293
298
  - spec/producer/core/worker_spec.rb
294
299
  - spec/spec_helper.rb
295
300
  - spec/support/exit_helpers.rb