rake-funnel 0.18.0 → 0.19.0
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/.rspec +1 -0
- data/.simplecov +24 -0
- data/Gemfile +27 -19
- data/README.md +1 -1
- data/lib/rake/funnel/ambiguous_file_error.rb +1 -0
- data/lib/rake/funnel/execution_error.rb +1 -0
- data/lib/rake/funnel/extensions/common_path.rb +5 -4
- data/lib/rake/funnel/extensions/shell.rb +3 -2
- data/lib/rake/funnel/integration/progress_report.rb +3 -2
- data/lib/rake/funnel/integration/sync_output.rb +1 -0
- data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +2 -1
- data/lib/rake/funnel/integration/teamcity/progress_report.rb +1 -1
- data/lib/rake/funnel/integration/teamcity/service_messages.rb +8 -3
- data/lib/rake/funnel/integration/teamcity/teamcity.rb +5 -4
- data/lib/rake/funnel/support/argument_mapper/styles/default.rb +5 -4
- data/lib/rake/funnel/support/argument_mapper/styles/msbuild.rb +6 -5
- data/lib/rake/funnel/support/argument_mapper/styles/msdeploy.rb +13 -12
- data/lib/rake/funnel/support/argument_mapper/styles/nunit.rb +6 -5
- data/lib/rake/funnel/support/assembly_version/from_version_files.rb +2 -1
- data/lib/rake/funnel/support/assembly_version_writer.rb +1 -0
- data/lib/rake/funnel/support/binary_version_reader.rb +14 -7
- data/lib/rake/funnel/support/copier.rb +1 -0
- data/lib/rake/funnel/support/environments/loader.rb +13 -8
- data/lib/rake/funnel/support/internal/finder.rb +2 -1
- data/lib/rake/funnel/support/internal/instantiate_symbol.rb +9 -4
- data/lib/rake/funnel/support/mapper.rb +7 -6
- data/lib/rake/funnel/support/mono.rb +1 -3
- data/lib/rake/funnel/support/msbuild/build_tool.rb +35 -12
- data/lib/rake/funnel/support/msdeploy/registry_patch.rb +14 -17
- data/lib/rake/funnel/support/patch.rb +1 -0
- data/lib/rake/funnel/support/specs_remover.rb +14 -11
- data/lib/rake/funnel/support/template_engine.rb +1 -0
- data/lib/rake/funnel/support/timing/report.rb +11 -10
- data/lib/rake/funnel/support/version_info.rb +8 -9
- data/lib/rake/funnel/support/zipper.rb +1 -0
- data/lib/rake/funnel/tasks/assembly_version.rb +4 -3
- data/lib/rake/funnel/tasks/bin_path.rb +3 -2
- data/lib/rake/funnel/tasks/copy.rb +2 -1
- data/lib/rake/funnel/tasks/environments.rb +13 -9
- data/lib/rake/funnel/tasks/msbuild.rb +4 -6
- data/lib/rake/funnel/tasks/msdeploy.rb +6 -5
- data/lib/rake/funnel/tasks/nunit.rb +3 -2
- data/lib/rake/funnel/tasks/paket.rb +2 -1
- data/lib/rake/funnel/tasks/quick_template.rb +3 -2
- data/lib/rake/funnel/tasks/side_by_side_specs.rb +2 -1
- data/lib/rake/funnel/tasks/timing.rb +7 -6
- data/lib/rake/funnel/tasks/zip.rb +3 -2
- data/lib/rake/funnel/version.rb +1 -1
- data/rake-funnel.gemspec +11 -11
- data/spec/rake/funnel/execution_error_spec.rb +2 -2
- data/spec/rake/funnel/extensions/rexml_spec.rb +5 -2
- data/spec/rake/funnel/extensions/shell_spec.rb +26 -17
- data/spec/rake/funnel/integration/progress_report_spec.rb +32 -36
- data/spec/rake/funnel/integration/sync_output_spec.rb +5 -5
- data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +32 -20
- data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +31 -25
- data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +56 -20
- data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +7 -5
- data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +2 -0
- data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +6 -4
- data/spec/rake/funnel/support/argument_mapper/styles/styles_spec.rb +76 -67
- data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +17 -19
- data/spec/rake/funnel/support/assembly_version_writer_spec.rb +49 -52
- data/spec/rake/funnel/support/binary_version_reader_spec.rb +2 -2
- data/spec/rake/funnel/support/copier_spec.rb +5 -5
- data/spec/rake/funnel/support/environments/loader_spec.rb +32 -32
- data/spec/rake/funnel/support/internal/finder_spec.rb +8 -6
- data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +27 -27
- data/spec/rake/funnel/support/mapper_spec.rb +4 -3
- data/spec/rake/funnel/support/mono_spec.rb +7 -7
- data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +13 -10
- data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +47 -41
- data/spec/rake/funnel/support/patch_spec.rb +11 -11
- data/spec/rake/funnel/support/specs_remover/project/paket.references +3 -3
- data/spec/rake/funnel/support/specs_remover/project/uncompiled-code/paket.references +3 -3
- data/spec/rake/funnel/support/specs_remover/project-specific paket.references/Sample.csproj.paket.references +3 -3
- data/spec/rake/funnel/support/specs_remover/project-specific paket.references/paket.references +3 -3
- data/spec/rake/funnel/support/specs_remover_spec.rb +31 -33
- data/spec/rake/funnel/support/template_engine_spec.rb +6 -3
- data/spec/rake/funnel/support/timing/report_spec.rb +19 -20
- data/spec/rake/funnel/support/trace_spec.rb +6 -6
- data/spec/rake/funnel/support/version_info_spec.rb +8 -6
- data/spec/rake/funnel/support/which_spec.rb +7 -7
- data/spec/rake/funnel/support/zipper_spec.rb +8 -8
- data/spec/rake/funnel/tasks/assembly_version_spec.rb +9 -9
- data/spec/rake/funnel/tasks/bin_path_spec.rb +23 -21
- data/spec/rake/funnel/tasks/copy_spec.rb +10 -10
- data/spec/rake/funnel/tasks/environments_spec.rb +48 -46
- data/spec/rake/funnel/tasks/msbuild_spec.rb +21 -17
- data/spec/rake/funnel/tasks/msdeploy_spec.rb +31 -31
- data/spec/rake/funnel/tasks/nunit_spec.rb +12 -10
- data/spec/rake/funnel/tasks/paket_spec.rb +25 -21
- data/spec/rake/funnel/tasks/quick_template_spec.rb +7 -7
- data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +12 -12
- data/spec/rake/funnel/tasks/timing_spec.rb +12 -12
- data/spec/rake/funnel/tasks/zip_spec.rb +16 -16
- data/spec/spec_helper.rb +5 -31
- metadata +7 -6
@@ -2,18 +2,17 @@ include Rake
|
|
2
2
|
include Rake::Funnel::Support::Timing
|
3
3
|
|
4
4
|
describe Rake::Funnel::Support::Timing::Report do
|
5
|
-
|
6
5
|
include DSL
|
7
6
|
|
8
7
|
subject { described_class.new(stats, opts) }
|
9
8
|
|
10
9
|
let(:opts) { {} }
|
11
10
|
|
12
|
-
before
|
11
|
+
before do
|
13
12
|
allow($stdout).to receive(:puts)
|
14
13
|
allow($stderr).to receive(:puts)
|
15
14
|
subject.render
|
16
|
-
|
15
|
+
end
|
17
16
|
|
18
17
|
shared_examples_for :report do
|
19
18
|
it 'should separator lines' do
|
@@ -53,18 +52,18 @@ describe Rake::Funnel::Support::Timing::Report do
|
|
53
52
|
describe 'empty report' do
|
54
53
|
let(:stats) { Statistics.new }
|
55
54
|
|
56
|
-
|
55
|
+
it_behaves_like :report
|
57
56
|
end
|
58
57
|
|
59
58
|
describe 'report for 2 tasks' do
|
60
|
-
let(:stats)
|
59
|
+
let(:stats) do
|
61
60
|
s = Statistics.new
|
62
|
-
s.benchmark(task
|
63
|
-
s.benchmark(task
|
61
|
+
s.benchmark(task(:foo)) {}
|
62
|
+
s.benchmark(task(:bar)) {}
|
64
63
|
s
|
65
|
-
|
64
|
+
end
|
66
65
|
|
67
|
-
|
66
|
+
it_behaves_like :report
|
68
67
|
|
69
68
|
it 'should print each task' do
|
70
69
|
expect($stdout).to have_received(:puts).with(/^foo/)
|
@@ -77,27 +76,27 @@ describe Rake::Funnel::Support::Timing::Report do
|
|
77
76
|
end
|
78
77
|
|
79
78
|
describe 'formatting' do
|
80
|
-
let(:stats)
|
79
|
+
let(:stats) do
|
81
80
|
s = Statistics.new
|
82
|
-
s.benchmark(task
|
81
|
+
s.benchmark(task(task_name)) {}
|
83
82
|
s
|
84
|
-
|
83
|
+
end
|
85
84
|
|
86
|
-
let(:header_space)
|
85
|
+
let(:header_space) do
|
87
86
|
diff = task_name.to_s.length - subject.columns[0].header.length
|
88
87
|
diff = 0 if diff < 0
|
89
88
|
diff + described_class::SPACE
|
90
|
-
|
89
|
+
end
|
91
90
|
|
92
|
-
let(:header_underline)
|
91
|
+
let(:header_underline) do
|
93
92
|
[subject.columns[0].header.length, task_name.to_s.length].max
|
94
|
-
|
93
|
+
end
|
95
94
|
|
96
|
-
let(:value_space)
|
95
|
+
let(:value_space) do
|
97
96
|
diff = subject.columns.first.header.length - task_name.to_s.length
|
98
97
|
diff = 0 if diff < 0
|
99
98
|
diff + described_class::SPACE
|
100
|
-
|
99
|
+
end
|
101
100
|
|
102
101
|
shared_examples_for :padding do
|
103
102
|
it 'should pad headers' do
|
@@ -117,13 +116,13 @@ describe Rake::Funnel::Support::Timing::Report do
|
|
117
116
|
context 'task names are shorter than headers' do
|
118
117
|
let(:task_name) { :a }
|
119
118
|
|
120
|
-
|
119
|
+
it_behaves_like :padding
|
121
120
|
end
|
122
121
|
|
123
122
|
context 'task names are longer than headers' do
|
124
123
|
let(:task_name) { :aaaaaaaaaaaa }
|
125
124
|
|
126
|
-
|
125
|
+
it_behaves_like :padding
|
127
126
|
end
|
128
127
|
end
|
129
128
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
describe Rake::Funnel::Support::Trace do
|
2
|
-
before
|
2
|
+
before do
|
3
3
|
allow(Rake).to receive(:rake_output_message)
|
4
|
-
|
4
|
+
end
|
5
5
|
|
6
6
|
context 'Rake run with --trace' do
|
7
|
-
before
|
7
|
+
before do
|
8
8
|
allow(Rake.application.options).to receive(:trace).and_return(true)
|
9
|
-
|
9
|
+
end
|
10
10
|
|
11
11
|
it 'should write messages' do
|
12
12
|
described_class.message('foo')
|
@@ -16,9 +16,9 @@ describe Rake::Funnel::Support::Trace do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'Rake run without --trace' do
|
19
|
-
before
|
19
|
+
before do
|
20
20
|
allow(Rake.application.options).to receive(:trace).and_return(false)
|
21
|
-
|
21
|
+
end
|
22
22
|
|
23
23
|
it 'should not write messages' do
|
24
24
|
described_class.message('foo')
|
@@ -175,7 +175,7 @@ describe Rake::Funnel::Support::VersionInfo do
|
|
175
175
|
{
|
176
176
|
context: {
|
177
177
|
version: '1.2',
|
178
|
-
metadata: {
|
178
|
+
metadata: {}
|
179
179
|
},
|
180
180
|
expected: {
|
181
181
|
assembly_version: '1.2.0.0',
|
@@ -259,7 +259,7 @@ describe Rake::Funnel::Support::VersionInfo do
|
|
259
259
|
}
|
260
260
|
}
|
261
261
|
].each do |spec|
|
262
|
-
context "version #{spec[:context][:version] || 'none'}, build number #{spec[:context].fetch(:metadata, {})[:build] || 'none'}, SHA #{spec[:context].fetch(:metadata, {})[:sha] || 'none'}" do
|
262
|
+
context "version #{spec[:context][:version] || 'none'}, build number #{spec[:context].fetch(:metadata, {})[:build] || 'none'}, SHA #{spec[:context].fetch(:metadata, {})[:sha] || 'none'}" do # rubocop:disable Metrics/LineLength
|
263
263
|
let(:parsed) { described_class.parse(spec[:context]) }
|
264
264
|
|
265
265
|
it "should generate assembly version #{spec[:expected][:assembly_version]}" do
|
@@ -304,16 +304,18 @@ describe Rake::Funnel::Support::VersionInfo do
|
|
304
304
|
|
305
305
|
describe '#read_version_from' do
|
306
306
|
let(:file) { 'file with version info' }
|
307
|
-
let(:contents)
|
307
|
+
let(:contents) do
|
308
|
+
# rubocop:disable Style/IndentHeredoc
|
309
|
+
<<-EOF
|
308
310
|
first line with expected version number
|
309
311
|
other crap
|
310
|
-
|
311
|
-
|
312
|
+
EOF
|
313
|
+
# rubocop:enable Style/IndentHeredoc
|
314
|
+
end
|
312
315
|
|
313
316
|
it 'should read the first line with leading and trailing whitespace removed' do
|
314
317
|
Dir.mktmpdir do |tmp|
|
315
318
|
Dir.chdir(tmp) do
|
316
|
-
|
317
319
|
File.write(file, contents)
|
318
320
|
expect(described_class.read_version_from(file)).to eq('first line with expected version number')
|
319
321
|
end
|
@@ -3,17 +3,17 @@ require 'tmpdir'
|
|
3
3
|
describe Rake::Funnel::Support::Which do
|
4
4
|
let(:temp_dir) { Dir.mktmpdir }
|
5
5
|
let(:executable_path) { File.join(temp_dir, 'executable.exe') }
|
6
|
-
let(:create_entry) {
|
6
|
+
let(:create_entry) { ->(p) { FileUtils.touch(p) } }
|
7
7
|
|
8
|
-
before
|
8
|
+
before do
|
9
9
|
create_entry.call(executable_path)
|
10
10
|
|
11
11
|
allow(ENV).to receive(:[]).with('PATH').and_return(temp_dir)
|
12
|
-
|
12
|
+
end
|
13
13
|
|
14
|
-
after
|
14
|
+
after do
|
15
15
|
FileUtils.rm_rf(temp_dir)
|
16
|
-
|
16
|
+
end
|
17
17
|
|
18
18
|
describe 'executable in PATH' do
|
19
19
|
context 'found' do
|
@@ -29,7 +29,7 @@ describe Rake::Funnel::Support::Which do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'found as directory' do
|
32
|
-
let(:create_entry) {
|
32
|
+
let(:create_entry) { ->(p) { FileUtils.mkdir_p(p) } }
|
33
33
|
|
34
34
|
it 'should yield nil' do
|
35
35
|
expect(described_class.which('executable.exe')).to be_nil
|
@@ -55,7 +55,7 @@ describe Rake::Funnel::Support::Which do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
context 'found as directory' do
|
58
|
-
let(:create_entry) {
|
58
|
+
let(:create_entry) { ->(p) { FileUtils.mkdir_p(p) } }
|
59
59
|
|
60
60
|
it 'should yield nil' do
|
61
61
|
expect(described_class.which('executable.exe')).to be_nil
|
@@ -19,21 +19,21 @@ describe Rake::Funnel::Support::Zipper do
|
|
19
19
|
let(:zip_root) { nil }
|
20
20
|
let(:zip) { instance_double(::Zip::File).as_null_object }
|
21
21
|
let(:mtime) { Time.new(2015, 3, 9) }
|
22
|
-
let(:zip_entry) { double(::Zip::Entry).as_null_object }
|
22
|
+
let(:zip_entry) { double(::Zip::Entry).as_null_object } # rubocop:disable RSpec/VerifiedDoubles
|
23
23
|
|
24
|
-
before
|
24
|
+
before do
|
25
25
|
allow(RakeFileUtils).to receive(:mkdir_p)
|
26
|
-
|
26
|
+
end
|
27
27
|
|
28
|
-
before
|
28
|
+
before do
|
29
29
|
allow(::Zip::File).to receive(:open).with(target, ::Zip::File::CREATE).and_yield(zip)
|
30
30
|
allow(zip).to receive(:add).and_return(zip_entry)
|
31
31
|
allow(File).to receive(:mtime).and_return(mtime)
|
32
|
-
|
32
|
+
end
|
33
33
|
|
34
|
-
before
|
34
|
+
before do
|
35
35
|
described_class.zip(source, target, zip_root)
|
36
|
-
|
36
|
+
end
|
37
37
|
|
38
38
|
it 'should create the target directory' do
|
39
39
|
expect(RakeFileUtils).to have_received(:mkdir_p).with(File.dirname(target))
|
@@ -66,7 +66,7 @@ describe Rake::Funnel::Support::Zipper do
|
|
66
66
|
context "with '#{root || 'nil'}'" do
|
67
67
|
let(:zip_root) { root }
|
68
68
|
|
69
|
-
it "should put files below #{
|
69
|
+
it "should put files below #{root.nil? || root.empty? ? 'the root' : "'#{root}'"}" do
|
70
70
|
expect(zip).to have_received(:add).with(/^#{root}/, anything).exactly(source.length).times
|
71
71
|
end
|
72
72
|
end
|
@@ -2,9 +2,9 @@ include Rake
|
|
2
2
|
include Rake::Funnel::Support
|
3
3
|
|
4
4
|
describe Rake::Funnel::Tasks::AssemblyVersion do
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
Task.clear
|
7
|
-
|
7
|
+
end
|
8
8
|
|
9
9
|
describe 'defaults' do
|
10
10
|
its(:name) { should == :version }
|
@@ -23,22 +23,22 @@ describe Rake::Funnel::Tasks::AssemblyVersion do
|
|
23
23
|
describe 'execution' do
|
24
24
|
let(:writer) { instance_double(AssemblyVersionWriter).as_null_object }
|
25
25
|
|
26
|
-
before
|
26
|
+
before do
|
27
27
|
allow(AssemblyVersionWriter).to receive(:new).and_return(writer)
|
28
|
-
|
28
|
+
end
|
29
29
|
|
30
|
-
subject
|
30
|
+
subject do
|
31
31
|
described_class.new(:name) do |t|
|
32
|
-
t.language =
|
32
|
+
t.language = %i(cs vb)
|
33
33
|
t.source = %w(one two)
|
34
34
|
t.source_args = { foo: 42 }
|
35
35
|
t.target_path = 'will not work'
|
36
36
|
end
|
37
|
-
|
37
|
+
end
|
38
38
|
|
39
|
-
before
|
39
|
+
before do
|
40
40
|
Task[subject.name].invoke
|
41
|
-
|
41
|
+
end
|
42
42
|
|
43
43
|
it 'should pass source and source_args' do
|
44
44
|
expect(AssemblyVersionWriter).to have_received(:new).with(subject.source, subject.source_args)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
include Rake
|
2
2
|
|
3
3
|
describe Rake::Funnel::Tasks::BinPath do
|
4
|
-
before
|
4
|
+
before do
|
5
5
|
Task.clear
|
6
|
-
|
6
|
+
end
|
7
7
|
|
8
8
|
describe 'defaults' do
|
9
9
|
its(:name) { should == :bin_path }
|
@@ -13,35 +13,37 @@ describe Rake::Funnel::Tasks::BinPath do
|
|
13
13
|
describe 'execution' do
|
14
14
|
let(:default_path) { 'default PATH contents' }
|
15
15
|
let(:search_pattern) { %w(foo bar not-a-directory) }
|
16
|
-
let(:directories)
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
let(:directories) do
|
17
|
+
search_pattern.first(2)
|
18
|
+
.map { |path| File.expand_path(path) }
|
19
|
+
.sort
|
20
|
+
.join(File::PATH_SEPARATOR)
|
21
|
+
end
|
20
22
|
let(:path_modifier) { nil }
|
21
23
|
|
22
|
-
before
|
24
|
+
before do
|
23
25
|
allow(ENV).to receive(:[]).with('PATH').and_return(default_path)
|
24
26
|
allow(ENV).to receive(:[]=)
|
25
27
|
allow(Rake).to receive(:rake_output_message)
|
26
|
-
|
28
|
+
end
|
27
29
|
|
28
|
-
subject
|
30
|
+
subject do
|
29
31
|
described_class.new do |t|
|
30
32
|
t.search_pattern = search_pattern
|
31
33
|
t.path_modifier = path_modifier unless path_modifier.nil?
|
32
34
|
end
|
33
|
-
|
35
|
+
end
|
34
36
|
|
35
37
|
context 'paths to add' do
|
36
|
-
before
|
38
|
+
before do
|
37
39
|
allow(Dir).to receive(:[]).with(*search_pattern).and_return(search_pattern)
|
38
40
|
allow(File).to receive(:directory?).and_return(true)
|
39
41
|
allow(File).to receive(:directory?).with(search_pattern.last).and_return(false)
|
40
|
-
|
42
|
+
end
|
41
43
|
|
42
|
-
before
|
44
|
+
before do
|
43
45
|
Task[subject.name].invoke
|
44
|
-
|
46
|
+
end
|
45
47
|
|
46
48
|
it 'should prepend sorted matching folders to the PATH environment variable' do
|
47
49
|
expect(ENV).to have_received(:[]=).with('PATH', /^#{directories}/)
|
@@ -56,8 +58,8 @@ describe Rake::Funnel::Tasks::BinPath do
|
|
56
58
|
end
|
57
59
|
|
58
60
|
it 'should report added paths' do
|
59
|
-
expect(Rake).to have_received(:rake_output_message).with(%r
|
60
|
-
expect(Rake).to have_received(:rake_output_message).with(%r
|
61
|
+
expect(Rake).to have_received(:rake_output_message).with(%r{/foo$})
|
62
|
+
expect(Rake).to have_received(:rake_output_message).with(%r{/bar$})
|
61
63
|
end
|
62
64
|
|
63
65
|
describe 'path modifier' do
|
@@ -65,7 +67,7 @@ describe Rake::Funnel::Tasks::BinPath do
|
|
65
67
|
let(:path_modifier) { proc { |paths| paths.push('added path') } }
|
66
68
|
|
67
69
|
it 'adds extra paths' do
|
68
|
-
expect(ENV).to have_received(:[]=).with('PATH'
|
70
|
+
expect(ENV).to have_received(:[]=).with('PATH', /added path/)
|
69
71
|
end
|
70
72
|
|
71
73
|
it 'retains other paths' do
|
@@ -89,13 +91,13 @@ describe Rake::Funnel::Tasks::BinPath do
|
|
89
91
|
end
|
90
92
|
|
91
93
|
context 'no paths to add' do
|
92
|
-
before
|
94
|
+
before do
|
93
95
|
allow(Dir).to receive(:[]).with(*search_pattern).and_return([])
|
94
|
-
|
96
|
+
end
|
95
97
|
|
96
|
-
before
|
98
|
+
before do
|
97
99
|
Task[subject.name].invoke
|
98
|
-
|
100
|
+
end
|
99
101
|
|
100
102
|
it 'should not print message' do
|
101
103
|
expect(Rake).not_to have_received(:rake_output_message)
|
@@ -2,9 +2,9 @@ include Rake
|
|
2
2
|
include Rake::Funnel::Support
|
3
3
|
|
4
4
|
describe Rake::Funnel::Tasks::Copy do
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
Task.clear
|
7
|
-
|
7
|
+
end
|
8
8
|
|
9
9
|
describe 'defaults' do
|
10
10
|
its(:name) { should == :copy }
|
@@ -17,25 +17,25 @@ describe Rake::Funnel::Tasks::Copy do
|
|
17
17
|
let(:target) { 'target' }
|
18
18
|
let(:finder) { instance_double(Finder).as_null_object }
|
19
19
|
|
20
|
-
before
|
20
|
+
before do
|
21
21
|
allow(finder).to receive(:all_or_default).and_return(source)
|
22
22
|
allow(Finder).to receive(:new).and_return(finder)
|
23
|
-
|
23
|
+
end
|
24
24
|
|
25
|
-
before
|
25
|
+
before do
|
26
26
|
allow(Copier).to receive(:copy)
|
27
|
-
|
27
|
+
end
|
28
28
|
|
29
|
-
subject
|
29
|
+
subject do
|
30
30
|
described_class.new do |t|
|
31
31
|
t.source = source
|
32
32
|
t.target = target
|
33
33
|
end
|
34
|
-
|
34
|
+
end
|
35
35
|
|
36
|
-
before
|
36
|
+
before do
|
37
37
|
Task[subject.name].invoke
|
38
|
-
|
38
|
+
end
|
39
39
|
|
40
40
|
it 'should delegate to Copier' do
|
41
41
|
expect(Copier).to have_received(:copy).with(source, subject.target)
|
@@ -7,24 +7,24 @@ include Rake::Funnel::Tasks
|
|
7
7
|
describe Rake::Funnel::Tasks::Environments do
|
8
8
|
include Rake::DSL
|
9
9
|
|
10
|
-
before
|
10
|
+
before do
|
11
11
|
Task.clear
|
12
|
-
|
12
|
+
end
|
13
13
|
|
14
14
|
let(:files) { [] }
|
15
15
|
|
16
|
-
before
|
16
|
+
before do
|
17
17
|
allow(Dir).to receive(:[]).and_return(files)
|
18
|
-
|
18
|
+
end
|
19
19
|
|
20
20
|
def disable_default_env_setup
|
21
|
-
allow_any_instance_of(described_class).to receive(:default_environment_setup)
|
21
|
+
allow_any_instance_of(described_class).to receive(:default_environment_setup) # rubocop:disable RSpec/AnyInstance
|
22
22
|
end
|
23
23
|
|
24
24
|
describe 'defaults' do
|
25
|
-
before
|
25
|
+
before do
|
26
26
|
disable_default_env_setup
|
27
|
-
|
27
|
+
end
|
28
28
|
|
29
29
|
its(:store) { should == configatron }
|
30
30
|
its(:base_dir) { should == 'config' }
|
@@ -36,7 +36,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
36
36
|
describe 'overriding defaults' do
|
37
37
|
let(:store) { OpenStruct.new }
|
38
38
|
|
39
|
-
subject
|
39
|
+
subject do
|
40
40
|
described_class.new do |t|
|
41
41
|
t.store = store
|
42
42
|
t.base_dir = 'custom base_dir'
|
@@ -45,7 +45,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
45
45
|
t.local_config = 'custom local_config'
|
46
46
|
t.customizer = proc {}
|
47
47
|
end
|
48
|
-
|
48
|
+
end
|
49
49
|
|
50
50
|
its(:store) { should == store }
|
51
51
|
its(:base_dir) { should == subject.base_dir }
|
@@ -57,17 +57,17 @@ describe Rake::Funnel::Tasks::Environments do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe 'definition' do
|
60
|
-
before
|
60
|
+
before do
|
61
61
|
disable_default_env_setup
|
62
|
-
|
62
|
+
end
|
63
63
|
|
64
|
-
before
|
65
|
-
allow_any_instance_of(described_class).to receive(:task)
|
66
|
-
|
64
|
+
before do
|
65
|
+
allow_any_instance_of(described_class).to receive(:task) # rubocop:disable RSpec/AnyInstance
|
66
|
+
end
|
67
67
|
|
68
|
-
let(:files)
|
68
|
+
let(:files) do
|
69
69
|
%w(config/default.yaml config/local.yaml config/dev.yaml config/production.yaml)
|
70
|
-
|
70
|
+
end
|
71
71
|
|
72
72
|
it 'should define a task for each config file' do
|
73
73
|
expect(subject).to have_received(:task).with('dev')
|
@@ -85,28 +85,28 @@ describe Rake::Funnel::Tasks::Environments do
|
|
85
85
|
|
86
86
|
describe 'config files to load' do
|
87
87
|
let(:optional) { nil }
|
88
|
-
let(:files)
|
88
|
+
let(:files) do
|
89
89
|
%w(config/dev.yaml)
|
90
|
-
|
90
|
+
end
|
91
91
|
|
92
|
-
before
|
92
|
+
before do
|
93
93
|
allow(Loader).to receive(:load_configuration)
|
94
|
-
|
94
|
+
end
|
95
95
|
|
96
|
-
before
|
96
|
+
before do
|
97
97
|
allow(File).to receive(:exist?).and_return(true)
|
98
98
|
allow(File).to receive(:exist?).with(optional).and_return(false)
|
99
|
-
|
99
|
+
end
|
100
100
|
|
101
|
-
subject!
|
101
|
+
subject! do
|
102
102
|
described_class.new do |t|
|
103
103
|
t.default_env = 'dev'
|
104
104
|
end
|
105
|
-
|
105
|
+
end
|
106
106
|
|
107
|
-
before
|
107
|
+
before do
|
108
108
|
Task['dev'].invoke
|
109
|
-
|
109
|
+
end
|
110
110
|
|
111
111
|
it 'should store configuration in configatron singleton' do
|
112
112
|
expect(Loader).to have_received(:load_configuration).with(anything, configatron, any_args)
|
@@ -118,7 +118,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
118
118
|
it 'should load all files' do
|
119
119
|
expect(Loader)
|
120
120
|
.to have_received(:load_configuration)
|
121
|
-
|
121
|
+
.with(hash_including(config_files: %w(config/default.yaml config/dev.yaml config/local.yaml)), any_args)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -128,7 +128,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
128
128
|
it 'should load environment file and local file' do
|
129
129
|
expect(Loader)
|
130
130
|
.to have_received(:load_configuration)
|
131
|
-
|
131
|
+
.with(hash_including(config_files: %w(config/dev.yaml config/local.yaml)), any_args)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -136,31 +136,33 @@ describe Rake::Funnel::Tasks::Environments do
|
|
136
136
|
let(:optional) { 'config/local.yaml' }
|
137
137
|
|
138
138
|
it 'should load default file and environment file' do
|
139
|
-
expect(Loader)
|
140
|
-
|
139
|
+
expect(Loader).to \
|
140
|
+
have_received(:load_configuration)
|
141
|
+
.with(hash_including(config_files: %w(config/default.yaml config/dev.yaml)),
|
142
|
+
any_args)
|
141
143
|
end
|
142
144
|
end
|
143
145
|
end
|
144
146
|
|
145
147
|
describe 'customization' do
|
146
148
|
let(:customizer) { proc {} }
|
147
|
-
let(:files)
|
149
|
+
let(:files) do
|
148
150
|
%w(config/dev.yaml)
|
149
|
-
|
151
|
+
end
|
150
152
|
|
151
|
-
subject!
|
153
|
+
subject! do
|
152
154
|
described_class.new do |t|
|
153
155
|
t.customizer = customizer
|
154
156
|
end
|
155
|
-
|
157
|
+
end
|
156
158
|
|
157
|
-
before
|
159
|
+
before do
|
158
160
|
allow(Loader).to receive(:load_configuration)
|
159
|
-
|
161
|
+
end
|
160
162
|
|
161
|
-
before
|
163
|
+
before do
|
162
164
|
Task['dev'].invoke
|
163
|
-
|
165
|
+
end
|
164
166
|
|
165
167
|
it 'should pass customizer to loader' do
|
166
168
|
expect(Loader).to have_received(:load_configuration).with(anything, anything, customizer)
|
@@ -168,21 +170,21 @@ describe Rake::Funnel::Tasks::Environments do
|
|
168
170
|
end
|
169
171
|
|
170
172
|
describe 'automatic environment setup' do
|
171
|
-
let(:files)
|
173
|
+
let(:files) do
|
172
174
|
%w(config/dev.yaml config/production.yaml)
|
173
|
-
|
175
|
+
end
|
174
176
|
|
175
|
-
before
|
177
|
+
before do
|
176
178
|
Rake.application.top_level_tasks.clear
|
177
179
|
Rake.application.top_level_tasks.push(*top_level_tasks)
|
178
|
-
|
180
|
+
end
|
179
181
|
|
180
182
|
context 'environment task defined in top-level Rake namespace' do
|
181
|
-
subject!
|
183
|
+
subject! do
|
182
184
|
described_class.new do |t|
|
183
185
|
t.default_env = default_env
|
184
186
|
end
|
185
|
-
|
187
|
+
end
|
186
188
|
|
187
189
|
context 'no default environment configured' do
|
188
190
|
let(:default_env) { nil }
|
@@ -215,7 +217,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
215
217
|
end
|
216
218
|
|
217
219
|
context 'environment task defined in Rake namespace' do
|
218
|
-
subject!
|
220
|
+
subject! do
|
219
221
|
namespace :foo do
|
220
222
|
namespace :bar do
|
221
223
|
described_class.new do |t|
|
@@ -223,7 +225,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
223
225
|
end
|
224
226
|
end
|
225
227
|
end
|
226
|
-
|
228
|
+
end
|
227
229
|
|
228
230
|
context 'default environment configured' do
|
229
231
|
let(:default_env) { 'dev' }
|