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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.simplecov +24 -0
  4. data/Gemfile +27 -19
  5. data/README.md +1 -1
  6. data/lib/rake/funnel/ambiguous_file_error.rb +1 -0
  7. data/lib/rake/funnel/execution_error.rb +1 -0
  8. data/lib/rake/funnel/extensions/common_path.rb +5 -4
  9. data/lib/rake/funnel/extensions/shell.rb +3 -2
  10. data/lib/rake/funnel/integration/progress_report.rb +3 -2
  11. data/lib/rake/funnel/integration/sync_output.rb +1 -0
  12. data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +2 -1
  13. data/lib/rake/funnel/integration/teamcity/progress_report.rb +1 -1
  14. data/lib/rake/funnel/integration/teamcity/service_messages.rb +8 -3
  15. data/lib/rake/funnel/integration/teamcity/teamcity.rb +5 -4
  16. data/lib/rake/funnel/support/argument_mapper/styles/default.rb +5 -4
  17. data/lib/rake/funnel/support/argument_mapper/styles/msbuild.rb +6 -5
  18. data/lib/rake/funnel/support/argument_mapper/styles/msdeploy.rb +13 -12
  19. data/lib/rake/funnel/support/argument_mapper/styles/nunit.rb +6 -5
  20. data/lib/rake/funnel/support/assembly_version/from_version_files.rb +2 -1
  21. data/lib/rake/funnel/support/assembly_version_writer.rb +1 -0
  22. data/lib/rake/funnel/support/binary_version_reader.rb +14 -7
  23. data/lib/rake/funnel/support/copier.rb +1 -0
  24. data/lib/rake/funnel/support/environments/loader.rb +13 -8
  25. data/lib/rake/funnel/support/internal/finder.rb +2 -1
  26. data/lib/rake/funnel/support/internal/instantiate_symbol.rb +9 -4
  27. data/lib/rake/funnel/support/mapper.rb +7 -6
  28. data/lib/rake/funnel/support/mono.rb +1 -3
  29. data/lib/rake/funnel/support/msbuild/build_tool.rb +35 -12
  30. data/lib/rake/funnel/support/msdeploy/registry_patch.rb +14 -17
  31. data/lib/rake/funnel/support/patch.rb +1 -0
  32. data/lib/rake/funnel/support/specs_remover.rb +14 -11
  33. data/lib/rake/funnel/support/template_engine.rb +1 -0
  34. data/lib/rake/funnel/support/timing/report.rb +11 -10
  35. data/lib/rake/funnel/support/version_info.rb +8 -9
  36. data/lib/rake/funnel/support/zipper.rb +1 -0
  37. data/lib/rake/funnel/tasks/assembly_version.rb +4 -3
  38. data/lib/rake/funnel/tasks/bin_path.rb +3 -2
  39. data/lib/rake/funnel/tasks/copy.rb +2 -1
  40. data/lib/rake/funnel/tasks/environments.rb +13 -9
  41. data/lib/rake/funnel/tasks/msbuild.rb +4 -6
  42. data/lib/rake/funnel/tasks/msdeploy.rb +6 -5
  43. data/lib/rake/funnel/tasks/nunit.rb +3 -2
  44. data/lib/rake/funnel/tasks/paket.rb +2 -1
  45. data/lib/rake/funnel/tasks/quick_template.rb +3 -2
  46. data/lib/rake/funnel/tasks/side_by_side_specs.rb +2 -1
  47. data/lib/rake/funnel/tasks/timing.rb +7 -6
  48. data/lib/rake/funnel/tasks/zip.rb +3 -2
  49. data/lib/rake/funnel/version.rb +1 -1
  50. data/rake-funnel.gemspec +11 -11
  51. data/spec/rake/funnel/execution_error_spec.rb +2 -2
  52. data/spec/rake/funnel/extensions/rexml_spec.rb +5 -2
  53. data/spec/rake/funnel/extensions/shell_spec.rb +26 -17
  54. data/spec/rake/funnel/integration/progress_report_spec.rb +32 -36
  55. data/spec/rake/funnel/integration/sync_output_spec.rb +5 -5
  56. data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +32 -20
  57. data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +31 -25
  58. data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +56 -20
  59. data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +7 -5
  60. data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +2 -0
  61. data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +6 -4
  62. data/spec/rake/funnel/support/argument_mapper/styles/styles_spec.rb +76 -67
  63. data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +17 -19
  64. data/spec/rake/funnel/support/assembly_version_writer_spec.rb +49 -52
  65. data/spec/rake/funnel/support/binary_version_reader_spec.rb +2 -2
  66. data/spec/rake/funnel/support/copier_spec.rb +5 -5
  67. data/spec/rake/funnel/support/environments/loader_spec.rb +32 -32
  68. data/spec/rake/funnel/support/internal/finder_spec.rb +8 -6
  69. data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +27 -27
  70. data/spec/rake/funnel/support/mapper_spec.rb +4 -3
  71. data/spec/rake/funnel/support/mono_spec.rb +7 -7
  72. data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +13 -10
  73. data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +47 -41
  74. data/spec/rake/funnel/support/patch_spec.rb +11 -11
  75. data/spec/rake/funnel/support/specs_remover/project/paket.references +3 -3
  76. data/spec/rake/funnel/support/specs_remover/project/uncompiled-code/paket.references +3 -3
  77. data/spec/rake/funnel/support/specs_remover/project-specific paket.references/Sample.csproj.paket.references +3 -3
  78. data/spec/rake/funnel/support/specs_remover/project-specific paket.references/paket.references +3 -3
  79. data/spec/rake/funnel/support/specs_remover_spec.rb +31 -33
  80. data/spec/rake/funnel/support/template_engine_spec.rb +6 -3
  81. data/spec/rake/funnel/support/timing/report_spec.rb +19 -20
  82. data/spec/rake/funnel/support/trace_spec.rb +6 -6
  83. data/spec/rake/funnel/support/version_info_spec.rb +8 -6
  84. data/spec/rake/funnel/support/which_spec.rb +7 -7
  85. data/spec/rake/funnel/support/zipper_spec.rb +8 -8
  86. data/spec/rake/funnel/tasks/assembly_version_spec.rb +9 -9
  87. data/spec/rake/funnel/tasks/bin_path_spec.rb +23 -21
  88. data/spec/rake/funnel/tasks/copy_spec.rb +10 -10
  89. data/spec/rake/funnel/tasks/environments_spec.rb +48 -46
  90. data/spec/rake/funnel/tasks/msbuild_spec.rb +21 -17
  91. data/spec/rake/funnel/tasks/msdeploy_spec.rb +31 -31
  92. data/spec/rake/funnel/tasks/nunit_spec.rb +12 -10
  93. data/spec/rake/funnel/tasks/paket_spec.rb +25 -21
  94. data/spec/rake/funnel/tasks/quick_template_spec.rb +7 -7
  95. data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +12 -12
  96. data/spec/rake/funnel/tasks/timing_spec.rb +12 -12
  97. data/spec/rake/funnel/tasks/zip_spec.rb +16 -16
  98. data/spec/spec_helper.rb +5 -31
  99. metadata +7 -6
