producer-core 0.2.6 → 0.2.7

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: 4895dde05c3db8c7fddcaece8d7f94aa525ff45d
4
- data.tar.gz: 919123f791a2de0b2364e192c42662de44ec922d
3
+ metadata.gz: 558adf1eb44b9065788d910cc92c133894612fd1
4
+ data.tar.gz: 97b0bbc77826a98b81e854f2a7034ff8ca544557
5
5
  SHA512:
6
- metadata.gz: c073aa03b75b67b5b3a0d300820fce5d009c9a245e8c8d7abecc167e02a2f2842628b42d8d40b213e481b4d1824759fc972f139e7fbe7fcbf1d4ab5660418483
7
- data.tar.gz: 7c5f80f18a7d7b694eb2b3027d678cf79e6b13e015c4f6722ad2a060e5b02c3dbecca418d005f3972b0cfef9eadfce8d6cc79568260d0c26b76ea4e33186106f
6
+ metadata.gz: 6d4ffe253ba82de174a3064bc015e188c4d6e1715705cf211a03708695980daf66b3a6299973757fad6d236ab06a48e457d89db694682e9535f4533b6ad312aa
7
+ data.tar.gz: a5402e095dd72ba88a69ec602d99eb137c7a5821c3adecf95657a3c4e340231be42be593d84bee7307c217e723905d9cf6df57b07e9fe38a5a0af3d63643aaad
@@ -0,0 +1,15 @@
1
+ Feature: CLI target option
2
+
3
+ Background:
4
+ Given a recipe with:
5
+ """
6
+ target 'some_host.example'
7
+
8
+ task :some_task do
9
+ echo env.target
10
+ end
11
+ """
12
+
13
+ Scenario: prints tasks name
14
+ When I successfully execute the recipe with option -t other_host.example
15
+ Then the output must contain exactly "other_host.example\n"
@@ -11,7 +11,7 @@ When /^I successfully execute the recipe$/ do
11
11
  assert_exit_status 0
12
12
  end
13
13
 
14
- When /^I successfully execute the recipe with option (-\w)$/ do |option|
14
+ When /^I successfully execute the recipe with option (-.+)$/ do |option|
15
15
  run_simple "producer #{option} recipe.rb", false
16
16
  assert_exit_status 0
17
17
  end
@@ -1,6 +1,5 @@
1
1
  require 'aruba/cucumber'
2
2
  require 'aruba/in_process'
3
- require 'cucumber/sshd/cucumber'
4
3
  require 'producer/core'
5
4
 
6
5
 
@@ -24,6 +23,11 @@ class ArubaProgramWrapper
24
23
  end
25
24
 
26
25
 
26
+ Before do
27
+ @_sshd_fast = true
28
+ end
29
+ require 'cucumber/sshd/cucumber'
30
+
27
31
  Before('@exec') do
28
32
  Aruba.process = Aruba::SpawnProcess
29
33
  end
@@ -34,19 +34,21 @@ module Producer
34
34
  end
35
35
 
36
36
  def parse_arguments!
37
- @arguments = arguments.inject([]) do |m, e|
37
+ @arguments = arguments.each_with_index.inject([]) do |m, (e, i)|
38
38
  case e
39
39
  when '-v'
40
40
  env.verbose = true
41
41
  when '-n'
42
42
  env.dry_run = true
43
+ when '-t'
44
+ env.target = arguments.delete_at i + 1
43
45
  else
44
46
  m << e
45
47
  end
46
48
  m
47
49
  end
48
50
 
49
- raise ArgumentError unless arguments.any?
51
+ fail ArgumentError unless arguments.any?
50
52
  end
51
53
 
52
54
  def run
@@ -25,7 +25,7 @@ module Producer
25
25
  end
26
26
 
27
27
  def target(hostname)
28
- env.target = hostname
28
+ env.target ||= hostname
29
29
  end
30
30
 
31
31
  def task(name, *args, &block)
@@ -32,7 +32,7 @@ module Producer
32
32
 
33
33
  ch.on_request 'exit-status' do |c, data|
34
34
  exit_status = data.read_long
35
- raise RemoteCommandExecutionError, command if exit_status != 0
35
+ fail RemoteCommandExecutionError, command if exit_status != 0
36
36
  end
