producer-core 0.2.13 → 0.2.14
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 +4 -4
- data/features/test_file_eq.feature +26 -0
- data/lib/producer/core/condition/dsl.rb +1 -0
- data/lib/producer/core/tests/file_eq.rb +22 -0
- data/lib/producer/core/version.rb +1 -1
- data/lib/producer/core.rb +1 -0
- data/spec/producer/core/condition/dsl_spec.rb +1 -0
- data/spec/producer/core/tests/file_eq_spec.rb +45 -0
- 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: 961e79ea57d0b4e4db3b33cc2a0665efbda76aac
|
4
|
+
data.tar.gz: ef532a17f25bfc0e746ee5af7d14b553beb00419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7a09c92aabde58b964fc612f1118301deb8d627c9b6b0c447255d740081765b2309b93b04ecd50db556e4e7ee2e3d9f4979b86a36717b7a9c4f0e3e25016072
|
7
|
+
data.tar.gz: 6d4fec1fe651713a7dcb4ecc52792bc6ca9892504e4ae786a73af6f266ec9dcdefe2bf3072c5e437d5286977432cbcb1074d0a1d52c317a56334a42542b580d2
|
@@ -0,0 +1,26 @@
|
|
1
|
+
@sshd
|
2
|
+
Feature: `file_eq' condition keyword
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given a recipe with:
|
6
|
+
"""
|
7
|
+
task :file_eq_test do
|
8
|
+
condition { file_eq 'some_file', 'some content' }
|
9
|
+
|
10
|
+
echo 'evaluated'
|
11
|
+
end
|
12
|
+
"""
|
13
|
+
|
14
|
+
Scenario: succeeds when file content is expected content
|
15
|
+
Given a remote file named "some_file" with "some content"
|
16
|
+
When I successfully execute the recipe on remote target
|
17
|
+
Then the output must contain "evaluated"
|
18
|
+
|
19
|
+
Scenario: fails when file content is not expected content
|
20
|
+
Given a remote file named "some_file" with "some content padded"
|
21
|
+
When I successfully execute the recipe on remote target
|
22
|
+
Then the output must not contain "evaluated"
|
23
|
+
|
24
|
+
Scenario: fails when file does not exist
|
25
|
+
When I successfully execute the recipe on remote target
|
26
|
+
Then the output must not contain "evaluated"
|
@@ -25,6 +25,7 @@ module Producer
|
|
25
25
|
define_test :`, Tests::ShellCommandStatus
|
26
26
|
define_test :sh, Tests::ShellCommandStatus
|
27
27
|
define_test :file_contains, Tests::FileContains
|
28
|
+
define_test :file_eq, Tests::FileEq
|
28
29
|
define_test :env?, Tests::HasEnv
|
29
30
|
define_test :executable?, Tests::HasExecutable
|
30
31
|
define_test :dir?, Tests::HasDir
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Producer
|
2
|
+
module Core
|
3
|
+
module Tests
|
4
|
+
class FileEq < Test
|
5
|
+
def verify
|
6
|
+
file_content ? file_content == expected_content : false
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def file_content
|
13
|
+
@file_content ||= fs.file_read(arguments[0])
|
14
|
+
end
|
15
|
+
|
16
|
+
def expected_content
|
17
|
+
arguments[1]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/producer/core.rb
CHANGED
@@ -18,6 +18,7 @@ require 'producer/core/actions/file_writer'
|
|
18
18
|
require 'producer/core/test'
|
19
19
|
require 'producer/core/tests/condition_test'
|
20
20
|
require 'producer/core/tests/file_contains'
|
21
|
+
require 'producer/core/tests/file_eq'
|
21
22
|
require 'producer/core/tests/has_dir'
|
22
23
|
require 'producer/core/tests/has_env'
|
23
24
|
require 'producer/core/tests/has_executable'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Producer::Core
|
4
|
+
module Tests
|
5
|
+
describe FileEq, :env do
|
6
|
+
let(:filepath) { 'some_file' }
|
7
|
+
let(:content) { 'some content' }
|
8
|
+
subject(:test) { FileEq.new(env, filepath, content) }
|
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).to receive(:file_read).with(filepath) { content }
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns true' do
|
19
|
+
expect(test.verify).to be true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when file content does not match' do
|
24
|
+
before do
|
25
|
+
allow(remote_fs).to receive(:file_read).with(filepath) { 'foo bar' }
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns false' do
|
29
|
+
expect(test.verify).to be false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when file does not exist' do
|
34
|
+
before do
|
35
|
+
allow(remote_fs).to receive(:file_read).with(filepath) { nil }
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns false' do
|
39
|
+
expect(test.verify).to be false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
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.
|
4
|
+
version: 0.2.14
|
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-09-
|
11
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- features/test_executable.feature
|
156
156
|
- features/test_file.feature
|
157
157
|
- features/test_file_contains.feature
|
158
|
+
- features/test_file_eq.feature
|
158
159
|
- features/test_negated_test.feature
|
159
160
|
- features/test_shell_command_status.feature
|
160
161
|
- lib/producer/core.rb
|
@@ -184,6 +185,7 @@ files:
|
|
184
185
|
- lib/producer/core/testing/mock_remote.rb
|
185
186
|
- lib/producer/core/tests/condition_test.rb
|
186
187
|
- lib/producer/core/tests/file_contains.rb
|
188
|
+
- lib/producer/core/tests/file_eq.rb
|
187
189
|
- lib/producer/core/tests/has_dir.rb
|
188
190
|
- lib/producer/core/tests/has_env.rb
|
189
191
|
- lib/producer/core/tests/has_executable.rb
|
@@ -219,6 +221,7 @@ files:
|
|
219
221
|
- spec/producer/core/testing/mock_remote_spec.rb
|
220
222
|
- spec/producer/core/tests/condition_test_spec.rb
|
221
223
|
- spec/producer/core/tests/file_contains_spec.rb
|
224
|
+
- spec/producer/core/tests/file_eq_spec.rb
|
222
225
|
- spec/producer/core/tests/has_dir_spec.rb
|
223
226
|
- spec/producer/core/tests/has_env_spec.rb
|
224
227
|
- spec/producer/core/tests/has_executable_spec.rb
|
@@ -289,6 +292,7 @@ test_files:
|
|
289
292
|
- features/test_executable.feature
|
290
293
|
- features/test_file.feature
|
291
294
|
- features/test_file_contains.feature
|
295
|
+
- features/test_file_eq.feature
|
292
296
|
- features/test_negated_test.feature
|
293
297
|
- features/test_shell_command_status.feature
|
294
298
|
- spec/fixtures/recipes/empty.rb
|
@@ -318,6 +322,7 @@ test_files:
|
|
318
322
|
- spec/producer/core/testing/mock_remote_spec.rb
|
319
323
|
- spec/producer/core/tests/condition_test_spec.rb
|
320
324
|
- spec/producer/core/tests/file_contains_spec.rb
|
325
|
+
- spec/producer/core/tests/file_eq_spec.rb
|
321
326
|
- spec/producer/core/tests/has_dir_spec.rb
|
322
327
|
- spec/producer/core/tests/has_env_spec.rb
|
323
328
|
- spec/producer/core/tests/has_executable_spec.rb
|