@@ -1,3 +1,5 @@
1
+ # rubocop:disable RSpec/FilePath
2
+
1
3
  include Rake
2
4
  include Rake::Funnel::Integration
3
5
  include Rake::Funnel::Integration::TeamCity
@@ -8,7 +10,7 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
8
10
  let(:teamcity_running?) { false }
9
11
  let(:teamcity_rake_runner?) { false }
10
12
 
11
- before {
13
+ before do
12
14
  allow(TeamCity).to receive(:running?).and_return(teamcity_running?)
13
15
  allow(TeamCity).to receive(:rake_runner?).and_return(teamcity_rake_runner?)
14
16
  allow(ServiceMessages).to receive(:block_opened)
@@ -18,15 +20,15 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
18
20
  allow(ServiceMessages).to receive(:build_problem)
19
21
 
20
22
  Task.clear
21
- }
23
+ end
22
24
 
23
- subject! {
25
+ subject! do
24
26
  described_class.new
25
- }
27
+ end
26
28
 
27
- after {
29
+ after do
28
30
  subject.disable!
29
- }
31
+ end
30
32
 
31
33
  shared_examples :block_report do
32
34
  it 'should write block start' do
@@ -49,14 +51,14 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
49
51
  end
50
52
 
51
53
  context 'when task succeeds' do
