producer-core 0.5.8 → 0.5.9

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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/lib/producer/core/version.rb +1 -1
  3. metadata +21 -202
  4. data/.gitignore +0 -3
  5. data/.travis.yml +0 -14
  6. data/Gemfile +0 -5
  7. data/Guardfile +0 -14
  8. data/LICENSE +0 -30
  9. data/Rakefile +0 -19
  10. data/config/cucumber.yaml +0 -2
  11. data/features/actions/echo.feature +0 -11
  12. data/features/actions/file_append.feature +0 -15
  13. data/features/actions/file_replace_content.feature +0 -24
  14. data/features/actions/file_write.feature +0 -21
  15. data/features/actions/mkdir.feature +0 -31
  16. data/features/actions/sh.feature +0 -43
  17. data/features/actions/yaml_write.feature +0 -14
  18. data/features/cli/debug.feature +0 -19
  19. data/features/cli/dry_run.feature +0 -22
  20. data/features/cli/error_reporting.feature +0 -32
  21. data/features/cli/target.feature +0 -15
  22. data/features/cli/usage.feature +0 -13
  23. data/features/cli/verbose.feature +0 -48
  24. data/features/condition/negated_test.feature +0 -47
  25. data/features/condition/target.feature +0 -15
  26. data/features/recipe/compose_macro.feature +0 -29
  27. data/features/recipe/errors.feature +0 -9
  28. data/features/recipe/macro.feature +0 -50
  29. data/features/recipe/registry.feature +0 -82
  30. data/features/recipe/source.feature +0 -17
  31. data/features/recipe/target.feature +0 -23
  32. data/features/recipe/test_macro.feature +0 -50
  33. data/features/ssh/config.feature +0 -25
  34. data/features/steps/environment_steps.rb +0 -3
  35. data/features/support/env.rb +0 -1
  36. data/features/task/ask.feature +0 -23
  37. data/features/task/condition.feature +0 -13
  38. data/features/task/nested_tasks.feature +0 -20
  39. data/features/task/recipe_argv.feature +0 -13
  40. data/features/task/target.feature +0 -11
  41. data/features/task/template.feature +0 -49
  42. data/features/tests/dir.feature +0 -21
  43. data/features/tests/env.feature +0 -47
  44. data/features/tests/executable.feature +0 -26
  45. data/features/tests/file.feature +0 -21
  46. data/features/tests/file_contains.feature +0 -26
  47. data/features/tests/file_eq.feature +0 -26
  48. data/features/tests/file_match.feature +0 -26
  49. data/features/tests/shell_command_status.feature +0 -46
  50. data/features/tests/yaml_eq.feature +0 -26
  51. data/producer-core.gemspec +0 -28
  52. data/spec/fixtures/recipes/empty.rb +0 -1
  53. data/spec/fixtures/recipes/raise.rb +0 -1
  54. data/spec/fixtures/recipes/some_recipe.rb +0 -5
  55. data/spec/fixtures/recipes/throw.rb +0 -1
  56. data/spec/fixtures/templates/basic.erb +0 -1
  57. data/spec/fixtures/templates/basic_yaml.yaml +0 -1
  58. data/spec/fixtures/templates/variables.erb +0 -1
  59. data/spec/producer/core/action_spec.rb +0 -46
  60. data/spec/producer/core/actions/echo_spec.rb +0 -20
  61. data/spec/producer/core/actions/file_append_spec.rb +0 -49
  62. data/spec/producer/core/actions/file_replace_content_spec.rb +0 -42
  63. data/spec/producer/core/actions/file_writer_spec.rb +0 -52
  64. data/spec/producer/core/actions/mkdir_spec.rb +0 -71
  65. data/spec/producer/core/actions/shell_command_spec.rb +0 -45
  66. data/spec/producer/core/actions/yaml_writer_spec.rb +0 -25
  67. data/spec/producer/core/cli_spec.rb +0 -211
  68. data/spec/producer/core/condition_spec.rb +0 -198
  69. data/spec/producer/core/env_spec.rb +0 -196
  70. data/spec/producer/core/error_formatter_spec.rb +0 -86
  71. data/spec/producer/core/logger_formatter_spec.rb +0 -26
  72. data/spec/producer/core/prompter_spec.rb +0 -40
  73. data/spec/producer/core/recipe/file_evaluator_spec.rb +0 -22
  74. data/spec/producer/core/recipe_spec.rb +0 -126
  75. data/spec/producer/core/remote/environment_spec.rb +0 -19
  76. data/spec/producer/core/remote/fs_spec.rb +0 -144
  77. data/spec/producer/core/remote_spec.rb +0 -168
  78. data/spec/producer/core/task_spec.rb +0 -198
  79. data/spec/producer/core/template_spec.rb +0 -41
  80. data/spec/producer/core/test_spec.rb +0 -7
  81. data/spec/producer/core/testing/mock_remote_spec.rb +0 -66
  82. data/spec/producer/core/tests/condition_test_spec.rb +0 -55
  83. data/spec/producer/core/tests/file_contains_spec.rb +0 -46
  84. data/spec/producer/core/tests/file_eq_spec.rb +0 -45
  85. data/spec/producer/core/tests/file_match_spec.rb +0 -46
  86. data/spec/producer/core/tests/has_dir_spec.rb +0 -25
  87. data/spec/producer/core/tests/has_env_spec.rb +0 -75
  88. data/spec/producer/core/tests/has_executable_spec.rb +0 -29
  89. data/spec/producer/core/tests/has_file_spec.rb +0 -25
  90. data/spec/producer/core/tests/shell_command_status_spec.rb +0 -34
  91. data/spec/producer/core/tests/yaml_eq_spec.rb +0 -47
  92. data/spec/producer/core/worker_spec.rb +0 -88
  93. data/spec/spec_helper.rb +0 -13
  94. data/spec/support/exit_helpers.rb +0 -6
  95. data/spec/support/fixtures_helpers.rb +0 -7
  96. data/spec/support/net_ssh_story_helpers.rb +0 -36
  97. data/spec/support/shared_action.rb +0 -44
  98. data/spec/support/shared_test.rb +0 -82
  99. data/spec/support/test_env_helpers.rb +0 -44
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- module Tests
5
- describe YAMLEq, :env do
6
- let(:filepath) { 'some_file' }
7
- let(:data) { { foo: 'bar' } }
8
- subject(:test) { described_class.new(env, filepath, data, {}) }
9
-
10
- it_behaves_like 'test'
11
-
12
- describe '#verify' do
13
- context 'when file content matches' do
14
- before do
15
- allow(remote_fs)
16
- .to receive(:file_read).with(filepath) { ':foo: bar' }
17
- end
18
-
19
- it 'returns true' do
20
- expect(test.verify).to be true
21
- end
22
- end
23
-
24
- context 'when file content does not match' do
25
- before do
26
- allow(remote_fs)
27
- .to receive(:file_read).with(filepath) { ':foo: baz' }
28
- end
29
-
30
- it 'returns false' do
31
- expect(test.verify).to be false
32
- end
33
- end
34
-
35
- context 'when file does not exist' do
36
- before do
37
- allow(remote_fs).to receive(:file_read).with(filepath) { nil }
38
- end
39
-
40
- it 'returns false' do
41
- expect(test.verify).to be false
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,88 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- describe Worker do
5
- let(:env) { Env.new }
6
- subject(:worker) { described_class.new(env) }
7
-
8
- describe '#process' do
9
- it 'processes each task' do
10
- expect(worker).to receive(:process_task).with(:some_task)
11
- worker.process [:some_task]
12
- end
13
-
14
- context 'when dry run is enabled' do
15
- before { env.dry_run = true }
16
-
17
- it 'warns dry run is enabled' do
18
- expect(env).to receive(:log).with(
19
- /\Arunning in dry run mode, actions will NOT be applied\z/,
20
- :warn
21
- )
22
- worker.process []
23
- end
24
- end
25
- end
26
-
27
- describe '#process_task' do
28
- let(:env) { instance_spy Env, dry_run?: false }
29
- let(:action) { double('action', to_s: 'echo').as_null_object }
30
- let(:task) { Task.new(env, :some_task, [action]) }
31
-
32
- it 'logs task info' do
33
- expect(env).to receive(:log).with /\ATask: `some_task'/
34
- worker.process_task task
35
- end
36
-
37
- context 'when task condition is met' do
38
- it 'applies the actions' do
39
- expect(action).to receive :apply
40
- worker.process_task task
41
- end
42
-
43
- it 'logs the task as beeing applied' do
44
- expect(env).to receive(:log).with /some_task.+applying\.\.\.\z/
45
- worker.process_task task
46
- end
47
-
48
- it 'logs action info' do
49
- expect(env).to receive(:log).with /\A action: echo/
50
- worker.process_task task
51
- end
52
-
53
- context 'when dry run is enabled' do
54
- before { allow(env).to receive(:dry_run?) { true } }
55
-
56
- it 'does not apply the actions' do
57
- expect(action).not_to receive :apply
58
- worker.process_task task
59
- end
60
- end
61
- end
62
-
63
- context 'when task condition is not met' do
64
- before { task.condition { false } }
65
-
66
- it 'does not apply the actions' do
67
- expect(action).not_to receive :apply
68
- worker.process_task task
69
- end
70
-
71
- it 'logs the task as being skipped' do
72
- expect(env).to receive(:log).with /some_task.+skipped\z/
73
- worker.process_task task
74
- end
75
- end
76
-
77
- context 'when a task contains nested tasks' do
78
- let(:inner_task) { Task.new(env, :inner, [action]) }
79
- let(:outer_task) { Task.new(env, :outer, [inner_task]) }
80
-
81
- it 'processes nested tasks' do
82
- expect(action).to receive :apply
83
- worker.process [outer_task]
84
- end
85
- end
86
- end
87
- end
88
- end
data/spec/spec_helper.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'producer/core'
2
-
3
- Dir['spec/support/**/*.rb'].map { |e| require e.gsub 'spec/', '' }
4
-
5
-
6
- RSpec.configure do |c|
7
- c.include TestEnvHelpers, :env
8
-
9
- c.include NetSSHStoryHelpers, :ssh
10
- c.before(:each, :ssh) do
11
- allow(Net::SSH).to receive(:start) { connection }
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- module ExitHelpers
2
- def trap_exit
3
- yield
4
- rescue SystemExit
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- module FixturesHelpers
2
- FIXTURES_PATH = 'spec/fixtures'
3
-
4
- def fixture_path_for(path)
5
- File.join(FIXTURES_PATH, path)
6
- end
7
- end
@@ -1,36 +0,0 @@
1
- require 'net/ssh/test'
2
-
3
- if Net::SSH::Version::CURRENT >= Net::SSH::Version[2, 8, 0]
4
- module Net
5
- module SSH
6
- module Test
7
- class Socket
8
- def open(host, port, connections_options = nil)
9
- @host, @port = host, port
10
- self
11
- end
12
- end
13
- end
14
- end
15
- end
16
- end
17
-
18
- module NetSSHStoryHelpers
19
- include Net::SSH::Test
20
-
21
- def story_with_new_channel
22
- story do |session|
23
- ch = session.opens_channel
24
- yield ch
25
- ch.gets_close
26
- ch.sends_close
27
- end
28
- end
29
-
30
- def expect_story_completed
31
- raise 'there is no story to expect' if socket.script.events.empty?
32
- yield
33
- expect(socket.script.events)
34
- .to be_empty, "#{socket.script.events.count} story events still pending"
35
- end
36
- end
@@ -1,44 +0,0 @@
1
- module Producer::Core
2
- shared_examples 'action' do
3
- include TestEnvHelpers
4
-
5
- let(:options) { { foo: :bar } }
6
- subject(:action) { described_class.new(env, *arguments, options) }
7
-
8
- describe '#input' do
9
- it 'returns env input' do
10
- expect(action.input).to be env.input
11
- end
12
- end
13
-
14
- describe '#output' do
15
- it 'returns env output' do
16
- expect(action.output).to be env.output
17
- end
18
- end
19
-
20
- describe '#error_output' do
21
- it 'returns env error output' do
22
- expect(action.error_output).to be env.error_output
23
- end
24
- end
25
-
26
- describe '#remote' do
27
- it 'returns env remote' do
28
- expect(action.remote).to be env.remote
29
- end
30
- end
31
-
32
- describe '#fs' do
33
- it 'returns env remote fs' do
34
- expect(action.fs).to be env.remote.fs
35
- end
36
- end
37
-
38
- describe '#name' do
39
- it 'returns a word' do
40
- expect(action.name).to match /\A\w+\z/
41
- end
42
- end
43
- end
44
- end
@@ -1,82 +0,0 @@
1
- module Producer::Core
2
- shared_examples 'test' do
3
- include TestEnvHelpers
4
-
5
- let(:arguments) { [:some, :arguments] }
6
- subject(:test) { described_class.new(env, *arguments) }
7
-
8
- describe '#initialize' do
9
- it 'assigns the env' do
10
- expect(test.env).to be env
11
- end
12
-
13
- it 'assigns the arguments' do
14
- expect(test.arguments).to eq arguments
15
- end
16
-
17
- it 'assigns negated as false by default' do
18
- expect(test).not_to be_negated
19
- end
20
-
21
- context 'when negated option is true' do
22
- subject(:test) { described_class.new(env, *arguments, negated: true) }
23
-
24
- it 'assigns negated as true' do
25
- expect(test).to be_negated
26
- end
27
- end
28
- end
29
-
30
- describe '#remote' do
31
- it 'returns env remote' do
32
- expect(test.remote).to be test.env.remote
33
- end
34
- end
35
-
36
- describe '#fs' do
37
- it 'returns env remote fs' do
38
- expect(test.fs).to be test.env.remote.fs
39
- end
40
- end
41
-
42
- describe '#negated?' do
43
- it 'returns false' do
44
- expect(test.negated?).to be false
45
- end
46
-
47
- context 'when test is negated' do
48
- subject(:test) { described_class.new(env, *arguments, negated: true) }
49
-
50
- it 'returns true' do
51
- expect(test.negated?).to be true
52
- end
53
- end
54
- end
55
-
56
- describe '#pass?' do
57
- it 'returns true when #verify is true' do
58
- allow(test).to receive(:verify) { true }
59
- expect(test.pass?).to be true
60
- end
61
-
62
- it 'returns false when #verify is false' do
63
- allow(test).to receive(:verify) { false }
64
- expect(test.pass?).to be false
65
- end
66
-
67
- context 'when test is negated' do
68
- subject(:test) { described_class.new(env, *arguments, negated: true) }
69
-
70
- it 'returns false when #verify is true' do
71
- allow(test).to receive(:verify) { true }
72
- expect(test.pass?).to be false
73
- end
74
-
75
- it 'returns true when #verify is false' do
76
- allow(test).to receive(:verify) { false }
77
- expect(test.pass?).to be true
78
- end
79
- end
80
- end
81
- end
82
- end
@@ -1,44 +0,0 @@
1
- module TestEnvHelpers
2
- require 'producer/core/testing'
3
-
4
- def env
5
- @_env ||= build_env
6
- end
7
-
8
- def output
9
- env.output.string
10
- end
11
-
12
- def error_output
13
- env.error_output.string
14
- end
15
-
16
- def remote_fs
17
- env.remote.fs
18
- end
19
-
20
- def expect_execution(command)
21
- opts = { expected_from: caller.first }
22
- RSpec::Mocks
23
- .expect_message(env.remote, :execute, opts)
24
- .with(command, env.output, env.error_output)
25
- end
26
-
27
-
28
- private
29
-
30
- def build_env
31
- Producer::Core::Env.new(
32
- output: StringIO.new,
33
- error_output: StringIO.new,
34
- remote: build_remote
35
- )
36
- end
37
-
38
- def build_remote
39
- fs = instance_spy Producer::Core::Remote::FS
40
- remote = Producer::Core::Testing::MockRemote.new('some_host.test')
41
- remote.define_singleton_method(:fs) { fs }
42
- remote
43
- end
44
- end