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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e03f3130563d228e058023198926b0165c4a952e
4
- data.tar.gz: fd6354e893c19bb0f26e92036df3f5fc55ca83d8
3
+ metadata.gz: 961e79ea57d0b4e4db3b33cc2a0665efbda76aac
4
+ data.tar.gz: ef532a17f25bfc0e746ee5af7d14b553beb00419
5
5
  SHA512:
6
- metadata.gz: b74ec3d925307da7ca311dcd4ad23e7db4e77f129f5fe12e320c6556dc1a57c0e390911748cd24d4cb6c7186e565fcf916e30265173ac74e31d2012114e14a81
7
- data.tar.gz: 665c0ce5f5a207f51d679a3fff33b4646fa752cec32c7a75d565627fbb15834b5f9f79d43b6d70f1bc4b0c383c8c0827409d0ec2af833ef1b83c6c11f1b65bce
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
@@ -1,5 +1,5 @@
1
1
  module Producer
2
2
  module Core
3
- VERSION = '0.2.13'.freeze
3
+ VERSION = '0.2.14'.freeze
4
4
  end
5
5
  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'
@@ -11,6 +11,7 @@ module Producer::Core
11
11
  `
12
12
  sh
13
13
  file_contains
14
+ file_eq
14
15
  dir?
15
16
  env?
16
17
  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.13
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-21 00:00:00.000000000 Z
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