52
- before {
54
+ before do
53
55
  task :task
54
56
 
55
57
  Task[:task].invoke
56
- }
58
+ end
57
59
 
58
60
  it 'should not report build problems' do
59
- expect(ServiceMessages).to_not have_received(:build_problem)
61
+ expect(ServiceMessages).not_to have_received(:build_problem)
60
62
  end
61
63
 
62
64
  context 'not on TeamCity' do
@@ -81,7 +83,7 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
81
83
  context 'when task fails' do
82
84
  class SpecificError < StandardError; end
83
85
 
84
- before {
86
+ before do
85
87
  module Rake
86
88
  class ApplicationAbortedException < StandardError
87
89
  attr_reader :inner_exception
@@ -91,28 +93,27 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
91
93
  end
92
94
  end
93
95
  end
94
- }
96
+ end
95
97
 
96
98
  let(:error) { SpecificError.new('task error' * 4000) }
97
99
 
98
- before {
100
+ before do
99
101
  task :task do
100
102
  raise error
101
103
  end
102
104
 
103
105
  begin
104
106
  Task[:task].invoke
105
- rescue ApplicationAbortedException => e
106
- rescue SpecificError => e
107
+ rescue ApplicationAbortedException, SpecificError => e
107
108
  @raised_error = e
108
109
  end
109
- }
110
+ end
110
111
 
111
112
  context 'not on TeamCity' do
112
113
  it_behaves_like :no_block_report
113
114
 
114
115
  it 'should not swallow the error' do
115
- expect(@raised_error).to be_a_kind_of(SpecificError)
116
+ expect(@raised_error).to be_a_kind_of(SpecificError) # rubocop:disable RSpec/InstanceVariable
116
117
  end
117
118
  end
118
119
 
@@ -125,11 +126,15 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
125
126
  end
126
127
 
127
128
  it 'should report the error message' do
128
- expect(ServiceMessages).to have_received(:build_problem).with(hash_including({ description: be_an_instance_of(String) }))
129
+ expect(ServiceMessages).to \
130
+ have_received(:build_problem)
131
+ .with(hash_including(description: be_an_instance_of(String)))
129
132
  end
130
133
 
131
134
  it 'should report the first 4000 characters of the error message' do
132
- expect(ServiceMessages).to have_received(:build_problem).with(hash_including({ description: have(4000).items }))
135
+ expect(ServiceMessages).to \
136
+ have_received(:build_problem)
137
+ .with(hash_including(description: have(4000).items))
133
138
  end
134
139
  end
135
140
 
@@ -143,12 +148,13 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
143
148
 
144
149
  context 'with rake runner' do
145
150
  let(:teamcity_rake_runner?) { true }
146
- let(:error) {
151
+ let(:error) do
147
152
  ApplicationAbortedException.new(SpecificError.new('inner message'))
148
- }
153
+ end
149
154
 
150
- it 'should report the inner error as a build problem (as it will be wrapped in a ApplicationAbortedException)' do
151
- expect(ServiceMessages).to have_received(:build_problem).with({ description: 'inner message' })
155
+ it 'should report the inner error as a build problem (as it will be wrapped in a ApplicationAbortedException)' do # rubocop:disable Metrics/LineLength
156
+ expect(ServiceMessages).to \
157
+ have_received(:build_problem).with(description: 'inner message')
152
158
  end
153
159
 
154
160
  it_behaves_like :no_block_report
@@ -159,16 +165,16 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
159
165
  context 'when progess report was disabled' do
160
166
  let(:teamcity_running?) { true }
161
167
 
162
- before {
168
+ before do
163
169
  subject.disable!
164
170
 
165
171
  task :task
166
172
 
167
173
  Task[:task].invoke
168
- }
174
+ end
169
175
 
170
176
  it 'should not write' do
171
- expect(ServiceMessages).to_not have_received(:block_opened)
177
+ expect(ServiceMessages).not_to have_received(:block_opened)
172
178
  end
