rake-funnel 0.0.6.pre → 0.1.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.
- checksums.yaml +4 -4
- data/lib/rake/funnel/extensions/{camel_case.rb → case/camel_case.rb} +0 -0
- data/lib/rake/funnel/extensions/case/pascal_case.rb +19 -0
- data/lib/rake/funnel/extensions/case.rb +3 -0
- data/lib/rake/funnel/framework.rb +1 -0
- data/lib/rake/funnel/support/argument_mapper/key_value_pair.rb +10 -0
- data/lib/rake/funnel/support/{mapper_styles → argument_mapper/styles}/default.rb +1 -1
- data/lib/rake/funnel/support/{mapper_styles → argument_mapper/styles}/msbuild.rb +1 -1
- data/lib/rake/funnel/support/{mapper_styles → argument_mapper/styles}/msdeploy.rb +1 -1
- data/lib/rake/funnel/support/{mapper_styles → argument_mapper/styles}/nunit.rb +1 -1
- data/lib/rake/funnel/support/argument_mapper/styles.rb +5 -0
- data/lib/rake/funnel/support/argument_mapper/switch.rb +10 -0
- data/lib/rake/funnel/support/argument_mapper/value.rb +10 -0
- data/lib/rake/funnel/support/assembly_version/from_version_files.rb +35 -0
- data/lib/rake/funnel/support/assembly_version/languages/cs +5 -0
- data/lib/rake/funnel/support/assembly_version/languages/fs +12 -0
- data/lib/rake/funnel/support/assembly_version/languages/vb +5 -0
- data/lib/rake/funnel/support/assembly_version_writer.rb +52 -0
- data/lib/rake/funnel/{tasks/environments_support → support/environments}/loader.rb +8 -11
- data/lib/rake/funnel/support/environments.rb +3 -0
- data/lib/rake/funnel/support/{finder.rb → internal/finder.rb} +0 -0
- data/lib/rake/funnel/support/internal/instantiate_symbol.rb +34 -0
- data/lib/rake/funnel/support/mapper.rb +7 -35
- data/lib/rake/funnel/{tasks/msbuild_support → support/msbuild}/build_tool.rb +1 -1
- data/lib/rake/funnel/support/msbuild.rb +3 -0
- data/lib/rake/funnel/{tasks/msdeploy_support → support/msdeploy}/registry_patch.rb +1 -1
- data/lib/rake/funnel/support/msdeploy.rb +3 -0
- data/lib/rake/funnel/{tasks/side_by_side_specs_support → support/side_by_side_specs}/remover.rb +1 -1
- data/lib/rake/funnel/support/side_by_side_specs.rb +3 -0
- data/lib/rake/funnel/{tasks/timing_support → support/timing}/report.rb +1 -1
- data/lib/rake/funnel/{tasks/timing_support → support/timing}/statistics.rb +1 -1
- data/lib/rake/funnel/support/timing.rb +3 -0
- data/lib/rake/funnel/support/{version.rb → version_info.rb} +25 -8
- data/lib/rake/funnel/tasks/assembly_version.rb +34 -0
- data/lib/rake/funnel/tasks/bin_path.rb +3 -3
- data/lib/rake/funnel/tasks/copy.rb +3 -1
- data/lib/rake/funnel/tasks/environments.rb +4 -2
- data/lib/rake/funnel/tasks/msbuild.rb +6 -7
- data/lib/rake/funnel/tasks/msdeploy.rb +5 -6
- data/lib/rake/funnel/tasks/nunit.rb +5 -3
- data/lib/rake/funnel/tasks/paket.rb +4 -2
- data/lib/rake/funnel/tasks/quick_template.rb +3 -1
- data/lib/rake/funnel/tasks/side_by_side_specs.rb +3 -5
- data/lib/rake/funnel/tasks/timing.rb +5 -8
- data/lib/rake/funnel/tasks/zip.rb +3 -1
- data/lib/rake/funnel/version.rb +1 -1
- data/spec/rake/funnel/extensions/{camel_case_spec.rb → case/camel_case_spec.rb} +0 -0
- data/spec/rake/funnel/extensions/case/pascal_case_spec.rb +17 -0
- data/spec/rake/funnel/support/{mapper_styles → argument_mapper/styles}/msdeploy_spec.rb +1 -1
- data/spec/rake/funnel/support/{mapper_styles → argument_mapper/styles}/nunit_spec.rb +1 -1
- data/spec/rake/funnel/support/{mapper_styles → argument_mapper/styles}/styles_spec.rb +4 -4
- data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +61 -0
- data/spec/rake/funnel/support/assembly_version_writer_spec.rb +140 -0
- data/spec/rake/funnel/{tasks/environments_support → support/environments}/loader_spec.rb +13 -3
- data/spec/rake/funnel/support/{finder_spec.rb → internal/finder_spec.rb} +7 -6
- data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +183 -0
- data/spec/rake/funnel/support/mapper_spec.rb +2 -2
- data/spec/rake/funnel/{tasks/msbuild_support → support/msbuild}/build_tool_spec.rb +1 -1
- data/spec/rake/funnel/{tasks/msdeploy_support → support/msdeploy}/registry_patch_spec.rb +3 -3
- data/spec/rake/funnel/{tasks/side_by_side_specs_support → support/side_by_side_specs}/example/FooCode.cs +0 -0
- data/spec/rake/funnel/{tasks/side_by_side_specs_support → support/side_by_side_specs}/example/FooSpecs.cs +0 -0
- data/spec/rake/funnel/{tasks/side_by_side_specs_support → support/side_by_side_specs}/example/Sample.csproj +0 -0
- data/spec/rake/funnel/{tasks/side_by_side_specs_support → support/side_by_side_specs}/example/Specs.cs +0 -0
- data/spec/rake/funnel/{tasks/side_by_side_specs_support → support/side_by_side_specs}/example/subdir/BarCode.cs +0 -0
- data/spec/rake/funnel/{tasks/side_by_side_specs_support → support/side_by_side_specs}/example/subdir/BarSpecs.cs +0 -0
- data/spec/rake/funnel/{tasks/side_by_side_specs_support → support/side_by_side_specs}/remover_spec.rb +1 -1
- data/spec/rake/funnel/support/template_engine_spec.rb +2 -2
- data/spec/rake/funnel/{tasks/timing_support → support/timing}/report_spec.rb +2 -2
- data/spec/rake/funnel/support/version_info_spec.rb +228 -0
- data/spec/rake/funnel/tasks/assembly_version_spec.rb +54 -0
- data/spec/rake/funnel/tasks/bin_path_spec.rb +4 -4
- data/spec/rake/funnel/tasks/copy_spec.rb +1 -1
- data/spec/rake/funnel/tasks/environments_spec.rb +82 -26
- data/spec/rake/funnel/tasks/msbuild_spec.rb +1 -1
- data/spec/rake/funnel/tasks/msdeploy_spec.rb +1 -1
- data/spec/rake/funnel/tasks/paket_spec.rb +2 -2
- data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +4 -3
- data/spec/rake/funnel/tasks/zip_spec.rb +1 -1
- metadata +77 -49
- data/spec/rake/funnel/support/version_spec.rb +0 -145
@@ -46,13 +46,13 @@ describe Rake::Funnel::Support::Mapper do
|
|
46
46
|
|
47
47
|
context 'unknown mapper' do
|
48
48
|
it 'should fail' do
|
49
|
-
expect { described_class.new(:unknown) }.to raise_error(
|
49
|
+
expect { described_class.new(:unknown) }.to raise_error(NameError)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'nil mapper' do
|
54
54
|
it 'should fail' do
|
55
|
-
expect { described_class.new(nil) }.to raise_error(/You cannot use
|
55
|
+
expect { described_class.new(nil) }.to raise_error(/You cannot use the 'nil' mapper style. Available mappers are:/)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe Rake::Funnel::
|
1
|
+
describe Rake::Funnel::Support::MSDeploy::RegistryPatch do
|
2
2
|
describe 'execution' do
|
3
3
|
it 'should yield block' do
|
4
4
|
result = 0
|
@@ -11,7 +11,7 @@ describe Rake::Funnel::Tasks::MSDeploySupport::RegistryPatch do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should work without block' do
|
14
|
-
expect
|
14
|
+
expect { described_class.new }.not_to raise_error
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -22,7 +22,7 @@ describe Rake::Funnel::Tasks::MSDeploySupport::RegistryPatch do
|
|
22
22
|
}
|
23
23
|
|
24
24
|
it 'should succeed' do
|
25
|
-
expect
|
25
|
+
expect { described_class.new }.not_to raise_error
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -41,7 +41,7 @@ describe Rake::Funnel::Support::TemplateEngine do
|
|
41
41
|
var = 42
|
42
42
|
template = '<%= var %>'
|
43
43
|
|
44
|
-
expect
|
44
|
+
expect { described_class.render(template) }.to raise_error
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -59,7 +59,7 @@ describe Rake::Funnel::Support::TemplateEngine do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should report errors with file name' do
|
62
|
-
expect
|
62
|
+
expect { described_class.render('<%= undefined %>', 'file.template') }
|
63
63
|
.to raise_error { |ex| expect(ex.backtrace.join("\n")).to match(/file\.template/) }
|
64
64
|
end
|
65
65
|
end
|
@@ -0,0 +1,228 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
describe Rake::Funnel::Support::VersionInfo do
|
5
|
+
describe '#parse' do
|
6
|
+
[
|
7
|
+
{
|
8
|
+
context: {
|
9
|
+
version: '1.2',
|
10
|
+
build_number: '42',
|
11
|
+
sha: 'sha'
|
12
|
+
},
|
13
|
+
expected: {
|
14
|
+
assembly_version: '1.2',
|
15
|
+
assembly_file_version: '1.2.42',
|
16
|
+
assembly_informational_version: '1.2.42-sha'
|
17
|
+
}
|
18
|
+
},
|
19
|
+
{
|
20
|
+
context: {
|
21
|
+
version: '1.2-pre1',
|
22
|
+
build_number: '42',
|
23
|
+
sha: 'sha'
|
24
|
+
},
|
25
|
+
expected: {
|
26
|
+
assembly_version: '1.2',
|
27
|
+
assembly_file_version: '1.2.42',
|
28
|
+
assembly_informational_version: '1.2-pre1.42-sha'
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
context: {
|
33
|
+
version: '1.2.3',
|
34
|
+
build_number: '42',
|
35
|
+
sha: 'sha' },
|
36
|
+
expected: {
|
37
|
+
assembly_version: '1.2.3',
|
38
|
+
assembly_file_version: '1.2.3.42',
|
39
|
+
assembly_informational_version: '1.2.3.42-sha'
|
40
|
+
}
|
41
|
+
},
|
42
|
+
{
|
43
|
+
context: {
|
44
|
+
version: '1.2.3-pre1',
|
45
|
+
build_number: '42',
|
46
|
+
sha: 'sha'
|
47
|
+
},
|
48
|
+
expected: {
|
49
|
+
assembly_version: '1.2.3',
|
50
|
+
assembly_file_version: '1.2.3.42',
|
51
|
+
assembly_informational_version: '1.2.3-pre1.42-sha'
|
52
|
+
}
|
53
|
+
},
|
54
|
+
{
|
55
|
+
context: {
|
56
|
+
version: '1.2',
|
57
|
+
build_number: '-pre',
|
58
|
+
sha: 'sha'
|
59
|
+
},
|
60
|
+
expected: {
|
61
|
+
assembly_version: '1.2',
|
62
|
+
assembly_file_version: '1.2',
|
63
|
+
assembly_informational_version: '1.2-pre-sha'
|
64
|
+
}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
context: {
|
68
|
+
version: '1.2',
|
69
|
+
build_number: '-pre42',
|
70
|
+
sha: 'sha'
|
71
|
+
},
|
72
|
+
expected: {
|
73
|
+
assembly_version: '1.2',
|
74
|
+
assembly_file_version: '1.2.42',
|
75
|
+
assembly_informational_version: '1.2-pre42-sha'
|
76
|
+
}
|
77
|
+
},
|
78
|
+
{
|
79
|
+
context: {
|
80
|
+
version: '1.2',
|
81
|
+
build_number: nil,
|
82
|
+
sha: nil
|
83
|
+
},
|
84
|
+
expected: {
|
85
|
+
assembly_version: '1.2',
|
86
|
+
assembly_file_version: '1.2',
|
87
|
+
assembly_informational_version: '1.2'
|
88
|
+
}
|
89
|
+
},
|
90
|
+
{
|
91
|
+
context: {
|
92
|
+
version: '1.2',
|
93
|
+
build_number: '42',
|
94
|
+
sha: nil
|
95
|
+
},
|
96
|
+
expected: {
|
97
|
+
assembly_version: '1.2',
|
98
|
+
assembly_file_version: '1.2.42',
|
99
|
+
assembly_informational_version: '1.2.42'
|
100
|
+
}
|
101
|
+
},
|
102
|
+
{
|
103
|
+
context: {
|
104
|
+
version: 1,
|
105
|
+
build_number: '42',
|
106
|
+
sha: 'sha'
|
107
|
+
},
|
108
|
+
expected: {
|
109
|
+
assembly_version: '1',
|
110
|
+
assembly_file_version: '1.42',
|
111
|
+
assembly_informational_version: '1.42-sha'
|
112
|
+
}
|
113
|
+
},
|
114
|
+
{
|
115
|
+
context: {
|
116
|
+
version: '1.2',
|
117
|
+
build_number: 42,
|
118
|
+
sha: 'sha'
|
119
|
+
},
|
120
|
+
expected: {
|
121
|
+
assembly_version: '1.2',
|
122
|
+
assembly_file_version: '1.2.42',
|
123
|
+
assembly_informational_version: '1.2.42-sha'
|
124
|
+
}
|
125
|
+
},
|
126
|
+
{
|
127
|
+
context: {
|
128
|
+
version: '1.2'
|
129
|
+
},
|
130
|
+
expected: {
|
131
|
+
assembly_version: '1.2',
|
132
|
+
assembly_file_version: '1.2',
|
133
|
+
assembly_informational_version: '1.2'
|
134
|
+
}
|
135
|
+
},
|
136
|
+
{
|
137
|
+
context: {
|
138
|
+
version: nil,
|
139
|
+
build_number: nil,
|
140
|
+
sha: nil
|
141
|
+
},
|
142
|
+
expected: {
|
143
|
+
assembly_version: '0',
|
144
|
+
assembly_file_version: '0',
|
145
|
+
assembly_informational_version: '0'
|
146
|
+
}
|
147
|
+
},
|
148
|
+
{
|
149
|
+
context: {},
|
150
|
+
expected: {
|
151
|
+
assembly_version: '0',
|
152
|
+
assembly_file_version: '0',
|
153
|
+
assembly_informational_version: '0'
|
154
|
+
}
|
155
|
+
}
|
156
|
+
].each do |spec|
|
157
|
+
context "version #{spec[:context][:version] || 'none'}, build number #{spec[:context][:build_number] || 'none'}, SHA #{spec[:context][:sha] || 'none'}" do
|
158
|
+
let(:parsed) { described_class.parse(spec[:context]) }
|
159
|
+
|
160
|
+
it "should generate assembly version #{spec[:expected][:assembly_version]}" do
|
161
|
+
expect(parsed.assembly_version).to eq(spec[:expected][:assembly_version])
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should generate assembly file version #{spec[:expected][:assembly_file_version]}" do
|
165
|
+
expect(parsed.assembly_file_version).to eq(spec[:expected][:assembly_file_version])
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should generate assembly informational version #{spec[:expected][:assembly_informational_version]}" do
|
169
|
+
expect(parsed.assembly_informational_version).to eq(spec[:expected][:assembly_informational_version])
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe 'enumerable' do
|
176
|
+
it { is_expected.to be_kind_of(Enumerable) }
|
177
|
+
it { is_expected.to respond_to(:each) }
|
178
|
+
|
179
|
+
it 'should yield enumerator' do
|
180
|
+
expect(subject.each).to be_kind_of(Enumerator)
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'enumerating' do
|
184
|
+
let(:args) { { a: 42, b: 23 } }
|
185
|
+
|
186
|
+
subject { described_class.new(args) }
|
187
|
+
|
188
|
+
it 'should yield all hash pairs' do
|
189
|
+
expect { |b| subject.each(&b) }.to yield_successive_args([:a, 42], [:b, 23])
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe 'automatic methods' do
|
195
|
+
it 'should be an OpenStruct' do
|
196
|
+
expect(described_class < OpenStruct).to eq(true)
|
197
|
+
end
|
198
|
+
|
199
|
+
describe 'immutability' do
|
200
|
+
let(:args) { { a: 42 } }
|
201
|
+
|
202
|
+
subject { described_class.new(args) }
|
203
|
+
|
204
|
+
it 'should be immutable' do
|
205
|
+
expect { subject.a = 23 }.to raise_error
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe '#read_version_from' do
|
211
|
+
let(:file) { 'file with version info' }
|
212
|
+
let(:contents) { <<-EOF
|
213
|
+
first line with expected version number
|
214
|
+
other crap
|
215
|
+
EOF
|
216
|
+
}
|
217
|
+
|
218
|
+
it 'should read the first line with leading and trailing whitespace removed' do
|
219
|
+
Dir.mktmpdir do |tmp|
|
220
|
+
Dir.chdir(tmp) do
|
221
|
+
|
222
|
+
File.write(file, contents)
|
223
|
+
expect(described_class.read_version_from(file)).to eq('first line with expected version number')
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
include Rake
|
2
|
+
include Rake::Funnel::Support
|
3
|
+
|
4
|
+
describe Rake::Funnel::Tasks::AssemblyVersion do
|
5
|
+
before {
|
6
|
+
CLEAN.clear
|
7
|
+
Task.clear
|
8
|
+
}
|
9
|
+
|
10
|
+
describe 'defaults' do
|
11
|
+
its(:name) { should == :version }
|
12
|
+
its(:language) { should == :cs }
|
13
|
+
its(:source) { should == :FromVersionFiles }
|
14
|
+
its(:source_args) { should == {} }
|
15
|
+
its(:target_path) { should be_an_instance_of(Proc) }
|
16
|
+
|
17
|
+
describe 'overriding defaults' do
|
18
|
+
subject {
|
19
|
+
described_class.new(:name) do |t|
|
20
|
+
t.language = [:cs, :vb]
|
21
|
+
t.source = []
|
22
|
+
t.source_args = { foo: 42 }
|
23
|
+
t.target_path = 'will not work'
|
24
|
+
end
|
25
|
+
}
|
26
|
+
|
27
|
+
its(:name) { should == :name }
|
28
|
+
its(:language) { should == [:cs, :vb] }
|
29
|
+
its(:source) { should == [] }
|
30
|
+
its(:source_args) { should == { foo: 42 } }
|
31
|
+
its(:target_path) { should == 'will not work' }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'execution' do
|
36
|
+
let(:writer) { double(AssemblyVersionWriter).as_null_object }
|
37
|
+
|
38
|
+
before {
|
39
|
+
allow(AssemblyVersionWriter).to receive(:new).and_return(writer)
|
40
|
+
}
|
41
|
+
|
42
|
+
before {
|
43
|
+
Task[subject.name].invoke
|
44
|
+
}
|
45
|
+
|
46
|
+
it 'should pass source and source_args' do
|
47
|
+
expect(AssemblyVersionWriter).to have_received(:new).with(subject.source, subject.source_args)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should use writer' do
|
51
|
+
expect(writer).to have_received(:write).with(subject.target_path, subject.language)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -8,7 +8,7 @@ describe Rake::Funnel::Tasks::BinPath do
|
|
8
8
|
|
9
9
|
describe 'defaults' do
|
10
10
|
its(:name) { should == :bin_path }
|
11
|
-
its(:
|
11
|
+
its(:search_pattern) { should eq(%w(tools/* tools/*/bin packages/**/tools)) }
|
12
12
|
end
|
13
13
|
|
14
14
|
describe 'execution' do
|
@@ -19,15 +19,15 @@ describe Rake::Funnel::Tasks::BinPath do
|
|
19
19
|
}
|
20
20
|
|
21
21
|
before {
|
22
|
-
subject.
|
22
|
+
subject.search_pattern = %w(foo bar)
|
23
23
|
|
24
|
-
allow(Dir).to receive(:[]).with(*subject.
|
24
|
+
allow(Dir).to receive(:[]).with(*subject.search_pattern).and_return(subject.search_pattern)
|
25
25
|
|
26
26
|
Task[:bin_path].invoke
|
27
27
|
}
|
28
28
|
|
29
29
|
it 'should prepend sorted matching folders to the PATH environment variable' do
|
30
|
-
paths = subject.
|
30
|
+
paths = subject.search_pattern.sort.map { |path| File.expand_path(path) } << ENV['PATH']
|
31
31
|
|
32
32
|
expect(ENV).to have_received(:[]=).with('PATH', paths.join(File::PATH_SEPARATOR))
|
33
33
|
end
|
@@ -45,7 +45,7 @@ describe Rake::Funnel::Tasks::Copy do
|
|
45
45
|
let(:target) { nil }
|
46
46
|
|
47
47
|
it 'should fail' do
|
48
|
-
expect
|
48
|
+
expect { Task[subject.name].invoke }.to raise_error(/Target not defined/)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
include Rake
|
2
|
-
include Rake::Funnel::Support
|
2
|
+
include Rake::Funnel::Support::Environments
|
3
3
|
include Rake::Funnel::Tasks
|
4
4
|
|
5
5
|
describe Rake::Funnel::Tasks::Environments do
|
@@ -9,6 +9,14 @@ describe Rake::Funnel::Tasks::Environments do
|
|
9
9
|
Task.clear
|
10
10
|
}
|
11
11
|
|
12
|
+
before {
|
13
|
+
module Kernel
|
14
|
+
def configatron
|
15
|
+
OpenStruct.new(name: 'fake configatron singleton')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
}
|
19
|
+
|
12
20
|
let(:files) { [] }
|
13
21
|
|
14
22
|
before {
|
@@ -28,6 +36,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
28
36
|
its(:default_env) { should be_nil }
|
29
37
|
its(:default_config) { should == 'default' }
|
30
38
|
its(:local_config) { should == 'local' }
|
39
|
+
its(:customizer) { should be_nil }
|
31
40
|
|
32
41
|
describe 'overriding defaults' do
|
33
42
|
subject {
|
@@ -36,6 +45,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
36
45
|
t.default_env = 'custom default_env'
|
37
46
|
t.default_config = 'custom default_config'
|
38
47
|
t.local_config = 'custom local_config'
|
48
|
+
t.customizer = Proc.new {}
|
39
49
|
end
|
40
50
|
}
|
41
51
|
|
@@ -43,6 +53,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
43
53
|
its(:default_env) { should == subject.default_env }
|
44
54
|
its(:default_config) { should == subject.default_config }
|
45
55
|
its(:local_config) { should == subject.local_config }
|
56
|
+
its(:customizer) { should be_instance_of(Proc) }
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
@@ -79,7 +90,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
79
90
|
}
|
80
91
|
|
81
92
|
before {
|
82
|
-
allow(
|
93
|
+
allow(Loader).to receive(:load_configuration)
|
83
94
|
}
|
84
95
|
|
85
96
|
before {
|
@@ -101,8 +112,8 @@ describe Rake::Funnel::Tasks::Environments do
|
|
101
112
|
let(:optional) { nil }
|
102
113
|
|
103
114
|
it 'should load all files' do
|
104
|
-
expect(
|
105
|
-
.to have_received(:load_configuration).with(hash_including({ config_files: %w(config/default.yaml config/dev.yaml config/local.yaml) }))
|
115
|
+
expect(Loader)
|
116
|
+
.to have_received(:load_configuration).with(hash_including({ config_files: %w(config/default.yaml config/dev.yaml config/local.yaml) }), any_args)
|
106
117
|
end
|
107
118
|
end
|
108
119
|
|
@@ -110,8 +121,8 @@ describe Rake::Funnel::Tasks::Environments do
|
|
110
121
|
let(:optional) { 'config/default.yaml' }
|
111
122
|
|
112
123
|
it 'should load environment file and local file' do
|
113
|
-
expect(
|
114
|
-
.to have_received(:load_configuration).with(hash_including({ config_files: %w(config/dev.yaml config/local.yaml) }))
|
124
|
+
expect(Loader)
|
125
|
+
.to have_received(:load_configuration).with(hash_including({ config_files: %w(config/dev.yaml config/local.yaml) }), any_args)
|
115
126
|
end
|
116
127
|
end
|
117
128
|
|
@@ -119,9 +130,54 @@ describe Rake::Funnel::Tasks::Environments do
|
|
119
130
|
let(:optional) { 'config/local.yaml' }
|
120
131
|
|
121
132
|
it 'should load default file and environment file' do
|
122
|
-
expect(
|
123
|
-
.to have_received(:load_configuration).with(hash_including({ config_files: %w(config/default.yaml config/dev.yaml) }))
|
133
|
+
expect(Loader)
|
134
|
+
.to have_received(:load_configuration).with(hash_including({ config_files: %w(config/default.yaml config/dev.yaml) }), any_args)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe 'store' do
|
140
|
+
let(:files) {
|
141
|
+
%w(config/dev.yaml)
|
142
|
+
}
|
143
|
+
|
144
|
+
before {
|
145
|
+
allow(Loader).to receive(:load_configuration)
|
146
|
+
}
|
147
|
+
|
148
|
+
before {
|
149
|
+
expect(subject).to be
|
150
|
+
Task['dev'].invoke
|
151
|
+
}
|
152
|
+
|
153
|
+
it 'should store configuration in configatron singleton' do
|
154
|
+
expect(Loader).to have_received(:load_configuration).with(anything, configatron, any_args)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe 'customization' do
|
159
|
+
let(:customizer) { Proc.new {} }
|
160
|
+
let(:files) {
|
161
|
+
%w(config/dev.yaml)
|
162
|
+
}
|
163
|
+
|
164
|
+
subject {
|
165
|
+
described_class.new do |t|
|
166
|
+
t.customizer = customizer
|
124
167
|
end
|
168
|
+
}
|
169
|
+
|
170
|
+
before {
|
171
|
+
allow(Loader).to receive(:load_configuration)
|
172
|
+
}
|
173
|
+
|
174
|
+
before {
|
175
|
+
expect(subject).to be
|
176
|
+
Task['dev'].invoke
|
177
|
+
}
|
178
|
+
|
179
|
+
it 'should pass customizer to loader' do
|
180
|
+
expect(Loader).to have_received(:load_configuration).with(anything, anything, customizer)
|
125
181
|
end
|
126
182
|
end
|
127
183
|
|
@@ -131,7 +187,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
131
187
|
}
|
132
188
|
|
133
189
|
before {
|
134
|
-
allow(
|
190
|
+
allow(Loader).to receive(:load_configuration)
|
135
191
|
}
|
136
192
|
|
137
193
|
context 'no default environment configured' do
|
@@ -140,7 +196,7 @@ describe Rake::Funnel::Tasks::Environments do
|
|
140
196
|
}
|
141
197
|
|
142
198
|
it 'should not invoke environment tasks' do
|
143
|
-
expect(
|
199
|
+
expect(Loader).not_to have_received(:load_configuration)
|
144
200
|
end
|
145
201
|
end
|
146
202
|
|
@@ -163,13 +219,13 @@ describe Rake::Funnel::Tasks::Environments do
|
|
163
219
|
let(:user_defined_task) { %w(foo) }
|
164
220
|
|
165
221
|
it 'should invoke default environment task' do
|
166
|
-
expect(
|
167
|
-
.to have_received(:load_configuration).with(hash_including({ name: 'dev' }))
|
222
|
+
expect(Loader)
|
223
|
+
.to have_received(:load_configuration).with(hash_including({ name: 'dev' }), any_args)
|
168
224
|
end
|
169
225
|
|
170
226
|
it 'should not invoke other environment tasks' do
|
171
|
-
expect(
|
172
|
-
.not_to have_received(:load_configuration).with(hash_including({ name: 'production' }))
|
227
|
+
expect(Loader)
|
228
|
+
.not_to have_received(:load_configuration).with(hash_including({ name: 'production' }), any_args)
|
173
229
|
end
|
174
230
|
end
|
175
231
|
|
@@ -177,13 +233,13 @@ describe Rake::Funnel::Tasks::Environments do
|
|
177
233
|
let(:user_defined_task) { %w(foo production) }
|
178
234
|
|
179
235
|
it 'should invoke user-defined environment task' do
|
180
|
-
expect(
|
181
|
-
.to have_received(:load_configuration).with(hash_including({ name: 'production' }))
|
236
|
+
expect(Loader)
|
237
|
+
.to have_received(:load_configuration).with(hash_including({ name: 'production' }), any_args)
|
182
238
|
end
|
183
239
|
|
184
240
|
it 'should not invoke other environment tasks' do
|
185
|
-
expect(
|
186
|
-
.not_to have_received(:load_configuration).with(hash_including({ name: 'dev' }))
|
241
|
+
expect(Loader)
|
242
|
+
.not_to have_received(:load_configuration).with(hash_including({ name: 'dev' }), any_args)
|
187
243
|
end
|
188
244
|
end
|
189
245
|
|
@@ -207,13 +263,13 @@ describe Rake::Funnel::Tasks::Environments do
|
|
207
263
|
let(:user_defined_task) { %w(foo) }
|
208
264
|
|
209
265
|
it 'should invoke default environment task' do
|
210
|
-
expect(
|
211
|
-
.to have_received(:load_configuration).with(hash_including({ name: 'dev' }))
|
266
|
+
expect(Loader)
|
267
|
+
.to have_received(:load_configuration).with(hash_including({ name: 'dev' }), any_args)
|
212
268
|
end
|
213
269
|
|
214
270
|
it 'should not invoke other environment tasks' do
|
215
|
-
expect(
|
216
|
-
.not_to have_received(:load_configuration).with(hash_including({ name: 'production' }))
|
271
|
+
expect(Loader)
|
272
|
+
.not_to have_received(:load_configuration).with(hash_including({ name: 'production' }), any_args)
|
217
273
|
end
|
218
274
|
end
|
219
275
|
|
@@ -221,13 +277,13 @@ describe Rake::Funnel::Tasks::Environments do
|
|
221
277
|
let(:user_defined_task) { %w(foo foo:bar:production) }
|
222
278
|
|
223
279
|
it 'should invoke user-defined environment task' do
|
224
|
-
expect(
|
225
|
-
.to have_received(:load_configuration).with(hash_including({ name: 'production' }))
|
280
|
+
expect(Loader)
|
281
|
+
.to have_received(:load_configuration).with(hash_including({ name: 'production' }), any_args)
|
226
282
|
end
|
227
283
|
|
228
284
|
it 'should not invoke other environment tasks' do
|
229
|
-
expect(
|
230
|
-
.not_to have_received(:load_configuration).with(hash_including({ name: 'dev' }))
|
285
|
+
expect(Loader)
|
286
|
+
.not_to have_received(:load_configuration).with(hash_including({ name: 'dev' }), any_args)
|
231
287
|
end
|
232
288
|
end
|
233
289
|
end
|
@@ -154,7 +154,7 @@ describe Rake::Funnel::Tasks::Paket do
|
|
154
154
|
}
|
155
155
|
|
156
156
|
it 'should fail' do
|
157
|
-
expect
|
157
|
+
expect { Task[subject.name].invoke }.to raise_error
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
@@ -174,7 +174,7 @@ describe Rake::Funnel::Tasks::Paket do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'should fail' do
|
177
|
-
expect
|
177
|
+
expect { Task[subject.name].invoke }.to raise_error
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|