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,149 +1,149 @@
1
- include Rake
2
- include Rake::Funnel::Integration
3
-
4
- describe Rake::Funnel::Integration::ProgressReport do
5
- include DSL
6
-
7
- let(:teamcity_running?) { false }
8
-
9
- before {
10
- allow($stdout).to receive(:puts)
11
- allow(TeamCity).to receive(:running?).and_return(teamcity_running?)
12
-
13
- Task.clear
14
- }
15
-
16
- after {
17
- subject.disable!
18
- }
19
-
20
- describe 'defaults' do
21
- subject! {
22
- described_class.new
23
- }
24
-
25
- before {
26
- task :task
27
-
28
- Task[:task].invoke
29
- }
30
-
31
- context 'not on TeamCity' do
32
- it 'should write task name in square brackets' do
33
- expect($stdout).to have_received(:puts).with("\n[task]")
34
- end
35
- end
36
-
37
- context 'on TeamCity' do
38
- let(:teamcity_running?) { true }
39
-
40
- it 'should not write task name in square brackets since it would clutter the output' do
41
- expect($stdout).to_not have_received(:puts).with("\n[task]")
42
- end
43
- end
44
- end
45
-
46
- context 'when progess report was disabled' do
47
- subject! {
48
- described_class.new
49
- }
50
-
51
- before {
52
- subject.disable!
53
-
54
- task :task
55
-
56
- Task[:task].invoke
57
- }
58
-
59
- it 'should not write' do
60
- expect($stdout).to_not have_received(:puts).with("\n[task]")
61
- end
62
- end
63
-
64
- describe 'custom event handlers' do
65
- let(:receiver) { double.as_null_object }
66
-
67
- subject! {
68
- described_class.new do |r|
69
- r.task_starting do |task, args|
70
- receiver.starting({
71
- task: task,
72
- args: args
73
- })
74
- end
75
-
76
- r.task_finished do |task, args, error|
77
- receiver.finished({
78
- task: task,
79
- args: args,
80
- error: error
81
- })
82
- end
83
- end
84
- }
85
-
86
- context 'when task succeeds' do
87
- before {
88
- task :task
89
-
90
- Task[:task].invoke
91
- }
92
-
93
- describe 'starting handler' do
94
- it 'should run' do
95
- expect(receiver).to have_received(:starting)
96
- end
97
-
98
- it 'should receive task' do
99
- expect(receiver).to have_received(:starting).with(hash_including({ task: kind_of(Task) }))
100
- end
101
-
102
- it 'should receive task arguments' do
103
- expect(receiver).to have_received(:starting).with(hash_including({ args: kind_of(TaskArguments) }))
104
- end
105
- end
106
-
107
- describe 'finished handler' do
108
- it 'should run' do
109
- expect(receiver).to have_received(:finished)
110
- end
111
-
112
- it 'should receive task' do
113
- expect(receiver).to have_received(:finished).with(hash_including({ task: kind_of(Task) }))
114
- end
115
-
116
- it 'should receive task arguments' do
117
- expect(receiver).to have_received(:finished).with(hash_including({ args: kind_of(TaskArguments) }))
118
- end
119
-
120
- it 'should not receive error' do
121
- expect(receiver).to have_received(:finished).with(hash_including({ error: nil }))
122
- end
123
- end
124
- end
125
-
126
- context 'when task fails' do
127
- class SpecificError < StandardError; end
128
-
129
- let(:error) { SpecificError.new('task error') }
130
-
131
- before {
132
- task :task do
133
- raise error
134
- end
135
-
136
- begin
137
- Task[:task].invoke
138
- rescue SpecificError
139
- end
140
- }
141
-
142
- describe 'finished handler' do
143
- it 'should receive error' do
144
- expect(receiver).to have_received(:finished).with(hash_including({ error: error }))
145
- end
146
- end
147
- end
148
- end
149
- end
1
+ include Rake
2
+ include Rake::Funnel::Integration
3
+
4
+ describe Rake::Funnel::Integration::ProgressReport do
5
+ include DSL
6
+
7
+ let(:teamcity_running?) { false }
8
+
9
+ before {
10
+ allow($stdout).to receive(:puts)
11
+ allow(TeamCity).to receive(:running?).and_return(teamcity_running?)
12
+
13
+ Task.clear
14
+ }
15
+
16
+ after {
17
+ subject.disable!
18
+ }
19
+
20
+ describe 'defaults' do
21
+ subject! {
22
+ described_class.new
23
+ }
24
+
25
+ before {
26
+ task :task
27
+
28
+ Task[:task].invoke
29
+ }
30
+
31
+ context 'not on TeamCity' do
32
+ it 'should write task name in square brackets' do
33
+ expect($stdout).to have_received(:puts).with("\n[task]")
34
+ end
35
+ end
36
+
37
+ context 'on TeamCity' do
38
+ let(:teamcity_running?) { true }
39
+
40
+ it 'should not write task name in square brackets since it would clutter the output' do
41
+ expect($stdout).to_not have_received(:puts).with("\n[task]")
42
+ end
43
+ end
44
+ end
45
+
46
+ context 'when progess report was disabled' do
47
+ subject {
48
+ described_class.new
49
+ }
50
+
51
+ before {
52
+ subject.disable!
53
+
54
+ task :task
55
+
56
+ Task[:task].invoke
57
+ }
58
+
59
+ it 'should not write' do
60
+ expect($stdout).to_not have_received(:puts).with("\n[task]")
61
+ end
62
+ end
63
+
64
+ describe 'custom event handlers' do
65
+ let(:receiver) { double.as_null_object }
66
+
67
+ subject! {
68
+ described_class.new do |r|
69
+ r.task_starting do |task, args|
70
+ receiver.task_starting({
71
+ task: task,
72
+ args: args
73
+ })
74
+ end
75
+
76
+ r.task_finished do |task, args, error|
77
+ receiver.task_finished({
78
+ task: task,
79
+ args: args,
80
+ error: error
81
+ })
82
+ end
83
+ end
84
+ }
85
+
86
+ context 'when task succeeds' do
87
+ before {
88
+ task :task
89
+
90
+ Task[:task].invoke
91
+ }
92
+
93
+ describe 'starting handler' do
94
+ it 'should run' do
95
+ expect(receiver).to have_received(:task_starting)
96
+ end
97
+
98
+ it 'should receive task' do
99
+ expect(receiver).to have_received(:task_starting).with(hash_including({ task: kind_of(Task) }))
100
+ end
101
+
102
+ it 'should receive task arguments' do
103
+ expect(receiver).to have_received(:task_starting).with(hash_including({ args: kind_of(TaskArguments) }))
104
+ end
105
+ end
106
+
107
+ describe 'finished handler' do
108
+ it 'should run' do
109
+ expect(receiver).to have_received(:task_finished)
110
+ end
111
+
112
+ it 'should receive task' do
113
+ expect(receiver).to have_received(:task_finished).with(hash_including({ task: kind_of(Task) }))
114
+ end
115
+
116
+ it 'should receive task arguments' do
117
+ expect(receiver).to have_received(:task_finished).with(hash_including({ args: kind_of(TaskArguments) }))
118
+ end
119
+
120
+ it 'should not receive error' do
121
+ expect(receiver).to have_received(:task_finished).with(hash_including({ error: nil }))
122
+ end
123
+ end
124
+ end
125
+
126
+ context 'when task fails' do
127
+ class SpecificError < StandardError; end
128
+
129
+ let(:error) { SpecificError.new('task error') }
130
+
131
+ before {
132
+ task :task do
133
+ raise error
134
+ end
135
+
136
+ begin
137
+ Task[:task].invoke
138
+ rescue SpecificError
139
+ end
140
+ }
141
+
142
+ describe 'finished handler' do
143
+ it 'should receive error' do
144
+ expect(receiver).to have_received(:task_finished).with(hash_including({ error: error }))
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
@@ -1,16 +1,16 @@
1
- describe Rake::Funnel::Integration::SyncOutput do
2
- before {
3
- allow($stdout).to receive(:sync=)
4
- allow($stderr).to receive(:sync=)
5
-
6
- expect(subject).to be
7
- }
8
-
9
- it 'should immediately flush stdout' do
10
- expect($stdout).to have_received(:sync=).with(true)
11
- end
12
-
13
- it 'should immediately flush stderr' do
14
- expect($stdout).to have_received(:sync=).with(true)
15
- end
16
- end
1
+ describe Rake::Funnel::Integration::SyncOutput do
2
+ before {
3
+ allow($stdout).to receive(:sync=)
4
+ allow($stderr).to receive(:sync=)
5
+
6
+ expect(subject).to be
7
+ }
8
+
9
+ it 'should immediately flush stdout' do
10
+ expect($stdout).to have_received(:sync=).with(true)
11
+ end
12
+
13
+ it 'should immediately flush stderr' do
14
+ expect($stdout).to have_received(:sync=).with(true)
15
+ end
16
+ end
@@ -1,110 +1,110 @@
1
- include Rake::Funnel::Support
2
-
3
- describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
4
- before {
5
- allow(ENV).to receive(:[]).with(described_class::ENV_VAR).and_return(env_var)
6
- allow(Which).to receive(:which).and_return(which)
7
- allow(Dir).to receive(:glob).and_return([])
8
- allow(RakeFileUtils).to receive(:mkdir_p)
9
- allow(Rake).to receive(:rake_output_message)
10
- }
11
-
12
- before {
13
- allow(BinaryVersionReader).to receive(:read_from).with(which).and_return(nunit_version)
14
- }
15
-
16
- describe 'success' do
17
- let(:env_var) { '/path/to/nunit plugins/nunit' }
18
- let(:addin_dlls) { [env_var + 'addin.dll'] }
19
- let(:which) { 'path/to/nunit-console.exe' }
20
- let(:nunit_version) { VersionInfo.new({ file_version: '1.2.3.4' }) }
21
- let(:plugin_version) { nunit_version.file_version.split('.').take(3).join('.') }
22
-
23
- before {
24
- allow(Dir).to receive(:glob).and_return(addin_dlls)
25
- allow(RakeFileUtils).to receive(:cp)
26
- }
27
-
28
- before {
29
- described_class.setup('nunit-console.exe')
30
- }
31
-
32
- it 'should create addin directory' do
33
- expect(RakeFileUtils).to have_received(:mkdir_p).with(File.join(File.dirname(which), 'addins'))
34
- end
35
-
36
- it 'should enumerate addin files' do
37
- expect(Dir).to have_received(:glob).with(/#{Regexp.escape("#{env_var}-#{plugin_version}\.*")}$/)
38
- end
39
-
40
- it 'should copy the addin from TeamCity to NUnit' do
41
- expect(RakeFileUtils).to have_received(:cp).with(addin_dlls, File.join(File.dirname(which), 'addins'), { preserve: true })
42
- end
43
-
44
- it 'should report that the addin is installed' do
45
- expect(Rake).to have_received(:rake_output_message).with("Installing TeamCity NUnit addin for version #{plugin_version} in #{which}")
46
- end
47
-
48
- context 'Windows-style path in environment variable', platform: :win32 do
49
- let(:env_var) { 'C:\path\to\nunit plugins\nunit-' }
50
-
51
- it 'should convert path to Ruby-style' do
52
- expect(Dir).to have_received(:glob).with(%r|^C:/path/to/nunit plugins/nunit-|)
53
- end
54
- end
55
- end
56
-
57
- describe 'failures' do
58
- let(:env_var) { nil }
59
- let(:which) { nil }
60
- let(:nunit_version) { VersionInfo.new }
61
-
62
- before {
63
- described_class.setup('nunit-console.exe')
64
- }
65
-
66
- context 'TeamCity plugin path not in environment' do
67
- let(:env_var) { nil }
68
-
69
- it 'should skip reading the version' do
70
- expect(BinaryVersionReader).to_not have_received(:read_from)
71
- end
72
- end
73
-
74
- context 'NUnit executable not found' do
75
- let(:env_var) { '/path/to/nunit plugins/nunit' }
76
- let(:which) { nil }
77
-
78
- it 'should skip reading the version' do
79
- expect(BinaryVersionReader).to_not have_received(:read_from)
80
- end
81
- end
82
-
83
- context 'NUnit executable without version' do
84
- let(:env_var) { '/path/to/nunit plugins/nunit' }
85
- let(:which) { 'path/to/nunit-console.exe' }
86
-
87
- it 'should report that the version could not be read' do
88
- expect(Rake).to have_received(:rake_output_message).with("Could read version from NUnit executable in #{which}")
89
- end
90
-
91
- it 'should skip' do
92
- expect(Dir).not_to have_received(:glob)
93
- end
94
- end
95
-
96
- context 'plugin for NUnit version not available' do
97
- let(:env_var) { '/path/to/nunit plugins/nunit' }
98
- let(:which) { 'path/to/nunit-console.exe' }
99
- let(:nunit_version) { VersionInfo.new({ file_version: '1.2.3.4' }) }
100
-
101
- it 'should report that the addin version is not available' do
102
- expect(Rake).to have_received(:rake_output_message).with(/Could not find TeamCity NUnit addin for version 1\.2\.3 in .*#{env_var}$/)
103
- end
104
-
105
- it 'should skip' do
106
- expect(RakeFileUtils).not_to have_received(:mkdir_p)
107
- end
108
- end
109
- end
110
- end
1
+ include Rake::Funnel::Support
2
+
3
+ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
4
+ before {
5
+ allow(ENV).to receive(:[]).with(described_class::ENV_VAR).and_return(env_var)
6
+ allow(Which).to receive(:which).and_return(which)
7
+ allow(Dir).to receive(:glob).and_return([])
8
+ allow(RakeFileUtils).to receive(:mkdir_p)
9
+ allow(Rake).to receive(:rake_output_message)
10
+ }
11
+
12
+ before {
13
+ allow(BinaryVersionReader).to receive(:read_from).with(which).and_return(nunit_version)
14
+ }
15
+
16
+ describe 'success' do
17
+ let(:env_var) { '/path/to/nunit plugins/nunit' }
18
+ let(:addin_dlls) { [env_var + 'addin.dll'] }
19
+ let(:which) { 'path/to/nunit-console.exe' }
20
+ let(:nunit_version) { VersionInfo.new({ file_version: '1.2.3.4' }) }
21
+ let(:plugin_version) { nunit_version.file_version.split('.').take(3).join('.') }
22
+
23
+ before {
24
+ allow(Dir).to receive(:glob).and_return(addin_dlls)
25
+ allow(RakeFileUtils).to receive(:cp)
26
+ }
27
+
28
+ before {
29
+ described_class.setup('nunit-console.exe')
30
+ }
31
+
32
+ it 'should create addin directory' do
33
+ expect(RakeFileUtils).to have_received(:mkdir_p).with(File.join(File.dirname(which), 'addins'))
34
+ end
35
+
36
+ it 'should enumerate addin files' do
37
+ expect(Dir).to have_received(:glob).with(/#{Regexp.escape("#{env_var}-#{plugin_version}\.*")}$/)
38
+ end
39
+
40
+ it 'should copy the addin from TeamCity to NUnit' do
41
+ expect(RakeFileUtils).to have_received(:cp).with(addin_dlls, File.join(File.dirname(which), 'addins'), preserve: true)
42
+ end
43
+
44
+ it 'should report that the addin is installed' do
45
+ expect(Rake).to have_received(:rake_output_message).with("Installing TeamCity NUnit addin for version #{plugin_version} in #{which}")
46
+ end
47
+
48
+ context 'Windows-style path in environment variable', platform: :win32 do
49
+ let(:env_var) { 'C:\path\to\nunit plugins\nunit-' }
50
+
51
+ it 'should convert path to Ruby-style' do
52
+ expect(Dir).to have_received(:glob).with(%r|^C:/path/to/nunit plugins/nunit-|)
53
+ end
54
+ end
55
+ end
56
+
57
+ describe 'failures' do
58
+ let(:env_var) { nil }
59
+ let(:which) { nil }
60
+ let(:nunit_version) { VersionInfo.new }
61
+
62
+ before {
63
+ described_class.setup('nunit-console.exe')
64
+ }
65
+
66
+ context 'TeamCity plugin path not in environment' do
67
+ let(:env_var) { nil }
68
+
69
+ it 'should skip reading the version' do
70
+ expect(BinaryVersionReader).to_not have_received(:read_from)
71
+ end
72
+ end
73
+
74
+ context 'NUnit executable not found' do
75
+ let(:env_var) { '/path/to/nunit plugins/nunit' }
76
+ let(:which) { nil }
77
+
78
+ it 'should skip reading the version' do
79
+ expect(BinaryVersionReader).to_not have_received(:read_from)
80
+ end
81
+ end
82
+
83
+ context 'NUnit executable without version' do
84
+ let(:env_var) { '/path/to/nunit plugins/nunit' }
85
+ let(:which) { 'path/to/nunit-console.exe' }
86
+
87
+ it 'should report that the version could not be read' do
88
+ expect(Rake).to have_received(:rake_output_message).with("Could read version from NUnit executable in #{which}")
89
+ end
90
+
91
+ it 'should skip' do
92
+ expect(Dir).not_to have_received(:glob)
93
+ end
94
+ end
95
+
96
+ context 'plugin for NUnit version not available' do
97
+ let(:env_var) { '/path/to/nunit plugins/nunit' }
98
+ let(:which) { 'path/to/nunit-console.exe' }
99
+ let(:nunit_version) { VersionInfo.new({ file_version: '1.2.3.4' }) }
100
+
101
+ it 'should report that the addin version is not available' do
102
+ expect(Rake).to have_received(:rake_output_message).with(/Could not find TeamCity NUnit addin for version 1\.2\.3 in .*#{env_var}$/)
103
+ end
104
+
105
+ it 'should skip' do
106
+ expect(RakeFileUtils).not_to have_received(:mkdir_p)
107
+ end
108
+ end
109
+ end
110
+ end