173
179
  end
174
180
  end
@@ -1,10 +1,12 @@
1
+ # rubocop:disable RSpec/FilePath
2
+
1
3
  include Rake::Funnel::Integration
2
4
 
3
5
  describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
4
- before {
6
+ before do
5
7
  allow(TeamCity).to receive(:running?).and_return(teamcity_running?)
6
8
  allow($stdout).to receive(:puts)
7
- }
9
+ end
8
10
 
9
11
  context 'when running outside TeamCity' do
10
12
  let(:teamcity_running?) { false }
@@ -22,9 +24,11 @@ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
22
24
  describe 'escaping' do
23
25
  context 'when publishing messages without special characters' do
24
26
  it 'should not escape' do
25
- described_class.progress_start "the message"
27
+ described_class.progress_start 'the message'
26
28
 
27
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart 'the message']")
29
+ expect($stdout).to \
30
+ have_received(:puts)
31
+ .with("##teamcity[progressStart 'the message']")
28
32
  end
29
33
  end
30
34
 
@@ -32,61 +36,81 @@ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
32
36
  it 'should escape apostrophes' do
33
37
  described_class.progress_start "'"
34
38
 
35
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|'']")
39
+ expect($stdout).to \
40
+ have_received(:puts)
41
+ .with("##teamcity[progressStart '|'']")
36
42
  end
37
43
 
38
44
  it 'should escape line feeds' do
39
45
  described_class.progress_start "\n"
40
46
 
41
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|n']")
47
+ expect($stdout).to \
48
+ have_received(:puts)
49
+ .with("##teamcity[progressStart '|n']")
42
50
  end
43
51
 
44
52
  it 'should escape carriage returns' do
45
53
  described_class.progress_start "\r"
46
54
 
47
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|r']")
55
+ expect($stdout).to \
56
+ have_received(:puts)
57
+ .with("##teamcity[progressStart '|r']")
48
58
  end
49
59
 
50
60
  it 'should escape next lines' do
51
61
  described_class.progress_start "\u0085"
52
62
 
53
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|x']")
63
+ expect($stdout).to \
64
+ have_received(:puts)
65
+ .with("##teamcity[progressStart '|x']")
54
66
  end
55
67
 
56
68
  it 'should escape line separators' do
57
69
  described_class.progress_start "\u2028"
58
70
 
59
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|l']")
71
+ expect($stdout).to \
72
+ have_received(:puts)
73
+ .with("##teamcity[progressStart '|l']")
60
74
  end
61
75
 
62
76
  it 'should escape paragraph separators' do
63
77
  described_class.progress_start "\u2029"
64
78
 
65
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|p']")
79
+ expect($stdout).to \
80
+ have_received(:puts)
81
+ .with("##teamcity[progressStart '|p']")
66
82
  end
67
83
 
68
84
  it 'should escape vertical bars' do
69
85
  described_class.progress_start '|'
70
86
 
71
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '||']")
87
+ expect($stdout).to \
88
+ have_received(:puts)
89
+ .with("##teamcity[progressStart '||']")
72
90
  end
73
91
 
74
92
  it 'should escape opening brackets' do
75
93
  described_class.progress_start '['
76
94
 
77
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|[']")
95
+ expect($stdout).to \
96
+ have_received(:puts)
97
+ .with("##teamcity[progressStart '|[']")
78
98
  end
79
99
 
80
100
  it 'should escape closing brackets' do
81
101
  described_class.progress_start ']'
82
102
 
83
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|]']")
103
+ expect($stdout).to \
104
+ have_received(:puts)
105
+ .with("##teamcity[progressStart '|]']")
84
106
  end
85
107
 
86
108
  it 'should escape all special characters in a string' do
87
109
  described_class.progress_start "[\r|\n]"
88
110
 
89
- expect($stdout).to have_received(:puts).with("##teamcity[progressStart '|[|r|||n|]']")
111
+ expect($stdout).to \
112
+ have_received(:puts)
113
+ .with("##teamcity[progressStart '|[|r|||n|]']")
90
114
  end
91
115
  end
92
116
  end
@@ -96,7 +120,9 @@ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
96
120
  it 'should print the service message' do
