rake-funnel 0.0.1.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 (111) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +21 -0
  5. data/Gemfile +29 -0
  6. data/Guardfile +24 -0
  7. data/README.md +29 -0
  8. data/Rakefile +77 -0
  9. data/build.cmd +30 -0
  10. data/bundle.cmd +26 -0
  11. data/config/.gitignore +1 -0
  12. data/config/.local.yaml.example +9 -0
  13. data/config/default.yaml +5 -0
  14. data/config/dev.yaml +0 -0
  15. data/config/production.yaml +3 -0
  16. data/lib/rake/funnel/ambiguous_file_error.rb +29 -0
  17. data/lib/rake/funnel/execution_error.rb +26 -0
  18. data/lib/rake/funnel/extensions/camel_case.rb +19 -0
  19. data/lib/rake/funnel/extensions/common_path.rb +52 -0
  20. data/lib/rake/funnel/extensions/disable_colors.rb +27 -0
  21. data/lib/rake/funnel/extensions/rexml.rb +23 -0
  22. data/lib/rake/funnel/extensions/shell.rb +56 -0
  23. data/lib/rake/funnel/framework.rb +15 -0
  24. data/lib/rake/funnel/integration/progress_report.rb +70 -0
  25. data/lib/rake/funnel/integration/sync_output.rb +8 -0
  26. data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +59 -0
  27. data/lib/rake/funnel/integration/teamcity/progress_report.rb +33 -0
  28. data/lib/rake/funnel/integration/teamcity/service_messages.rb +40 -0
  29. data/lib/rake/funnel/integration/teamcity/teamcity.rb +15 -0
  30. data/lib/rake/funnel/integration/teamcity.rb +5 -0
  31. data/lib/rake/funnel/support/finder.rb +51 -0
  32. data/lib/rake/funnel/support/mapper.rb +81 -0
  33. data/lib/rake/funnel/support/mapper_styles/default.rb +31 -0
  34. data/lib/rake/funnel/support/mapper_styles/msbuild.rb +33 -0
  35. data/lib/rake/funnel/support/mapper_styles/msdeploy.rb +47 -0
  36. data/lib/rake/funnel/support/mapper_styles/nunit.rb +33 -0
  37. data/lib/rake/funnel/support/mono.rb +17 -0
  38. data/lib/rake/funnel/support/patch.rb +37 -0
  39. data/lib/rake/funnel/support/template_engine.rb +26 -0
  40. data/lib/rake/funnel/support/which.rb +15 -0
  41. data/lib/rake/funnel/tasks/bin_path.rb +34 -0
  42. data/lib/rake/funnel/tasks/copy.rb +54 -0
  43. data/lib/rake/funnel/tasks/environments.rb +74 -0
  44. data/lib/rake/funnel/tasks/environments_support/loader.rb +37 -0
  45. data/lib/rake/funnel/tasks/msbuild.rb +52 -0
  46. data/lib/rake/funnel/tasks/msbuild_support/build_tool.rb +28 -0
  47. data/lib/rake/funnel/tasks/msdeploy.rb +58 -0
  48. data/lib/rake/funnel/tasks/msdeploy_support/registry_patch.rb +84 -0
  49. data/lib/rake/funnel/tasks/nunit.rb +46 -0
  50. data/lib/rake/funnel/tasks/paket.rb +39 -0
  51. data/lib/rake/funnel/tasks/quick_template.rb +45 -0
  52. data/lib/rake/funnel/tasks/side_by_side_specs.rb +33 -0
  53. data/lib/rake/funnel/tasks/side_by_side_specs_support/remover.rb +62 -0
  54. data/lib/rake/funnel/tasks/timing.rb +100 -0
  55. data/lib/rake/funnel/tasks/timing_support/report.rb +89 -0
  56. data/lib/rake/funnel/tasks/timing_support/statistics.rb +26 -0
  57. data/lib/rake/funnel/tasks/zip.rb +66 -0
  58. data/lib/rake/funnel/version.rb +5 -0
  59. data/lib/rake/funnel.rb +7 -0
  60. data/rake-funnel.gemspec +28 -0
  61. data/spec/rake/funnel/execution_error_spec.rb +67 -0
  62. data/spec/rake/funnel/extensions/camel_case_spec.rb +17 -0
  63. data/spec/rake/funnel/extensions/common_path_spec.rb +56 -0
  64. data/spec/rake/funnel/extensions/disable_colors_spec.rb +33 -0
  65. data/spec/rake/funnel/extensions/rexml_spec.rb +20 -0
  66. data/spec/rake/funnel/extensions/shell_spec.rb +237 -0
  67. data/spec/rake/funnel/integration/progress_report_spec.rb +149 -0
  68. data/spec/rake/funnel/integration/sync_output_spec.rb +16 -0
  69. data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +112 -0
  70. data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +174 -0
  71. data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +136 -0
  72. data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +34 -0
  73. data/spec/rake/funnel/support/finder_spec.rb +210 -0
  74. data/spec/rake/funnel/support/mapper_spec.rb +87 -0
  75. data/spec/rake/funnel/support/mapper_styles/msdeploy_spec.rb +222 -0
  76. data/spec/rake/funnel/support/mapper_styles/nunit_spec.rb +25 -0
  77. data/spec/rake/funnel/support/mapper_styles/styles_spec.rb +214 -0
  78. data/spec/rake/funnel/support/mono_spec.rb +57 -0
  79. data/spec/rake/funnel/support/patch_spec.rb +108 -0
  80. data/spec/rake/funnel/support/template_engine_spec.rb +65 -0
  81. data/spec/rake/funnel/support/which_spec.rb +65 -0
  82. data/spec/rake/funnel/tasks/bin_path_spec.rb +40 -0
  83. data/spec/rake/funnel/tasks/copy_spec.rb +101 -0
  84. data/spec/rake/funnel/tasks/environments_spec.rb +237 -0
  85. data/spec/rake/funnel/tasks/environments_support/loader_spec.rb +114 -0
  86. data/spec/rake/funnel/tasks/msbuild_spec.rb +91 -0
  87. data/spec/rake/funnel/tasks/msbuild_support/build_tool_spec.rb +21 -0
  88. data/spec/rake/funnel/tasks/msdeploy_spec.rb +243 -0
  89. data/spec/rake/funnel/tasks/msdeploy_support/registry_patch_spec.rb +139 -0
  90. data/spec/rake/funnel/tasks/nunit_spec.rb +76 -0
  91. data/spec/rake/funnel/tasks/paket_spec.rb +184 -0
  92. data/spec/rake/funnel/tasks/quick_template_spec.rb +89 -0
  93. data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +58 -0
  94. data/spec/rake/funnel/tasks/side_by_side_specs_support/example/FooCode.cs +0 -0
  95. data/spec/rake/funnel/tasks/side_by_side_specs_support/example/FooSpecs.cs +0 -0
  96. data/spec/rake/funnel/tasks/side_by_side_specs_support/example/Sample.csproj +28 -0
  97. data/spec/rake/funnel/tasks/side_by_side_specs_support/example/Specs.cs +0 -0
  98. data/spec/rake/funnel/tasks/side_by_side_specs_support/example/subdir/BarCode.cs +0 -0
  99. data/spec/rake/funnel/tasks/side_by_side_specs_support/example/subdir/BarSpecs.cs +0 -0
  100. data/spec/rake/funnel/tasks/side_by_side_specs_support/remover_spec.rb +116 -0
  101. data/spec/rake/funnel/tasks/timing_spec.rb +133 -0
  102. data/spec/rake/funnel/tasks/timing_support/report_spec.rb +129 -0
  103. data/spec/rake/funnel/tasks/zip_spec.rb +119 -0
  104. data/spec/spec_helper.rb +32 -0
  105. data/tools/MSDeploy/Microsoft.Web.Delegation.dll +0 -0
  106. data/tools/MSDeploy/Microsoft.Web.Deployment.Tracing.dll +0 -0
  107. data/tools/MSDeploy/Microsoft.Web.Deployment.dll +0 -0
  108. data/tools/MSDeploy/en/msdeploy.resources.dll +0 -0
  109. data/tools/MSDeploy/msdeploy.exe +0 -0
  110. data/tools/MSDeploy/msdeploy.exe.config +6 -0
  111. metadata +253 -0