37
37
  end
38
38
  end
@@ -3,7 +3,7 @@ module Producer
3
3
  module Testing
4
4
  class MockRemote < Remote
5
5
  def session
6
- raise 'no session for mock remote!'
6
+ fail 'no session for mock remote!'
7
7
  end
8
8
 
9
9
  def execute(command, output = '')
@@ -16,9 +16,9 @@ module Producer
16
16
  when 'true'
17
17
  output << ''
18
18
  when 'false'
19
- raise RemoteCommandExecutionError
19
+ fail RemoteCommandExecutionError
20
20
  when 'type'
21
- raise RemoteCommandExecutionError unless %w[
21
+ fail RemoteCommandExecutionError unless %w[
22
22
  echo
23
23
  true
24
24
  false
@@ -1,5 +1,5 @@
1
1
  module Producer
2
2
  module Core
3
- VERSION = '0.2.6'.freeze
3
+ VERSION = '0.2.7'.freeze
4
4
  end
5
5
  end
@@ -122,7 +122,7 @@ module Producer::Core
122
122
 
123
123
  describe '#parse_arguments!' do
124
124
  context 'with options' do
125
- let(:options) { %w[-v] }
125
+ let(:options) { %w[-v -t some_host.example] }
126
126
 
127
127
  before { cli.parse_arguments! }
128
128
 
@@ -131,6 +131,8 @@ module Producer::Core
131
131
  end
132
132
 
133
133
  context 'verbose' do
134
+ let(:options) { %w[-v] }
135
+
134
136
  it 'enables env verbose mode' do
135
137
  expect(cli.env).to be_verbose
136
138
  end
@@ -143,6 +145,14 @@ module Producer::Core
143
145
  expect(cli.env).to be_dry_run
144
146
  end
145
147
  end
148
+
149
+ context 'target' do
150
+ let(:options) { %w[-t some_host.example] }
151
+
152
+ it 'assigns the given target to the env' do
153
+ expect(cli.env.target).to eq 'some_host.example'
154
+ end
155
+ end
146
156
  end
147
157
 
148
158
  context 'without arguments' do
@@ -65,9 +65,19 @@ module Producer::Core
65
65
  describe '#target' do
66
66
  let(:host) { 'some_host.example' }
67
67
 
68
- it 'registers the target host in the env' do
69
- dsl.target host
70
- expect(env.target).to eq host
68
+ context 'when env has no assigned target' do
69
+ it 'registers the target host in the env' do
70
+ dsl.target host
71
+ expect(env.target).to eq host
72
+ end
73
+ end
74
+
75
+ context 'when env has an assigned target' do
76
+ before { env.target = 'already_assigned_host.example' }
77
+
78
+ it 'does not change env target' do
79
+ expect { dsl.target host }.not_to change { env.target }
80
+ end
71
81
  end
72
82
  end
73
83
 
@@ -15,7 +15,7 @@ module Producer::Core
15
15
  end
16
16
 
17
17
  it 'assigns negated as false by default' do
18
- expect(test).to_not be_negated
18
+ expect(test).not_to be_negated
19
19
  end
20
20
 
21
21
  context 'when negated option is true' do
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.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-03 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -129,6 +129,7 @@ files:
129
129
  - features/action_mkdir.feature
130
130
  - features/action_sh.feature
131
131
  - features/cli_dry_run.feature
132
+ - features/cli_target.feature
132
133
  - features/cli_usage.feature
133
134
  - features/cli_verbose.feature
134
135
  - features/recipe_ask.feature
@@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
251
  version: '0'
251
252
  requirements: []
252
253
  rubyforge_project:
253
- rubygems_version: 2.4.5
254
+ rubygems_version: 2.2.2
254
255
  signing_key:
255
256
  specification_version: 4
256
257
  summary: Provisioning tool
@@ -262,6 +263,7 @@ test_files:
262
263
  - features/action_mkdir.feature
263
264
  - features/action_sh.feature
264
265
  - features/cli_dry_run.feature
266
+ - features/cli_target.feature
265
267
  - features/cli_usage.feature
266
268
  - features/cli_verbose.feature
267
269
  - features/recipe_ask.feature