97
121
  described_class.enable_service_messages
98
122
 
99
- expect($stdout).to have_received(:puts).with('##teamcity[enableServiceMessages]')
123
+ expect($stdout).to \
124
+ have_received(:puts)
125
+ .with('##teamcity[enableServiceMessages]')
100
126
  end
101
127
  end
102
128
 
@@ -104,7 +130,9 @@ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
104
130
  it 'should print the service message' do
105
131
  described_class.progress_message 'the message'
106
132
 
107
- expect($stdout).to have_received(:puts).with("##teamcity[progressMessage 'the message']")
133
+ expect($stdout).to \
134
+ have_received(:puts)
135
+ .with("##teamcity[progressMessage 'the message']")
108
136
  end
109
137
  end
110
138
 
@@ -112,7 +140,9 @@ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
112
140
  it 'should print the service message' do
113
141
  described_class.progress_message 42
114
142
 
115
- expect($stdout).to have_received(:puts).with("##teamcity[progressMessage '42']")
143
+ expect($stdout).to \
144
+ have_received(:puts)
145
+ .with("##teamcity[progressMessage '42']")
116
146
  end
117
147
  end
118
148
 
@@ -120,7 +150,9 @@ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
120
150
  it 'should print the service message' do
121
151
  described_class.block_opened(name: 'block name')
122
152
 
123
- expect($stdout).to have_received(:puts).with("##teamcity[blockOpened name='block name']")
153
+ expect($stdout).to \
154
+ have_received(:puts)
155
+ .with("##teamcity[blockOpened name='block name']")
124
156
  end
125
157
  end
126
158
 
@@ -128,7 +160,9 @@ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
128
160
  it 'should print the service message' do
129
161
  described_class.test_started(name: 'test name', captureStandardOutput: true)
130
162
 
131
- expect($stdout).to have_received(:puts).with("##teamcity[testStarted name='test name' captureStandardOutput='true']")
163
+ expect($stdout).to \
164
+ have_received(:puts)
165
+ .with("##teamcity[testStarted name='test name' captureStandardOutput='true']")
132
166
  end
133
167
  end
134
168
 
@@ -136,7 +170,9 @@ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
136
170
  it 'should print the service message' do
137
171
  described_class.test_started(capture_standard_output: true)
138
172
 
139
- expect($stdout).to have_received(:puts).with("##teamcity[testStarted captureStandardOutput='true']")
173
+ expect($stdout).to \
174
+ have_received(:puts)
175
+ .with("##teamcity[testStarted captureStandardOutput='true']")
140
176
  end
141
177
  end
142
178
  end
@@ -1,8 +1,10 @@
1
+ # rubocop:disable RSpec/FilePath
2
+
1
3
  describe Rake::Funnel::Integration::TeamCity do
2
4
  describe 'runner detection' do
3
- before {
5
+ before do
4
6
  allow(ENV).to receive(:include?).with(described_class::PROJECT_ENV_VAR).and_return(teamcity_running?)
5
- }
7
+ end
6
8
 
7
9
  context 'when running outside TeamCity' do
8
10
  let(:teamcity_running?) { false }
@@ -38,14 +40,14 @@ describe Rake::Funnel::Integration::TeamCity do
38
40
  let(:original_path) { 'original path environment variable contents' }
39
41
  let(:jre) { nil }
40
42
 
41
- before {
43
+ before do
42
44
  allow(ENV).to receive(:[]=)
43
45
 
44
46
  allow(ENV).to receive(:[]).with('PATH').and_return(original_path)
45
47
 
46
48
  allow(ENV).to receive(:include?).with(described_class::JRE_ENV_VAR).and_return(!jre.nil?)
47
49
  allow(ENV).to receive(:[]).with(described_class::JRE_ENV_VAR).and_return(jre)
48
- }
50
+ end
49
51
 
50
52
  context 'without block' do
51
53
  it 'should not modify environment variables' do
@@ -91,7 +93,7 @@ describe Rake::Funnel::Integration::TeamCity do
91
93
 
92
94
  context 'block error' do
93
95
  it 'should reset path' do
