rake-funnel 0.3.2.pre → 0.4.0.pre

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 (122) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -2
  3. data/Gemfile +4 -0
  4. data/README.md +2 -2
  5. data/lib/rake/funnel/ambiguous_file_error.rb +31 -29
  6. data/lib/rake/funnel/execution_error.rb +28 -26
  7. data/lib/rake/funnel/extensions/case/camel_case.rb +24 -19
  8. data/lib/rake/funnel/extensions/case/pascal_case.rb +24 -19
  9. data/lib/rake/funnel/extensions/case.rb +3 -3
  10. data/lib/rake/funnel/extensions/common_path.rb +60 -52
  11. data/lib/rake/funnel/extensions/disable_colors.rb +33 -27
  12. data/lib/rake/funnel/extensions/rexml.rb +27 -23
  13. data/lib/rake/funnel/extensions/shell.rb +92 -56
  14. data/lib/rake/funnel/extensions/windows_path.rb +15 -11
  15. data/lib/rake/funnel/framework.rb +11 -16
  16. data/lib/rake/funnel/integration/progress_report.rb +72 -70
  17. data/lib/rake/funnel/integration/sync_output.rb +12 -8
  18. data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +61 -55
  19. data/lib/rake/funnel/integration/teamcity/progress_report.rb +39 -33
  20. data/lib/rake/funnel/integration/teamcity/service_messages.rb +46 -40
  21. data/lib/rake/funnel/integration/teamcity/teamcity.rb +19 -15
  22. data/lib/rake/funnel/integration/teamcity.rb +3 -5
  23. data/lib/rake/funnel/support/argument_mapper/key_value_pair.rb +16 -10
  24. data/lib/rake/funnel/support/argument_mapper/styles/default.rb +39 -31
  25. data/lib/rake/funnel/support/argument_mapper/styles/msbuild.rb +41 -33
  26. data/lib/rake/funnel/support/argument_mapper/styles/msdeploy.rb +55 -47
  27. data/lib/rake/funnel/support/argument_mapper/styles/nunit.rb +41 -33
  28. data/lib/rake/funnel/support/argument_mapper/styles.rb +3 -5
  29. data/lib/rake/funnel/support/argument_mapper/switch.rb +16 -10
  30. data/lib/rake/funnel/support/argument_mapper/value.rb +16 -10
  31. data/lib/rake/funnel/support/assembly_version/from_version_files.rb +39 -35
  32. data/lib/rake/funnel/support/assembly_version/languages/cs +5 -5
  33. data/lib/rake/funnel/support/assembly_version/languages/fs +12 -12
  34. data/lib/rake/funnel/support/assembly_version/languages/vb +5 -5
  35. data/lib/rake/funnel/support/assembly_version_writer.rb +56 -52
  36. data/lib/rake/funnel/support/binary_version_reader.rb +37 -32
  37. data/lib/rake/funnel/support/copier.rb +31 -27
  38. data/lib/rake/funnel/support/environments/loader.rb +46 -40
  39. data/lib/rake/funnel/support/environments.rb +3 -3
  40. data/lib/rake/funnel/support/internal/finder.rb +55 -51
  41. data/lib/rake/funnel/support/internal/instantiate_symbol.rb +38 -34
  42. data/lib/rake/funnel/support/mapper.rb +57 -53
  43. data/lib/rake/funnel/support/mono.rb +21 -17
  44. data/lib/rake/funnel/support/msbuild/build_tool.rb +30 -24
  45. data/lib/rake/funnel/support/msbuild.rb +3 -3
  46. data/lib/rake/funnel/support/msdeploy/registry_patch.rb +90 -84
  47. data/lib/rake/funnel/support/msdeploy.rb +3 -3
  48. data/lib/rake/funnel/support/patch.rb +41 -37
  49. data/lib/rake/funnel/support/specs_remover.rb +66 -62
  50. data/lib/rake/funnel/support/template_engine.rb +30 -26
  51. data/lib/rake/funnel/support/timing/report.rb +95 -89
  52. data/lib/rake/funnel/support/timing/statistics.rb +32 -26
  53. data/lib/rake/funnel/support/timing.rb +3 -3
  54. data/lib/rake/funnel/support/version_info.rb +103 -72
  55. data/lib/rake/funnel/support/which.rb +19 -15
  56. data/lib/rake/funnel/support/zipper.rb +53 -49
  57. data/lib/rake/funnel/tasks/assembly_version.rb +44 -40
  58. data/lib/rake/funnel/tasks/bin_path.rb +45 -41
  59. data/lib/rake/funnel/tasks/copy.rb +43 -39
  60. data/lib/rake/funnel/tasks/environments.rb +89 -89
  61. data/lib/rake/funnel/tasks/msbuild.rb +55 -51
  62. data/lib/rake/funnel/tasks/msdeploy.rb +54 -50
  63. data/lib/rake/funnel/tasks/nunit.rb +52 -48
  64. data/lib/rake/funnel/tasks/paket.rb +51 -47
  65. data/lib/rake/funnel/tasks/quick_template.rb +53 -49
  66. data/lib/rake/funnel/tasks/side_by_side_specs.rb +41 -37
  67. data/lib/rake/funnel/tasks/timing.rb +108 -104
  68. data/lib/rake/funnel/tasks/zip.rb +46 -42
  69. data/lib/rake/funnel/version.rb +1 -1
  70. data/lib/rake/funnel.rb +7 -7
  71. data/rake-funnel.gemspec +12 -3
  72. data/spec/rake/funnel/execution_error_spec.rb +67 -67
  73. data/spec/rake/funnel/extensions/case/camel_case_spec.rb +17 -17
  74. data/spec/rake/funnel/extensions/case/pascal_case_spec.rb +17 -17
  75. data/spec/rake/funnel/extensions/common_path_spec.rb +56 -56
  76. data/spec/rake/funnel/extensions/disable_colors_spec.rb +33 -33
  77. data/spec/rake/funnel/extensions/rexml_spec.rb +20 -20
  78. data/spec/rake/funnel/extensions/shell_spec.rb +237 -237
  79. data/spec/rake/funnel/extensions/windows_path_spec.rb +5 -5
  80. data/spec/rake/funnel/integration/progress_report_spec.rb +149 -149
  81. data/spec/rake/funnel/integration/sync_output_spec.rb +16 -16
  82. data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +110 -110
  83. data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +174 -174
  84. data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +136 -136
  85. data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +34 -34
  86. data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +222 -222
  87. data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +25 -25
  88. data/spec/rake/funnel/support/argument_mapper/styles/styles_spec.rb +214 -214
  89. data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +66 -61
  90. data/spec/rake/funnel/support/assembly_version_writer_spec.rb +140 -140
  91. data/spec/rake/funnel/support/binary_version_reader_spec.rb +29 -29
  92. data/spec/rake/funnel/support/copier_spec.rb +58 -58
  93. data/spec/rake/funnel/support/environments/loader_spec.rb +143 -143
  94. data/spec/rake/funnel/support/internal/finder_spec.rb +229 -229
  95. data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +182 -183
  96. data/spec/rake/funnel/support/mapper_spec.rb +87 -87
  97. data/spec/rake/funnel/support/mono_spec.rb +57 -57
  98. data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +21 -21
  99. data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +139 -139
  100. data/spec/rake/funnel/support/patch_spec.rb +108 -108
  101. data/spec/rake/funnel/support/specs_remover/Sample.csproj +28 -28
  102. data/spec/rake/funnel/support/specs_remover_spec.rb +116 -116
  103. data/spec/rake/funnel/support/template_engine_spec.rb +65 -65
  104. data/spec/rake/funnel/support/timing/report_spec.rb +129 -129
  105. data/spec/rake/funnel/support/version_info_spec.rb +333 -228
  106. data/spec/rake/funnel/support/which_spec.rb +65 -65
  107. data/spec/rake/funnel/support/zipper_spec.rb +77 -77
  108. data/spec/rake/funnel/tasks/assembly_version_spec.rb +45 -45
  109. data/spec/rake/funnel/tasks/bin_path_spec.rb +52 -52
  110. data/spec/rake/funnel/tasks/copy_spec.rb +44 -44
  111. data/spec/rake/funnel/tasks/environments_spec.rb +249 -247
  112. data/spec/rake/funnel/tasks/msbuild_spec.rb +91 -91
  113. data/spec/rake/funnel/tasks/msdeploy_spec.rb +220 -220
  114. data/spec/rake/funnel/tasks/nunit_spec.rb +74 -74
  115. data/spec/rake/funnel/tasks/paket_spec.rb +140 -142
  116. data/spec/rake/funnel/tasks/quick_template_spec.rb +62 -62
  117. data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +58 -58
  118. data/spec/rake/funnel/tasks/timing_spec.rb +133 -133
  119. data/spec/rake/funnel/tasks/zip_spec.rb +50 -50
  120. data/spec/spec_helper.rb +43 -33
  121. metadata +2 -3
  122. data/lib/rake/funnel/support/side_by_side_specs.rb +0 -3