@@ -0,0 +1,87 @@
1
+ describe Rake::Funnel::Support::Mapper do
2
+ describe 'Manual debugging test case' do
3
+ it 'should work' do
4
+ args = {
5
+ unset: nil,
6
+ simple: 1,
7
+ array: [1, 2, nil],
8
+ hash: { one: 1, two: 2, unset: nil },
9
+ enum_hash: [{ one: 1 }, { two: 2 }, { unset: nil }]
10
+ }
11
+
12
+ _ = subject.map(args)
13
+ expect(_).not_to be_empty
14
+
15
+ skip('for manual testing only')
16
+ end
17
+ end
18
+
19
+ class CustomMapper
20
+ def generate_from(_)
21
+ [
22
+ ['-', 'switch'],
23
+ ['-', :some_switch],
24
+ ['-', :another_switch, '=', :some_value],
25
+ ['-string switch', '=', 'string value']
26
+ ]
27
+ end
28
+ end
29
+
30
+ describe 'mapping' do
31
+ it 'should support nil args' do
32
+ expect(subject.map(nil)).to be_empty
33
+ end
34
+
35
+ it 'should support empty args' do
36
+ expect(subject.map({})).to be_empty
37
+ end
38
+ end
39
+
40
+ describe 'mapper style' do
41
+ context 'default mapper' do
42
+ it 'should use default mapper' do
43
+ expect(described_class.new).to be
44
+ end
45
+ end
46
+
47
+ context 'unknown mapper' do
48
+ it 'should fail' do
49
+ expect { described_class.new(:unknown) }.to raise_error(/^Something went wrong while creating the 'unknown' mapper/)
50
+ end
51
+ end
52
+
53
+ context 'nil mapper' do
54
+ it 'should fail' do
55
+ expect { described_class.new(nil) }.to raise_error(/You cannot use a 'nil' mapper. Available mappers are: \w+/)
56
+ end
57
+ end
58
+
59
+ context 'custom mapper' do
60
+ it 'should take custom mapper instance' do
61
+ expect(described_class.new(CustomMapper.new)).to be
62
+ end
63
+ end
64
+ end
65
+
66
+ describe 'mapper output' do
67
+ subject { described_class.new(CustomMapper.new) }
68
+
69
+ it 'should join nested arrays' do
70
+ expect(subject.map).to include('-switch')
71
+ end
72
+
73
+ describe 'snake case to camel case conversion' do
74
+ it 'should convert symbols keys' do
75
+ expect(subject.map).to include('-someSwitch')
76
+ end
77
+
78
+ it 'should convert symbol values' do
79
+ expect(subject.map).to include('-anotherSwitch=someValue')
80
+ end
81
+
82
+ it 'should not convert strings' do
83
+ expect(subject.map).to include('-string switch=string value')
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,222 @@
1
+ include Rake::Funnel::Support
2
+
3
+ describe Rake::Funnel::Support::MapperStyles::MSDeploy do
4
+ subject { Mapper.new(:MSDeploy) }
5
+
6
+ describe 'no arguments' do
7
+ it 'should convert no args to []' do
8
+ expect(subject.map).to match_array([])
9
+ end
10
+
11
+ it 'should convert {} to []' do
12
+ expect(subject.map({})).to match_array([])
13
+ end
14
+ end
15
+
16
+ describe 'truthy arguments' do
17
+ it 'should convert switch => <true>' do
18
+ args = { switch: true }
19
+ expect(subject.map(args)).to match_array(['-switch:true'])
20
+ end
21
+
22
+ it 'should convert switch => <truthy>' do
23
+ args = { switch: 1 }
24
+ expect(subject.map(args)).to match_array(['-switch:1'])
25
+ end
26
+
27
+ it 'should convert switch => <symbol>' do
28
+ args = { switch: :one }
29
+ expect(subject.map(args)).to match_array(['-switch:one'])
30
+ end
31
+
32
+ it 'should convert switch => <string>' do
33
+ args = { switch: 'one' }
34
+ expect(subject.map(args)).to match_array(['-switch:one'])
35
+ end
36
+
37
+ it 'should convert switch => <truthy> enumerable' do
38
+ args = { switch: [true, 1] }
39
+ expect(subject.map(args)).to match_array(%w(-switch:true -switch:1))
40
+ end
41
+
42
+ it 'should convert hash values' do
43
+ args = { switch: { foo: true, bar: true } }
44
+ expect(subject.map(args)).to match_array(['-switch:foo=true,bar=true'])
45
+ end
46
+
47
+ it 'should convert enumerable hash values' do
48
+ args = { switch: [{ foo: true, bar: 1 }, { baz: :baz, foobar: 'foobar' }] }
49
+ expect(subject.map(args)).to match_array(%w(-switch:foo=true,bar=1 -switch:baz=baz,foobar=foobar))
50
+ end
51
+ end
52
+
53
+ describe 'falsy arguments' do
54
+ it 'should convert switch => <false>' do
55
+ args = { switch: false }
56
+ expect(subject.map(args)).to match_array(['-switch:false'])
57
+ end
58
+
59
+ it 'should convert switch => <falsy>' do
60
+ args = { switch: nil }
61
+ expect(subject.map(args)).to match_array(['-switch'])
62
+ end
63
+
64
+ it 'should convert switch => <falsy> enumerable' do
65
+ args = { switch: [false, nil] }
66
+ expect(subject.map(args)).to match_array(%w(-switch:false -switch))
67
+ end
68
+
69
+ it 'should convert hash values' do
70
+ args = { switch: { foo: false, bar: nil } }
71
+ expect(subject.map(args)).to match_array(['-switch:foo=false,bar'])
72
+ end
73
+
74
+ it 'should convert enumerable hash values' do
75
+ args = { switch: [{ foo: false }, { bar: nil }] }
76
+ expect(subject.map(args)).to match_array(%w(-switch:foo=false -switch:bar))
77
+ end
78
+ end
79
+
80
+ describe 'complex types' do
81
+ it 'should convert switch => <enumerable>' do
82
+ args = { switch: [1, 'two'] }
83
+ expect(subject.map(args)).to match_array(%w(-switch:1 -switch:two))
84
+ end
85
+
86
+ it 'should convert switch => <hash>' do
87
+ args = { switch: { one: 1, two: 2 } }
88
+ expect(subject.map(args)).to match_array(['-switch:one=1,two=2'])
89
+ end
90
+
91
+ it 'should convert switch => <enumerable of hash>' do
92
+ args = { switch: [{ one: 1 }, { two: 2 }] }
93
+ expect(subject.map(args)).to match_array(%w(-switch:one=1 -switch:two=2))
94
+ end
95
+ end
96
+
97
+ describe 'snake case to camel case conversion' do
98
+ it 'should convert symbols keys' do
99
+ args = { some_switch: 1 }
100
+ expect(subject.map(args)).to match_array(['-someSwitch:1'])
101
+ end
102
+
103
+ it 'should convert symbol values' do
104
+ args = { switch: :some_value }
105
+ expect(subject.map(args)).to match_array(['-switch:someValue'])
106
+ end
107
+
108
+ it 'should convert enumerable values' do
109
+ args = { switch: [:some_value] }
110
+ expect(subject.map(args)).to match_array(['-switch:someValue'])
111
+ end
112
+
113
+ it 'should convert hash values' do
114
+ args = { switch: { key: :some_value } }
115
+ expect(subject.map(args)).to match_array(['-switch:key=someValue'])
116
+ end
117
+
118
+ it 'should convert hash keys' do
119
+ args = { switch: { some_key: true } }
120
+ expect(subject.map(args)).to match_array(['-switch:someKey=true'])
121
+ end
122
+
123
+ it 'should convert enumerable hash values' do
124
+ args = { switch: [{ key: :some_value }] }
125
+ expect(subject.map(args)).to match_array(['-switch:key=someValue'])
126
+ end
127
+
128
+ it 'should convert enumerable hash keys' do
129
+ args = { switch: [{ some_key: true }] }
130
+ expect(subject.map(args)).to match_array(['-switch:someKey=true'])
131
+ end
132
+
133
+ it 'should not convert strings' do
134
+ args = { 'some_switch' => 'some_value' }
135
+ expect(subject.map(args)).to match_array(['-some_switch:some_value'])
136
+ end
137
+ end
138
+
139
+ describe 'whitespace' do
140
+ describe 'keys' do
141
+ context 'without quotes' do
142
+ it 'should enclose keys in "' do
143
+ args = { 'some key' => 1 }
144
+ expect(subject.map(args)).to match_array(['-"some key":1'])
145
+ end
146
+
147
+ it 'should enclose hash keys in "' do
148
+ args = { switch: { 'some key' => 1 } }
149
+ expect(subject.map(args)).to match_array(['-switch:"some key"=1'])
150
+ end
151
+
152
+ it 'should enclose enumerable hash keys in "' do
153
+ args = { switch: [{ 'some key' => 1 }] }
154
+ expect(subject.map(args)).to match_array(['-switch:"some key"=1'])
155
+ end
156
+ end
157
+
158
+ context 'with quotes' do
159
+ it 'should escape quotes' do
160
+ args = { 'some "key"' => 1 }
161
+ expect(subject.map(args)).to match_array(['-"some ""key""":1'])
162
+ end
163
+
164
+ it 'should escape quotes in hash keys' do
165
+ args = { switch: { 'some "key"' => 1 } }
166
+ expect(subject.map(args)).to match_array(['-switch:"some ""key"""=1'])
167
+ end
168
+
169
+ it 'should escape quotes in enumerable hash keys' do
170
+ args = { switch: [{ 'some "key"' => 1 }] }
171
+ expect(subject.map(args)).to match_array(['-switch:"some ""key"""=1'])
172
+ end
173
+ end
174
+ end
175
+
176
+ describe 'values' do
177
+ context 'without quotes' do
178
+ it 'should enclose values in "' do
179
+ args = { switch: 'some value' }
180
+ expect(subject.map(args)).to match_array(['-switch:"some value"'])
181
+ end
182
+
183
+ it 'should enclose enumerable values in "' do
184
+ args = { switch: ['some value'] }
185
+ expect(subject.map(args)).to match_array(['-switch:"some value"'])
186
+ end
187
+
188
+ it 'should enclose hash values in "' do
189
+ args = { switch: { key: 'some value' } }
190
+ expect(subject.map(args)).to match_array(['-switch:key="some value"'])
191
+ end
192
+
193
+ it 'should enclose enumerable hash values in "' do
194
+ args = { switch: [{ key: 'some value' }] }
195
+ expect(subject.map(args)).to match_array(['-switch:key="some value"'])
196
+ end
197
+ end
198
+
199
+ context 'with quotes' do
200
+ it 'should escape quotes' do
201
+ args = { switch: 'some "value"' }
202
+ expect(subject.map(args)).to match_array(['-switch:"some ""value"""'])
203
+ end
204
+
205
+ it 'should escape quotes in enumerable values' do
206
+ args = { switch: ['some "value"'] }
207
+ expect(subject.map(args)).to match_array(['-switch:"some ""value"""'])
208
+ end
209
+
210
+ it 'should escape quotes in hash values' do
211
+ args = { switch: { key: 'some "value"' } }
212
+ expect(subject.map(args)).to match_array(['-switch:key="some ""value"""'])
213
+ end
214
+
215
+ it 'should escape quotes in enumerable hash values' do
216
+ args = { switch: [{ key: 'some "value"' }] }
217
+ expect(subject.map(args)).to match_array(['-switch:key="some ""value"""'])
218
+ end
219
+ end
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,25 @@
1
+ describe Rake::Funnel::Support::MapperStyles::NUnit do
2
+ subject { Mapper.new(:NUnit) }
3
+
4
+ describe 'prefix' do
5
+ before {
6
+ allow(Rake::Win32).to receive(:windows?).and_return(windows?)
7
+ }
8
+
9
+ context 'on Windows' do
10
+ let(:windows?) { true }
11
+
12
+ it "should use '/'" do
13
+ expect(subject.map({ switch: nil })).to eq(['/switch'])
14
+ end
15
+ end
16
+
17
+ context 'not on Windows' do
18
+ let(:windows?) { false }
19
+
20
+ it "should use '-'" do
21
+ expect(subject.map({ switch: nil })).to eq(['-switch'])
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,214 @@
1
+ include Rake::Funnel::Support
2
+
3
+ MapperStyles.constants.reject { |x| x == :MSDeploy }.each do |style|
4
+ style_path = MapperStyles.const_get(style)
5
+ describe style_path do
6
+ subject {
7
+ Mapper.new(style)
8
+ }
9
+
10
+ let (:style) {
11
+ MapperStyles.const_get(style).new
12
+ }
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
39
+
40
+ styled.map(&:join).reject(&:empty?)
41
+ end
42
+
43
+ describe 'no arguments' do
44
+ it 'should convert no args to []' do
45
+ expect(subject.map).to match_array([])
46
+ end
47
+
48
+ it 'should convert {} to []' do
49
+ expect(subject.map({})).to match_array([])
50
+ end
51
+ end
52
+
53
+ describe 'truthy arguments' do
54
+ it 'should convert switch => <true>' do
55
+ args = { switch: true }
56
+ expect(subject.map(args)).to match_array(styled('switch', 'true'))
57
+ end
58
+
59
+ it 'should convert switch => <truthy>' do
60
+ args = { switch: 1 }
61
+ expect(subject.map(args)).to match_array(styled('switch', '1'))
62
+ end
63
+
64
+ it 'should convert switch => <symbol>' do
65
+ args = { switch: :one }
66
+ expect(subject.map(args)).to match_array(styled('switch', 'one'))
67
+ end
68
+
69
+ it 'should convert switch => <string>' do
70
+ args = { switch: 'one' }
71
+ expect(subject.map(args)).to match_array(styled('switch', 'one'))
72
+ end
73
+
74
+ it 'should convert switch => <truthy> enumerable' do
75
+ args = { switch: [true, 1] }
76
+ expect(subject.map(args)).to match_array(
77
+ [
78
+ *styled('switch', 'true'),
79
+ *styled('switch', '1')
80
+ ])
81
+ end
82
+
83
+ it 'should convert hash values' do
84
+ args = { switch: { foo: true, bar: true } }
85
+ expect(subject.map(args)).to match_array(
86
+ [
87
+ *styled('switch', 'foo', 'true'),
88
+ *styled('switch', 'bar', 'true')
89
+ ])
90
+ end
91
+
92
+ it 'should convert enumerable hash values' do
93
+ args = { switch: [{ foo: true, bar: 1 }, { baz: :baz, foobar: 'foobar' }] }
94
+ 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
+ ])
101
+ end
102
+ end
103
+
104
+ describe 'falsy arguments' do
105
+ it 'should convert switch => <false>' do
106
+ args = { switch: false }
107
+ expect(subject.map(args)).to match_array(styled('switch', 'false'))
108
+ end
109
+
110
+ it 'should convert switch => <falsy>' do
111
+ args = { switch: nil }
112
+ expect(subject.map(args)).to match_array(styled('switch'))
113
+ end
114
+
115
+ it 'should convert switch => <falsy> enumerable' do
116
+ args = { switch: [false, nil] }
117
+ expect(subject.map(args)).to match_array(
118
+ [
119
+ *styled('switch', 'false'),
120
+ *styled('switch')
121
+ ])
122
+ end
123
+
124
+ it 'should convert hash values' do
125
+ args = { switch: { foo: false, bar: nil } }
126
+ expect(subject.map(args)).to match_array(
127
+ [
128
+ *styled('switch', 'foo', 'false'),
129
+ *styled('switch', 'bar')
130
+ ])
131
+ end
132
+
133
+ it 'should convert enumerable hash values' do
134
+ args = { switch: [{ foo: false }, { bar: nil }] }
135
+ expect(subject.map(args)).to match_array(
136
+ [
137
+ *styled('switch', 'foo', 'false'),
138
+ *styled('switch', 'bar')
139
+ ])
140
+ end
141
+ end
142
+
143
+ describe 'complex types' do
144
+ it 'should convert switch => <enumerable>' do
145
+ args = { switch: [1, 'two'] }
146
+ expect(subject.map(args)).to match_array(
147
+ [
148
+ *styled('switch', '1'),
149
+ *styled('switch', 'two')
150
+ ])
151
+ end
152
+
153
+ it 'should convert switch => <hash>' do
154
+ args = { switch: { one: 1, two: 2 } }
155
+ expect(subject.map(args)).to match_array(
156
+ [
157
+ *styled('switch', 'one', '1'),
158
+ *styled('switch', 'two', '2')
159
+ ])
160
+ end
161
+
162
+ it 'should convert switch => <enumerable of hash>' do
163
+ args = { switch: [{ one: 1 }, { two: 2 }] }
164
+ expect(subject.map(args)).to match_array(
165
+ [
166
+ *styled('switch', 'one', '1'),
167
+ *styled('switch', 'two', '2')
168
+ ])
169
+ end
170
+ end
171
+
172
+ describe 'snake case to camel case conversion' do
173
+ it 'should convert symbols keys' do
174
+ args = { some_switch: 1 }
175
+ expect(subject.map(args)).to match_array(styled('someSwitch', '1'))
176
+ end
177
+
178
+ it 'should convert symbol values' do
179
+ args = { switch: :some_value }
180
+ expect(subject.map(args)).to match_array(styled('switch', 'someValue'))
181
+ end
182
+
183
+ it 'should convert enumerable values' do
184
+ args = { switch: [:some_value] }
185
+ expect(subject.map(args)).to match_array(styled('switch', 'someValue'))
186
+ end
187
+
188
+ it 'should convert hash values' do
189
+ args = { switch: { key: :some_value } }
190
+ expect(subject.map(args)).to match_array(styled('switch', 'key', 'someValue'))
191
+ end
192
+
193
+ it 'should convert hash keys' do
194
+ args = { switch: { some_key: true } }
195
+ expect(subject.map(args)).to match_array(styled('switch', 'someKey', 'true'))
196
+ end
197
+
198
+ it 'should convert enumerable hash values' do
199
+ args = { switch: [{ key: :some_value }] }
200
+ expect(subject.map(args)).to match_array(styled('switch', 'key', 'someValue'))
201
+ end
202
+
203
+ it 'should convert enumerable hash keys' do
204
+ args = { switch: [{ some_key: true }] }
205
+ expect(subject.map(args)).to match_array(styled('switch', 'someKey', 'true'))
206
+ end
207
+
208
+ it 'should not convert strings' do
209
+ args = { 'some_switch' => 'some_value' }
210
+ expect(subject.map(args)).to match_array(styled('some_switch', 'some_value'))
211
+ end
212
+ end
213
+ end
214
+ end
@@ -0,0 +1,57 @@
1
+ require 'tmpdir'
2
+
3
+ include Rake::Funnel::Support
4
+
5
+ describe Rake::Funnel::Support::Mono do
6
+ before {
7
+ allow(Rake::Win32).to receive(:windows?).and_return(windows?)
8
+ }
9
+
10
+ context 'on Windows' do
11
+ let(:windows?) { true }
12
+
13
+ it 'should return executable' do
14
+ expect(described_class.invocation('executable.exe')).to eq(%w(executable.exe))
15
+ end
16
+
17
+ it 'should return executable with args' do
18
+ expect(described_class.invocation('executable.exe', 'arg1', 'arg2')).to eq(%w(executable.exe arg1 arg2))
19
+ end
20
+
21
+ it 'should return array executable with args' do
22
+ expect(described_class.invocation(%w(executable.exe arg1 arg2))).to eq(%w(executable.exe arg1 arg2))
23
+ end
24
+
25
+ it 'should reject nil in array' do
26
+ expect(described_class.invocation(%w(executable.exe arg1) << nil)).to eq(%w(executable.exe arg1))
27
+ end
28
+
29
+ it 'should reject nil as arg' do
30
+ expect(described_class.invocation('executable.exe', nil)).to eq(%w(executable.exe))
31
+ end
32
+ end
33
+
34
+ context 'not on Windows' do
35
+ let(:windows?) { false }
36
+
37
+ before {
38
+ allow(Which).to receive(:which)
39
+ }
40
+
41
+ before {
42
+ @cmd = described_class.invocation('executable.exe')
43
+ }
44
+
45
+ it "should prepend 'mono'" do
46
+ expect(@cmd.first).to eq('mono')
47
+ end
48
+
49
+ it 'should resolve executable through which' do
50
+ expect(Which).to have_received(:which).with('executable.exe')
51
+ end
52
+
53
+ it 'should support args' do
54
+ expect(described_class.invocation(%w(executable.exe arg1 arg2))).to eq(%w(mono executable.exe arg1 arg2))
55
+ end
56
+ end
57
+ end