94
- expect { described_class.with_java_runtime { fail 'with some error' } }.to raise_error(/with some error/)
96
+ expect { described_class.with_java_runtime { raise 'with some error' } }.to raise_error(/with some error/)
95
97
 
96
98
  expect(ENV).to have_received(:[]=).with('PATH', original_path)
97
99
  end
@@ -1,3 +1,5 @@
1
+ # rubocop:disable RSpec/FilePath
2
+
1
3
  include Rake::Funnel::Support
2
4
 
3
5
  describe Rake::Funnel::Support::Mapper::Styles::MSDeploy do
@@ -1,16 +1,18 @@
1
+ # rubocop:disable RSpec/FilePath
2
+
1
3
  describe Rake::Funnel::Support::Mapper::Styles::NUnit do
2
4
  subject { Mapper.new(:NUnit) }
3
5
 
4
6
  describe 'prefix' do
5
- before {
7
+ before do
6
8
  allow(Rake::Win32).to receive(:windows?).and_return(windows?)
7
- }
9
+ end
8
10
 
9
11
  context 'on Windows' do
10
12
  let(:windows?) { true }
11
13
 
12
14
  it "should use '/'" do
13
- expect(subject.map({ switch: nil })).to eq(['/switch'])
15
+ expect(subject.map(switch: nil)).to eq(['/switch'])
14
16
  end
15
17
  end
16
18
 
@@ -18,7 +20,7 @@ describe Rake::Funnel::Support::Mapper::Styles::NUnit do
18
20
  let(:windows?) { false }
19
21
 
20
22
  it "should use '-'" do
21
- expect(subject.map({ switch: nil })).to eq(['-switch'])
23
+ expect(subject.map(switch: nil)).to eq(['-switch'])
22
24
  end
23
25
  end
24
26
  end
@@ -3,39 +3,39 @@ include Rake::Funnel::Support::ArgumentMapper
3
3
  Styles.constants.reject { |x| x == :MSDeploy }.each do |style|
4
4
  style_path = Styles.const_get(style)
5
5
  describe style_path do
6
- subject {
6
+ subject do
7
7
  Mapper.new(style)
8
- }
8
+ end
9
9
 
10
- let (:style) {
10
+ let(:style) do
11
11
  Styles.const_get(style).new
12
- }
12
+ end
13
13
 
14
- def styled(switch, key = nil, value = nil)
15
- unless style.respond_to?(:separator)
16
- styled = [
17
- [
18
- style.prefix,
19
- switch
20
- ],
21
- [
22
- key && key,
23
- value && style.value_separator,
24
- value && value
25
- ]
26
- ]
27
- else
28
- styled = [
29
- [
30
- style.prefix,
31
- switch,
32
- key && style.separator,
33
- key && key,
34
- value && style.value_separator,
35
- value && value
36
- ]
37
- ]
38
- end
14
+ def styled(switch, key = nil, value = nil) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/LineLength
15
+ styled = if style.respond_to?(:separator)
16
+ [
17
+ [
18
+ style.prefix,
19
+ switch,
20
+ key && style.separator,
21
+ key && key,
22
+ value && style.value_separator,
23
+ value && value
24
+ ]
25
+ ]
26
+ else
27
+ [
28
+ [
29
+ style.prefix,
30
+ switch
31
+ ],
32
+ [
33
+ key && key,
34
+ value && style.value_separator,
35
+ value && value
36
+ ]
37
+ ]
38
+ end
39
39
 
40
40
  styled.map(&:join).reject(&:empty?)
41
41
  end
@@ -74,30 +74,33 @@ Styles.constants.reject { |x| x == :MSDeploy }.each do |style|
74
74
  it 'should convert switch => <truthy> enumerable' do
75
75
  args = { switch: [true, 1] }
76
76
  expect(subject.map(args)).to match_array(
77
- [
78
- *styled('switch', 'true'),
79
- *styled('switch', '1')
80
- ])
77
+ [
78
+ *styled('switch', 'true'),
79
+ *styled('switch', '1')
80
+ ]
81
+ )
81
82
  end
82
83
 
83
84
  it 'should convert hash values' do
84
85
  args = { switch: { foo: true, bar: true } }