@@ -1,65 +1,65 @@
1
- require 'tmpdir'
2
-
3
- describe Rake::Funnel::Support::Which do
4
- let(:temp_dir) { Dir.mktmpdir }
5
- let(:executable_path) { File.join(temp_dir, 'executable.exe') }
6
- let(:create_entry) { lambda { |p| FileUtils.touch(p) }}
7
-
8
- before {
9
- create_entry.call(executable_path)
10
-
11
- allow(ENV).to receive(:[]).with('PATH').and_return(temp_dir)
12
- }
13
-
14
- after {
15
- FileUtils.rm_rf(temp_dir)
16
- }
17
-
18
- describe 'executable in PATH' do
19
- context 'found' do
20
- it 'should yield executable' do
21
- expect(described_class.which(File.basename(executable_path))).to eq(executable_path)
22
- end
23
- end
24
-
25
- context 'not found' do
26
- it 'should yield nil' do
27
- expect(described_class.which('does-not-exist.exe')).to be_nil
28
- end
29
- end
30
-
31
- context 'found as directory' do
32
- let(:create_entry) { lambda { |p| FileUtils.mkdir_p(p) } }
33
-
34
- it 'should yield nil' do
35
- expect(described_class.which('executable.exe')).to be_nil
36
- end
37
- end
38
- end
39
-
40
- describe 'executable in current working directory' do
41
- context 'found' do
42
- it 'should yield executable' do
43
- Dir.chdir(temp_dir) do
44
- expect(described_class.which(File.basename(executable_path))).to eq(File.basename(executable_path))
45
- end
46
- end
47
- end
48
-
49
- context 'not found' do
50
- it 'should yield nil' do
51
- Dir.chdir(temp_dir) do
52
- expect(described_class.which('does-not-exist.exe')).to be_nil
53
- end
54
- end
55
- end
56
-
57
- context 'found as directory' do
58
- let(:create_entry) { lambda { |p| FileUtils.mkdir_p(p) } }
59
-
60
- it 'should yield nil' do
61
- expect(described_class.which('executable.exe')).to be_nil
62
- end
63
- end
64
- end
65
- end
1
+ require 'tmpdir'
2
+
3
+ describe Rake::Funnel::Support::Which do
4
+ let(:temp_dir) { Dir.mktmpdir }
5
+ let(:executable_path) { File.join(temp_dir, 'executable.exe') }
6
+ let(:create_entry) { lambda { |p| FileUtils.touch(p) }}
7
+
8
+ before {
9
+ create_entry.call(executable_path)
10
+
11
+ allow(ENV).to receive(:[]).with('PATH').and_return(temp_dir)
12
+ }
13
+
14
+ after {
15
+ FileUtils.rm_rf(temp_dir)
16
+ }
17
+
18
+ describe 'executable in PATH' do
19
+ context 'found' do
20
+ it 'should yield executable' do
21
+ expect(described_class.which(File.basename(executable_path))).to eq(executable_path)
22
+ end
23
+ end
24
+
25
+ context 'not found' do
26
+ it 'should yield nil' do
27
+ expect(described_class.which('does-not-exist.exe')).to be_nil
28
+ end
29
+ end
30
+
31
+ context 'found as directory' do
32
+ let(:create_entry) { lambda { |p| FileUtils.mkdir_p(p) } }
33
+
34
+ it 'should yield nil' do
35
+ expect(described_class.which('executable.exe')).to be_nil
36
+ end
37
+ end
38
+ end
39
+
40
+ describe 'executable in current working directory' do
41
+ context 'found' do
42
+ it 'should yield executable' do
43
+ Dir.chdir(temp_dir) do
44
+ expect(described_class.which(File.basename(executable_path))).to eq(File.basename(executable_path))
45
+ end
46
+ end
47
+ end
48
+
49
+ context 'not found' do
50
+ it 'should yield nil' do
51
+ Dir.chdir(temp_dir) do
52
+ expect(described_class.which('does-not-exist.exe')).to be_nil
53
+ end
54
+ end
55
+ end
56
+
57
+ context 'found as directory' do
58
+ let(:create_entry) { lambda { |p| FileUtils.mkdir_p(p) } }
59
+
60
+ it 'should yield nil' do
61
+ expect(described_class.which('executable.exe')).to be_nil
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,77 +1,77 @@
1
- include Rake::Funnel::Support
2
-
3
- describe Rake::Funnel::Support::Zipper do
4
- describe '#zip' do
5
- let(:source) { %w(bin/1 bin/2 bin/3/4) }
6
-
7
- context 'failure' do
8
- context 'target not defined' do
9
- let(:target) { nil }
10
-
11
- it 'should fail' do
12
- expect { described_class.zip(source, target) }.to raise_error(/Target not defined/)
13
- end
14
- end
15
- end
16
-
17
- context 'success' do
18
- let(:target) { 'some path/file.zip' }
19
- let(:zip_root) { nil }
20
- let(:zip) { instance_double(::Zip::File).as_null_object }
21
- let(:mtime) { Time.new(2015, 3, 9) }
22
- let(:zip_entry) { double(::Zip::Entry).as_null_object }
23
-
24
- before {
25
- allow(RakeFileUtils).to receive(:mkdir_p)
26
- }
27
-
28
- before {
29
- allow(::Zip::File).to receive(:open).with(target, ::Zip::File::CREATE).and_yield(zip)
30
- allow(zip).to receive(:add).and_return(zip_entry)
31
- allow(File).to receive(:mtime).and_return(mtime)
32
- }
33
-
34
- before {
35
- described_class.zip(source, target, zip_root)
36
- }
37
-
38
- it 'should create the target directory' do
39
- expect(RakeFileUtils).to have_received(:mkdir_p).with(File.dirname(target))
40
- end
41
-
42
- describe 'configuration' do
43
- it 'should allow unicode names' do
44
- expect(::Zip.unicode_names).to eq(true)
45
- end
46
-
47
- it 'should use best compression' do
48
- expect(::Zip.default_compression).to eq(Zlib::BEST_COMPRESSION)
49
- end
50
- end
51
-
52
- describe 'work-around for https://github.com/rubyzip/rubyzip/issues/176' do
53
- it 'should explicitly set the file mtime' do
54
- expect(zip_entry).to have_received(:time=).with(mtime).exactly(source.length).times
55
- end
56
- end
57
-
58
- describe 'common path' do
59
- it 'should remove the common path from the source' do
60
- expect(zip).not_to have_received(:add).with(/#{source.common_path}/, anything)
61
- end
62
- end
63
-
64
- describe 'zip root' do
65
- [nil, '', 'some path/inside the zip file'].each do |root|
66
- context "with '#{root || 'nil'}'" do
67
- let(:zip_root) { root }
68
-
69
- it "should put files below #{(root.nil? || root.empty?) ? 'the root' : "'#{root}'"}" do
70
- expect(zip).to have_received(:add).with(/^#{root}/, anything).exactly(source.length).times
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
77
- end
1
+ include Rake::Funnel::Support
2
+
3
+ describe Rake::Funnel::Support::Zipper do
4
+ describe '#zip' do
5
+ let(:source) { %w(bin/1 bin/2 bin/3/4) }
6
+
7
+ context 'failure' do
8
+ context 'target not defined' do
9
+ let(:target) { nil }
10
+
11
+ it 'should fail' do
12
+ expect { described_class.zip(source, target) }.to raise_error(/Target not defined/)
13
+ end
14
+ end
15
+ end
16
+
17
+ context 'success' do
18
+ let(:target) { 'some path/file.zip' }
19
+ let(:zip_root) { nil }
20
+ let(:zip) { instance_double(::Zip::File).as_null_object }
21
+ let(:mtime) { Time.new(2015, 3, 9) }
22
+ let(:zip_entry) { double(::Zip::Entry).as_null_object }
23
+
24
+ before {
25
+ allow(RakeFileUtils).to receive(:mkdir_p)
26
+ }
27
+
28
+ before {
29
+ allow(::Zip::File).to receive(:open).with(target, ::Zip::File::CREATE).and_yield(zip)
30
+ allow(zip).to receive(:add).and_return(zip_entry)
31
+ allow(File).to receive(:mtime).and_return(mtime)
32
+ }
33
+
34
+ before {
35
+ described_class.zip(source, target, zip_root)
36
+ }
37
+
38
+ it 'should create the target directory' do
39
+ expect(RakeFileUtils).to have_received(:mkdir_p).with(File.dirname(target))
40
+ end
41
+
42
+ describe 'configuration' do
43
+ it 'should allow unicode names' do
44
+ expect(::Zip.unicode_names).to eq(true)
45
+ end
46
+
47
+ it 'should use best compression' do
48
+ expect(::Zip.default_compression).to eq(Zlib::BEST_COMPRESSION)
49
+ end
50
+ end
51
+
52
+ describe 'work-around for https://github.com/rubyzip/rubyzip/issues/176' do
53
+ it 'should explicitly set the file mtime' do
54
+ expect(zip_entry).to have_received(:time=).with(mtime).exactly(source.length).times
55
+ end
56
+ end
57
+
58
+ describe 'common path' do
59
+ it 'should remove the common path from the source' do
60
+ expect(zip).not_to have_received(:add).with(/#{source.common_path}/, anything)
61
+ end
62
+ end
63
+
64
+ describe 'zip root' do
65
+ [nil, '', 'some path/inside the zip file'].each do |root|
66
+ context "with '#{root || 'nil'}'" do
67
+ let(:zip_root) { root }
68
+
69
+ it "should put files below #{(root.nil? || root.empty?) ? 'the root' : "'#{root}'"}" do
70
+ expect(zip).to have_received(:add).with(/^#{root}/, anything).exactly(source.length).times
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -1,45 +1,45 @@
1
- include Rake
2
- include Rake::Funnel::Support
3
-
4
- describe Rake::Funnel::Tasks::AssemblyVersion do
5
- before {
6
- Task.clear
7
- }
8
-
9
- describe 'defaults' do
10
- its(:name) { should == :version }
11
- its(:language) { should == :cs }
12
- its(:source) { should == :FromVersionFiles }
13
- its(:source_args) { should == {} }
14
- its(:target_path) { should be_an_instance_of(Proc) }
15
- end
16
-
17
- describe 'execution' do
18
- let(:writer) { instance_double(AssemblyVersionWriter).as_null_object }
19
-
20
- before {
21
- allow(AssemblyVersionWriter).to receive(:new).and_return(writer)
22
- }
23
-
24
- subject {
25
- described_class.new(:name) do |t|
26
- t.language = [:cs, :vb]
27
- t.source = %w(one two)
28
- t.source_args = { foo: 42 }
29
- t.target_path = 'will not work'
30
- end
31
- }
32
-
33
- before {
34
- Task[subject.name].invoke
35
- }
36
-
37
- it 'should pass source and source_args' do
38
- expect(AssemblyVersionWriter).to have_received(:new).with(subject.source, subject.source_args)
39
- end
40
-
41
- it 'should use writer' do
42
- expect(writer).to have_received(:write).with(subject.target_path, subject.language)
43
- end
44
- end
45
- end
1
+ include Rake
2
+ include Rake::Funnel::Support
3
+
4
+ describe Rake::Funnel::Tasks::AssemblyVersion do
5
+ before {
6
+ Task.clear
7
+ }
8
+
9
+ describe 'defaults' do
10
+ its(:name) { should == :version }
11
+ its(:language) { should == :cs }
12
+ its(:source) { should == :FromVersionFiles }
13
+ its(:source_args) { should == {} }
14
+ its(:target_path) { should be_an_instance_of(Proc) }
15
+ end
16
+
17
+ describe 'execution' do
18
+ let(:writer) { instance_double(AssemblyVersionWriter).as_null_object }
19
+
20
+ before {
21
+ allow(AssemblyVersionWriter).to receive(:new).and_return(writer)
22
+ }
23
+
24
+ subject {
25
+ described_class.new(:name) do |t|
26
+ t.language = [:cs, :vb]
27
+ t.source = %w(one two)
28
+ t.source_args = { foo: 42 }
29
+ t.target_path = 'will not work'
30
+ end
31
+ }
32
+
33
+ before {
34
+ Task[subject.name].invoke
35
+ }
36
+
37
+ it 'should pass source and source_args' do
38
+ expect(AssemblyVersionWriter).to have_received(:new).with(subject.source, subject.source_args)
39
+ end
40
+
41
+ it 'should use writer' do
42
+ expect(writer).to have_received(:write).with(subject.target_path, subject.language)
43
+ end
44
+ end
45
+ end
@@ -1,52 +1,52 @@
1
- include Rake
2
-
3
- describe Rake::Funnel::Tasks::BinPath do
4
- before {
5
- Task.clear
6
- }
7
-
8
- describe 'defaults' do
9
- its(:name) { should == :bin_path }
10
- its(:search_pattern) { should eq(%w(tools/* tools/*/bin packages/**/tools)) }
11
- end
12
-
13
- describe 'execution' do
14
- let(:default_path) { 'default PATH contents' }
15
- let(:search_pattern) { %w(foo bar) }
16
-
17
- before {
18
- allow(ENV).to receive(:[]).with('PATH').and_return(default_path)
19
- allow(ENV).to receive(:[]=)
20
- allow(Rake).to receive(:rake_output_message)
21
- }
22
-
23
- before {
24
- allow(Dir).to receive(:[]).with(*search_pattern).and_return(search_pattern)
25
- }
26
-
27
- subject {
28
- described_class.new do |t|
29
- t.search_pattern = search_pattern
30
- end
31
- }
32
-
33
- before {
34
- Task[subject.name].invoke
35
- }
36
-
37
- it 'should prepend sorted matching folders to the PATH environment variable' do
38
- paths = search_pattern.map { |path| File.expand_path(path) }.sort.join(File::PATH_SEPARATOR)
39
-
40
- expect(ENV).to have_received(:[]=).with('PATH',/^#{paths}/)
41
- end
42
-
43
- it 'should append original PATH environment variable' do
44
- expect(ENV).to have_received(:[]=).with('PATH', /#{default_path}$/)
45
- end
46
-
47
- it 'should report added paths' do
48
- expect(Rake).to have_received(:rake_output_message).with(%r|/foo$|)
49
- expect(Rake).to have_received(:rake_output_message).with(%r|/bar$|)
50
- end
51
- end
52
- end
1
+ include Rake
2
+
3
+ describe Rake::Funnel::Tasks::BinPath do
4
+ before {
5
+ Task.clear
6
+ }
7
+
8
+ describe 'defaults' do
9
+ its(:name) { should == :bin_path }
10
+ its(:search_pattern) { should eq(%w(tools/* tools/*/bin packages/**/tools)) }
11
+ end
12
+
13
+ describe 'execution' do
14
+ let(:default_path) { 'default PATH contents' }
15
+ let(:search_pattern) { %w(foo bar) }
16
+
17
+ before {
18
+ allow(ENV).to receive(:[]).with('PATH').and_return(default_path)
19
+ allow(ENV).to receive(:[]=)
20
+ allow(Rake).to receive(:rake_output_message)
21
+ }
22
+
23
+ before {
24
+ allow(Dir).to receive(:[]).with(*search_pattern).and_return(search_pattern)
25
+ }
26
+
27
+ subject {
28
+ described_class.new do |t|
29
+ t.search_pattern = search_pattern
30
+ end
31
+ }
32
+
33
+ before {
34
+ Task[subject.name].invoke
35
+ }
36
+
37
+ it 'should prepend sorted matching folders to the PATH environment variable' do
38
+ paths = search_pattern.map { |path| File.expand_path(path) }.sort.join(File::PATH_SEPARATOR)
39
+
40
+ expect(ENV).to have_received(:[]=).with('PATH',/^#{paths}/)
41
+ end
42
+
43
+ it 'should append original PATH environment variable' do
44
+ expect(ENV).to have_received(:[]=).with('PATH', /#{default_path}$/)
45
+ end
46
+
47
+ it 'should report added paths' do
48
+ expect(Rake).to have_received(:rake_output_message).with(%r|/foo$|)
49
+ expect(Rake).to have_received(:rake_output_message).with(%r|/bar$|)
50
+ end
51
+ end
52
+ end
@@ -1,44 +1,44 @@
1
- include Rake
2
- include Rake::Funnel::Support
3
-
4
- describe Rake::Funnel::Tasks::Copy do
5
- before {
6
- Task.clear
7
- }
8
-
9
- describe 'defaults' do
10
- its(:name) { should == :copy }
11
- its(:source) { should eq([]) }
12
- its(:target) { should be_nil }
13
- end
14
-
15
- describe 'execution' do
16
- let(:source) { %w(one two) }
17
- let(:target) { 'target' }
18
- let(:finder) { instance_double(Finder).as_null_object }
19
-
20
- before {
21
- allow(finder).to receive(:all_or_default).and_return(source)
22
- allow(Finder).to receive(:new).and_return(finder)
23
- }
24
-
25
- before {
26
- allow(Copier).to receive(:copy)
27
- }
28
-
29
- subject {
30
- described_class.new do |t|
31
- t.source = source
32
- t.target = target
33
- end
34
- }
35
-
36
- before {
37
- Task[subject.name].invoke
38
- }
39
-
40
- it 'should delegate to Copier' do
41
- expect(Copier).to have_received(:copy).with(source, subject.target)
42
- end
43
- end
44
- end
1
+ include Rake
2
+ include Rake::Funnel::Support
3
+
4
+ describe Rake::Funnel::Tasks::Copy do
5
+ before {
6
+ Task.clear
7
+ }
8
+
9
+ describe 'defaults' do
10
+ its(:name) { should == :copy }
11
+ its(:source) { should eq([]) }
12
+ its(:target) { should be_nil }
13
+ end
14
+
15
+ describe 'execution' do
16
+ let(:source) { %w(one two) }
17
+ let(:target) { 'target' }
18
+ let(:finder) { instance_double(Finder).as_null_object }
19
+
20
+ before {
21
+ allow(finder).to receive(:all_or_default).and_return(source)
22
+ allow(Finder).to receive(:new).and_return(finder)
23
+ }
24
+
25
+ before {
26
+ allow(Copier).to receive(:copy)
27
+ }
28
+
29
+ subject {
30
+ described_class.new do |t|
31
+ t.source = source
32
+ t.target = target
33
+ end
34
+ }
35
+
36
+ before {
37
+ Task[subject.name].invoke
38
+ }
39
+
40
+ it 'should delegate to Copier' do
41
+ expect(Copier).to have_received(:copy).with(source, subject.target)
42
+ end
43
+ end
44
+ end