producer-core 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/actions/file_write.feature +15 -0
- data/features/steps/remote_steps.rb +5 -1
- data/lib/producer/core/actions/file_writer.rb +19 -0
- data/lib/producer/core/remote/fs.rb +6 -0
- data/lib/producer/core/task/dsl.rb +2 -0
- data/lib/producer/core/version.rb +1 -1
- data/lib/producer/core.rb +1 -0
- data/spec/producer/core/actions/file_writer_spec.rb +29 -0
- data/spec/producer/core/remote/fs_spec.rb +26 -1
- data/spec/producer/core/remote_spec.rb +1 -2
- data/spec/producer/core/task/dsl_spec.rb +1 -1
- data/spec/support/net_ssh_story_helpers.rb +7 -4
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69bc1d881cfd85eea00037b60c396d9b09bf7bdd
|
4
|
+
data.tar.gz: 6d440b7bd0beb137b073d00c2096222bb7f2b58a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 837737ed2a5bc77959a9c0e7c8295acdc7a997884a63fd286035cb9d811191ac7097d93ed5fb3e24c0c8c0afe22db4d05ca6b45afefcc4f5a69af34da3595e74
|
7
|
+
data.tar.gz: 098654fa4620affd4eac4b89fb8906a57537c13b134b9ab8c1a47e48cff83cce96d48b8cdbeed4cd50df2de4e95fbdfa7cd9589c4f5be04dedee3810630cc26d
|
@@ -0,0 +1,15 @@
|
|
1
|
+
@sshd
|
2
|
+
Feature: `file_write' task action
|
3
|
+
|
4
|
+
Scenario: writes given data to given file path
|
5
|
+
Given a recipe with:
|
6
|
+
"""
|
7
|
+
target 'some_host.test'
|
8
|
+
|
9
|
+
task :write_some_data do
|
10
|
+
file_write 'some_file', 'some_content'
|
11
|
+
end
|
12
|
+
"""
|
13
|
+
When I execute the recipe
|
14
|
+
Then the exit status must be 0
|
15
|
+
And the remote file "some_file" must contain "some_content"
|
@@ -1,3 +1,7 @@
|
|
1
|
-
Given
|
1
|
+
Given /^a remote file named "([^"]+)"$/ do |file_name|
|
2
2
|
write_file file_name, ''
|
3
3
|
end
|
4
|
+
|
5
|
+
Then /^the remote file "([^"]+)" should contain "([^"]+)"/ do |path, content|
|
6
|
+
check_file_content path, content, true
|
7
|
+
end
|
data/lib/producer/core.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Producer::Core
|
4
|
+
describe Actions::FileWriter do
|
5
|
+
let(:env) { Env.new }
|
6
|
+
let(:path) { 'some_path' }
|
7
|
+
let(:content) { 'some_content' }
|
8
|
+
subject(:writer) { Actions::FileWriter.new(env, path, content) }
|
9
|
+
|
10
|
+
describe '#apply' do
|
11
|
+
it 'delegates the call to env.remote.fs.file_write method' do
|
12
|
+
expect(env.remote.fs).to receive(:file_write).with(path, content)
|
13
|
+
writer.apply
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#path' do
|
18
|
+
it 'returns the path' do
|
19
|
+
expect(writer.path).to eq path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#content' do
|
24
|
+
it 'returns the content' do
|
25
|
+
expect(writer.content).to eq content
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -34,7 +34,7 @@ module Producer::Core
|
|
34
34
|
# FIXME: We rely a lot on mocking net-sftp heavily, while we already use a
|
35
35
|
# part of net-ssh story helpers, which are more close to integration tests.
|
36
36
|
describe '#has_file?', :ssh do
|
37
|
-
let(:file_path) {
|
37
|
+
let(:file_path) { 'some_file_path' }
|
38
38
|
let(:stat) { double 'stat' }
|
39
39
|
|
40
40
|
before do
|
@@ -72,5 +72,30 @@ module Producer::Core
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
describe '#file_write' do
|
77
|
+
let(:sftp) { double('sftp').as_null_object }
|
78
|
+
let(:file) { double('sftp').as_null_object }
|
79
|
+
let(:path) { 'some_file_path' }
|
80
|
+
let(:content) { 'some_content' }
|
81
|
+
|
82
|
+
before do
|
83
|
+
allow(fs).to receive(:sftp) { sftp }
|
84
|
+
allow(sftp).to receive(:file) { file }
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'opens the file' do
|
88
|
+
expect(file).to receive(:open).with(path, 'w')
|
89
|
+
fs.file_write path, content
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'writes the content' do
|
93
|
+
expect(file).to receive(:open).with(any_args) do |&b|
|
94
|
+
expect(file).to receive(:write).with(content)
|
95
|
+
b.call file
|
96
|
+
end
|
97
|
+
fs.file_write path, content
|
98
|
+
end
|
99
|
+
end
|
75
100
|
end
|
76
101
|
end
|
@@ -29,10 +29,6 @@ module NetSSHStoryHelpers
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def story_completed?
|
33
|
-
socket.script.events.empty?
|
34
|
-
end
|
35
|
-
|
36
32
|
def sftp_story
|
37
33
|
story do |session|
|
38
34
|
ch = session.opens_channel
|
@@ -48,4 +44,11 @@ module NetSSHStoryHelpers
|
|
48
44
|
yield ch if block_given?
|
49
45
|
end
|
50
46
|
end
|
47
|
+
|
48
|
+
def expect_story_completed
|
49
|
+
raise 'there is no story to expect' if socket.script.events.empty?
|
50
|
+
yield
|
51
|
+
expect(socket.script.events)
|
52
|
+
.to be_empty, "#{socket.script.events.count} story events still pending"
|
53
|
+
end
|
51
54
|
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- Rakefile
|
110
110
|
- bin/producer
|
111
111
|
- features/actions/echo.feature
|
112
|
+
- features/actions/file_write.feature
|
112
113
|
- features/actions/sh.feature
|
113
114
|
- features/cli/usage.feature
|
114
115
|
- features/recipes/env.feature
|
@@ -131,6 +132,7 @@ files:
|
|
131
132
|
- lib/producer/core.rb
|
132
133
|
- lib/producer/core/action.rb
|
133
134
|
- lib/producer/core/actions/echo.rb
|
135
|
+
- lib/producer/core/actions/file_writer.rb
|
134
136
|
- lib/producer/core/actions/shell_command.rb
|
135
137
|
- lib/producer/core/cli.rb
|
136
138
|
- lib/producer/core/condition.rb
|
@@ -154,6 +156,7 @@ files:
|
|
154
156
|
- spec/fixtures/recipes/throw.rb
|
155
157
|
- spec/producer/core/action_spec.rb
|
156
158
|
- spec/producer/core/actions/echo_spec.rb
|
159
|
+
- spec/producer/core/actions/file_writer_spec.rb
|
157
160
|
- spec/producer/core/actions/shell_command_spec.rb
|
158
161
|
- spec/producer/core/cli_spec.rb
|
159
162
|
- spec/producer/core/condition/dsl_spec.rb
|
@@ -197,9 +200,10 @@ rubyforge_project:
|
|
197
200
|
rubygems_version: 2.4.5
|
198
201
|
signing_key:
|
199
202
|
specification_version: 4
|
200
|
-
summary: producer-core-0.1.
|
203
|
+
summary: producer-core-0.1.6
|
201
204
|
test_files:
|
202
205
|
- features/actions/echo.feature
|
206
|
+
- features/actions/file_write.feature
|
203
207
|
- features/actions/sh.feature
|
204
208
|
- features/cli/usage.feature
|
205
209
|
- features/recipes/env.feature
|
@@ -223,6 +227,7 @@ test_files:
|
|
223
227
|
- spec/fixtures/recipes/throw.rb
|
224
228
|
- spec/producer/core/action_spec.rb
|
225
229
|
- spec/producer/core/actions/echo_spec.rb
|
230
|
+
- spec/producer/core/actions/file_writer_spec.rb
|
226
231
|
- spec/producer/core/actions/shell_command_spec.rb
|
227
232
|
- spec/producer/core/cli_spec.rb
|
228
233
|
- spec/producer/core/condition/dsl_spec.rb
|