85
86
  expect(subject.map(args)).to match_array(
86
- [
87
- *styled('switch', 'foo', 'true'),
88
- *styled('switch', 'bar', 'true')
89
- ])
87
+ [
88
+ *styled('switch', 'foo', 'true'),
89
+ *styled('switch', 'bar', 'true')
90
+ ]
91
+ )
90
92
  end
91
93
 
92
94
  it 'should convert enumerable hash values' do
93
95
  args = { switch: [{ foo: true, bar: 1 }, { baz: :baz, foobar: 'foobar' }] }
94
96
  expect(subject.map(args)).to match_array(
95
- [
96
- *styled('switch', 'foo', 'true'),
97
- *styled('switch', 'bar', '1'),
98
- *styled('switch', 'baz', 'baz'),
99
- *styled('switch', 'foobar', 'foobar'),
100
- ])
97
+ [
98
+ *styled('switch', 'foo', 'true'),
99
+ *styled('switch', 'bar', '1'),
100
+ *styled('switch', 'baz', 'baz'),
101
+ *styled('switch', 'foobar', 'foobar')
102
+ ]
103
+ )
101
104
  end
102
105
  end
103
106
 
@@ -115,28 +118,31 @@ Styles.constants.reject { |x| x == :MSDeploy }.each do |style|
115
118
  it 'should convert switch => <falsy> enumerable' do
116
119
  args = { switch: [false, nil] }
117
120
  expect(subject.map(args)).to match_array(
118
- [
119
- *styled('switch', 'false'),
120
- *styled('switch')
121
- ])
121
+ [
122
+ *styled('switch', 'false'),
123
+ *styled('switch')
124
+ ]
125
+ )
122
126
  end
123
127
 
124
128
  it 'should convert hash values' do
125
129
  args = { switch: { foo: false, bar: nil } }
126
130
  expect(subject.map(args)).to match_array(
127
- [
128
- *styled('switch', 'foo', 'false'),
129
- *styled('switch', 'bar')
130
- ])
131
+ [
132
+ *styled('switch', 'foo', 'false'),
133
+ *styled('switch', 'bar')
134
+ ]
135
+ )
131
136
  end
132
137
 
133
138
  it 'should convert enumerable hash values' do
134
139
  args = { switch: [{ foo: false }, { bar: nil }] }
135
140
  expect(subject.map(args)).to match_array(
136
- [
137
- *styled('switch', 'foo', 'false'),
138
- *styled('switch', 'bar')
139
- ])
141
+ [
142
+ *styled('switch', 'foo', 'false'),
143
+ *styled('switch', 'bar')
144
+ ]
145
+ )
140
146
  end
141
147
  end
142
148
 
@@ -144,28 +150,31 @@ Styles.constants.reject { |x| x == :MSDeploy }.each do |style|
144
150
  it 'should convert switch => <enumerable>' do
145
151
  args = { switch: [1, 'two'] }
146
152
  expect(subject.map(args)).to match_array(
147
- [
148
- *styled('switch', '1'),
149
- *styled('switch', 'two')
150
- ])
153
+ [
154
+ *styled('switch', '1'),
155
+ *styled('switch', 'two')
156
+ ]
157
+ )
151
158
  end
152
159
 
153
160
  it 'should convert switch => <hash>' do
154
161
  args = { switch: { one: 1, two: 2 } }
155
162
  expect(subject.map(args)).to match_array(
156
- [
157
- *styled('switch', 'one', '1'),
158
- *styled('switch', 'two', '2')
159
- ])
163
+ [
164
+ *styled('switch', 'one', '1'),
165
+ *styled('switch', 'two', '2')
166
+ ]
167
+ )
160
168
  end
161
169
 
162
170
  it 'should convert switch => <enumerable of hash>' do
163
171
  args = { switch: [{ one: 1 }, { two: 2 }] }
164
172
  expect(subject.map(args)).to match_array(
165
- [
166
- *styled('switch', 'one', '1'),
167
- *styled('switch', 'two', '2')
168
- ])
173
+ [
174
+ *styled('switch', 'one', '1'),
175
+ *styled('switch', 'two', '2')
176
+ ]
177
+ )
169
178
  end
170
179
  end
171
180