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
@@ -2,6 +2,8 @@ require 'rake/tasklib'
|
|
2
2
|
|
3
3
|
module Rake::Funnel::Tasks
|
4
4
|
class NUnit < Rake::TaskLib
|
5
|
+
include Rake::Funnel::Support
|
6
|
+
|
5
7
|
attr_accessor :name, :files, :args
|
6
8
|
|
7
9
|
def initialize(name = :test)
|
@@ -28,9 +30,9 @@ module Rake::Funnel::Tasks
|
|
28
30
|
Rake::Funnel::Integration::TeamCity::NUnitPlugin.setup(nunit)
|
29
31
|
|
30
32
|
cmd = [
|
31
|
-
*
|
33
|
+
*Mono.invocation(nunit),
|
32
34
|
*test_assemblies.all,
|
33
|
-
*
|
35
|
+
*Mapper.new(:NUnit).map(args)
|
34
36
|
]
|
35
37
|
|
36
38
|
sh(*cmd)
|
@@ -40,7 +42,7 @@ module Rake::Funnel::Tasks
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def test_assemblies
|
43
|
-
|
45
|
+
Finder.new(files, self, 'No test assemblies found.')
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -2,6 +2,8 @@ require 'rake/tasklib'
|
|
2
2
|
|
3
3
|
module Rake::Funnel::Tasks
|
4
4
|
class Paket < Rake::TaskLib
|
5
|
+
include Rake::Funnel::Support
|
6
|
+
|
5
7
|
attr_accessor :name, :paket, :paket_args, :bootstrapper, :bootstrapper_args
|
6
8
|
|
7
9
|
def initialize(name = :paket)
|
@@ -29,11 +31,11 @@ module Rake::Funnel::Tasks
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def bootstrapper_cmd
|
32
|
-
|
34
|
+
Mono.invocation(bootstrapper, bootstrapper_args)
|
33
35
|
end
|
34
36
|
|
35
37
|
def paket_cmd
|
36
|
-
|
38
|
+
Mono.invocation(paket, paket_args)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -3,6 +3,8 @@ require 'rake/tasklib'
|
|
3
3
|
|
4
4
|
module Rake::Funnel::Tasks
|
5
5
|
class QuickTemplate < Rake::TaskLib
|
6
|
+
include Rake::Funnel::Support
|
7
|
+
|
6
8
|
attr_accessor :name, :search_pattern, :context
|
7
9
|
|
8
10
|
def initialize(name = :template)
|
@@ -35,7 +37,7 @@ module Rake::Funnel::Tasks
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def templates
|
38
|
-
|
40
|
+
Finder.new(search_pattern, self, 'No templates found.')
|
39
41
|
end
|
40
42
|
|
41
43
|
def result_filename(template)
|
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'rake/tasklib'
|
2
2
|
|
3
|
-
Dir["#{File.dirname(__FILE__)}/side_by_side_specs_support/*.rb"].each do |path|
|
4
|
-
require path
|
5
|
-
end
|
6
|
-
|
7
3
|
module Rake::Funnel::Tasks
|
8
4
|
class SideBySideSpecs < Rake::TaskLib
|
5
|
+
include Rake::Funnel::Support::SideBySideSpecs
|
6
|
+
|
9
7
|
attr_accessor :name, :projects, :references, :specs, :enabled
|
10
8
|
|
11
9
|
def initialize(name = :compile)
|
@@ -24,7 +22,7 @@ module Rake::Funnel::Tasks
|
|
24
22
|
def define
|
25
23
|
task name do
|
26
24
|
next unless enabled
|
27
|
-
|
25
|
+
Remover.remove({ projects: projects, references: references, specs: specs })
|
28
26
|
end
|
29
27
|
|
30
28
|
self
|
@@ -1,18 +1,15 @@
|
|
1
|
-
require 'rake'
|
2
1
|
require 'rake/tasklib'
|
3
2
|
|
4
|
-
Dir["#{File.dirname(__FILE__)}/timing_support/*.rb"].each do |path|
|
5
|
-
require path
|
6
|
-
end
|
7
|
-
|
8
3
|
module Rake::Funnel::Tasks
|
9
4
|
class Timing < Rake::TaskLib
|
5
|
+
include Rake::Funnel::Support::Timing
|
6
|
+
|
10
7
|
attr_accessor :name
|
11
8
|
attr_reader :stats
|
12
9
|
|
13
10
|
def initialize(name = :timing)
|
14
11
|
@name = name
|
15
|
-
@stats =
|
12
|
+
@stats = Statistics.new
|
16
13
|
|
17
14
|
yield self if block_given?
|
18
15
|
|
@@ -28,7 +25,7 @@ module Rake::Funnel::Tasks
|
|
28
25
|
patches.each { |p| p.apply! }
|
29
26
|
|
30
27
|
task @name, :failed do |task, args|
|
31
|
-
|
28
|
+
Report.new(@stats, args).render
|
32
29
|
end
|
33
30
|
|
34
31
|
timing_task = Rake.application.current_scope.path_with_task_name(@name)
|
@@ -43,7 +40,7 @@ module Rake::Funnel::Tasks
|
|
43
40
|
|
44
41
|
def report
|
45
42
|
Rake::Funnel::Support::Patch.new do |p|
|
46
|
-
report_invoker = -> (opts) {
|
43
|
+
report_invoker = -> (opts) { Report.new(@stats, opts).render }
|
47
44
|
|
48
45
|
p.setup do
|
49
46
|
Rake::Application.class_eval do
|
@@ -4,6 +4,8 @@ require 'zip'
|
|
4
4
|
|
5
5
|
module Rake::Funnel::Tasks
|
6
6
|
class Zip < Rake::TaskLib
|
7
|
+
include Rake::Funnel::Support
|
8
|
+
|
7
9
|
attr_accessor :name, :source, :target, :zip_root
|
8
10
|
|
9
11
|
def initialize(name = :package)
|
@@ -38,7 +40,7 @@ module Rake::Funnel::Tasks
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def files
|
41
|
-
|
43
|
+
Finder.new(source, self, 'No files to zip.').all_or_default
|
42
44
|
end
|
43
45
|
|
44
46
|
def configure_zip
|
data/lib/rake/funnel/version.rb
CHANGED
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe Rake::Funnel::Extensions::PascalCase do
|
2
|
+
it 'should convert strings' do
|
3
|
+
expect('foo'.pascalize).to eq('Foo')
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'should convert strings with underscores' do
|
7
|
+
expect('foo_bar'.pascalize).to eq('FooBar')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should convert symbols to string' do
|
11
|
+
expect(:foo.pascalize).to eq('Foo')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should convert symbols with underscores' do
|
15
|
+
expect(:foo_bar.pascalize).to eq('FooBar')
|
16
|
+
end
|
17
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
include Rake::Funnel::Support
|
1
|
+
include Rake::Funnel::Support::ArgumentMapper
|
2
2
|
|
3
|
-
|
4
|
-
style_path =
|
3
|
+
Styles.constants.reject { |x| x == :MSDeploy }.each do |style|
|
4
|
+
style_path = Styles.const_get(style)
|
5
5
|
describe style_path do
|
6
6
|
subject {
|
7
7
|
Mapper.new(style)
|
8
8
|
}
|
9
9
|
|
10
10
|
let (:style) {
|
11
|
-
|
11
|
+
Styles.const_get(style).new
|
12
12
|
}
|
13
13
|
|
14
14
|
def styled(switch, key = nil, value = nil)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
include Rake::Funnel::Support
|
2
|
+
|
3
|
+
describe Rake::Funnel::Support::AssemblyVersion::FromVersionFiles do
|
4
|
+
describe 'defaults' do
|
5
|
+
its(:search_pattern) { should == %w(**/VERSION) }
|
6
|
+
its(:build_number) { should be_nil }
|
7
|
+
its(:sha) { should be_nil }
|
8
|
+
|
9
|
+
describe 'overriding defaults' do
|
10
|
+
subject {
|
11
|
+
described_class.new({
|
12
|
+
search_pattern: 'search pattern',
|
13
|
+
build_number: 42,
|
14
|
+
sha: 'abc'
|
15
|
+
})
|
16
|
+
}
|
17
|
+
|
18
|
+
its(:search_pattern) { should == 'search pattern' }
|
19
|
+
its(:build_number) { should == 42 }
|
20
|
+
its(:sha) { should == 'abc' }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'enumerable' do
|
25
|
+
it { is_expected.to be_kind_of(Enumerable) }
|
26
|
+
it { is_expected.to respond_to(:each) }
|
27
|
+
|
28
|
+
it 'should yield enumerator' do
|
29
|
+
expect(subject.each).to be_kind_of(Enumerator)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'enumeration' do
|
34
|
+
let(:finder) { double(Finder).as_null_object }
|
35
|
+
let(:files) { %w(1 2) }
|
36
|
+
|
37
|
+
before {
|
38
|
+
allow(finder).to receive(:all_or_default).and_return(files)
|
39
|
+
allow(Finder).to receive(:new).and_return(finder)
|
40
|
+
}
|
41
|
+
|
42
|
+
before {
|
43
|
+
allow(VersionInfo).to receive(:read_version_from).and_return(*files)
|
44
|
+
}
|
45
|
+
|
46
|
+
before {
|
47
|
+
allow(Rake).to receive(:rake_output_message)
|
48
|
+
}
|
49
|
+
|
50
|
+
subject {
|
51
|
+
described_class.new({ build_number: 42, sha: 'abc' })
|
52
|
+
}
|
53
|
+
|
54
|
+
it 'should yield source and version info for each file' do
|
55
|
+
expect { |b| subject.each(&b) }.to yield_successive_args(
|
56
|
+
{ source: '1', version_info: VersionInfo.new({ assembly_version: '1', assembly_file_version: '1.42', assembly_informational_version: '1.42-abc' }) },
|
57
|
+
{ source: '2', version_info: VersionInfo.new({ assembly_version: '2', assembly_file_version: '2.42', assembly_informational_version: '2.42-abc' }) }
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
include Rake::Funnel::Support
|
4
|
+
|
5
|
+
describe Rake::Funnel::Support::AssemblyVersionWriter do
|
6
|
+
describe 'version source' do
|
7
|
+
describe 'default' do
|
8
|
+
before {
|
9
|
+
allow_any_instance_of(described_class).to receive(:create)
|
10
|
+
}
|
11
|
+
|
12
|
+
it 'should create FromVersionFiles with empty args' do
|
13
|
+
expect(subject).to have_received(:create).with(:FromVersionFiles, {})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'custom type' do
|
18
|
+
let(:source) { :Custom }
|
19
|
+
let(:source_args) { { foo: 42 } }
|
20
|
+
|
21
|
+
before {
|
22
|
+
allow_any_instance_of(described_class).to receive(:create)
|
23
|
+
}
|
24
|
+
|
25
|
+
subject {
|
26
|
+
described_class.new(source, source_args)
|
27
|
+
}
|
28
|
+
|
29
|
+
it 'should create type with args' do
|
30
|
+
expect(subject).to have_received(:create).with(source, source_args)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'custom instance' do
|
35
|
+
let(:source) {
|
36
|
+
[
|
37
|
+
{
|
38
|
+
source: 'from e.g. gitversion',
|
39
|
+
version_info: VersionInfo.new(
|
40
|
+
{
|
41
|
+
assembly_version: '1',
|
42
|
+
assembly_file_version: '1.2',
|
43
|
+
assembly_informational_version: '1.2-abc'
|
44
|
+
})
|
45
|
+
}
|
46
|
+
]
|
47
|
+
}
|
48
|
+
|
49
|
+
subject {
|
50
|
+
described_class.new(source)
|
51
|
+
}
|
52
|
+
|
53
|
+
it 'should succeed' do
|
54
|
+
expect(true).to eq(true)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'generator' do
|
60
|
+
let(:source) {
|
61
|
+
[
|
62
|
+
{
|
63
|
+
source: 'one',
|
64
|
+
version_info: VersionInfo.new(
|
65
|
+
{
|
66
|
+
assembly_version: '1',
|
67
|
+
assembly_file_version: '1.2',
|
68
|
+
assembly_informational_version: '1.2-abc'
|
69
|
+
})
|
70
|
+
},
|
71
|
+
{
|
72
|
+
source: 'two',
|
73
|
+
version_info: VersionInfo.new(
|
74
|
+
{
|
75
|
+
assembly_version: '2',
|
76
|
+
assembly_file_version: '2.3',
|
77
|
+
assembly_informational_version: '2.3-def'
|
78
|
+
})
|
79
|
+
}
|
80
|
+
]
|
81
|
+
}
|
82
|
+
|
83
|
+
let(:target_path) { double(Proc).as_null_object }
|
84
|
+
let(:languages) { [:vb, :cs, :fs] }
|
85
|
+
let(:erb) { double(ERB).as_null_object }
|
86
|
+
|
87
|
+
subject {
|
88
|
+
described_class.new(source)
|
89
|
+
}
|
90
|
+
|
91
|
+
before {
|
92
|
+
allow(Rake).to receive(:rake_output_message)
|
93
|
+
}
|
94
|
+
|
95
|
+
before {
|
96
|
+
allow(ERB).to receive(:new).and_return(erb)
|
97
|
+
}
|
98
|
+
|
99
|
+
before {
|
100
|
+
allow(File).to receive(:read).and_return('template')
|
101
|
+
allow(File).to receive(:write)
|
102
|
+
}
|
103
|
+
|
104
|
+
context 'supported languages' do
|
105
|
+
before {
|
106
|
+
subject.write(target_path, languages)
|
107
|
+
}
|
108
|
+
|
109
|
+
it 'should determine target path for each language in source' do
|
110
|
+
source.each do |src|
|
111
|
+
languages.each do |language|
|
112
|
+
expect(target_path).to have_received(:call).with(language, src[:version_info], src[:source])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should read version info template for languages' do
|
118
|
+
languages.each do |language|
|
119
|
+
expect(File).to have_received(:read).with(%r|assembly_version/languages/#{language}|).at_least(:once)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should run templates through ERb' do
|
124
|
+
expect(erb).to have_received(:result).exactly(languages.length * source.length).times
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should write version info file for each language in source' do
|
128
|
+
expect(File).to have_received(:write).exactly(languages.length * source.length).times
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'unsupported language' do
|
133
|
+
let(:languages) { :unsupported }
|
134
|
+
|
135
|
+
it 'should fail' do
|
136
|
+
expect { subject.write(target_path, languages) }.to raise_error /Language is not supported: unsupported/
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
|
-
describe Rake::Funnel::
|
1
|
+
describe Rake::Funnel::Support::Environments::Loader do
|
2
2
|
let(:store) {
|
3
3
|
double(Configatron::Store).as_null_object
|
4
4
|
}
|
5
5
|
|
6
|
+
let(:customizer) { nil }
|
7
|
+
|
6
8
|
let(:config) {
|
7
9
|
{
|
8
10
|
name: 'environment name',
|
@@ -27,7 +29,7 @@ describe Rake::Funnel::Tasks::EnvironmentsSupport::Loader do
|
|
27
29
|
}
|
28
30
|
|
29
31
|
before {
|
30
|
-
described_class.load_configuration(config, store)
|
32
|
+
described_class.load_configuration(config, store, customizer)
|
31
33
|
}
|
32
34
|
|
33
35
|
it 'should reinitialize the configatron store' do
|
@@ -54,6 +56,14 @@ describe Rake::Funnel::Tasks::EnvironmentsSupport::Loader do
|
|
54
56
|
expect(store).to have_received(:lock!)
|
55
57
|
end
|
56
58
|
|
59
|
+
describe 'customization' do
|
60
|
+
let(:customizer) { double(Proc).as_null_object }
|
61
|
+
|
62
|
+
it 'should run the customizer' do
|
63
|
+
expect(customizer).to have_received(:call).with(store)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
57
67
|
context 'config file with overriding values' do
|
58
68
|
let(:config_files) {
|
59
69
|
{
|
@@ -125,7 +135,7 @@ describe Rake::Funnel::Tasks::EnvironmentsSupport::Loader do
|
|
125
135
|
}
|
126
136
|
|
127
137
|
it 'should report file name' do
|
128
|
-
expect
|
138
|
+
expect { described_class.load_configuration(config, store) }
|
129
139
|
.to raise_error { |ex| expect(ex.backtrace.join("\n")).to match(/with_erb/) }
|
130
140
|
end
|
131
141
|
end
|
@@ -34,9 +34,10 @@ describe Rake::Funnel::Support::Finder do
|
|
34
34
|
let(:generate) { %w(1 2 3 4) }
|
35
35
|
let(:pattern) { '**/*' }
|
36
36
|
|
37
|
-
it
|
38
|
-
|
39
|
-
|
37
|
+
it { is_expected.to be_kind_of(Enumerable) }
|
38
|
+
it { is_expected.to respond_to(:each) }
|
39
|
+
|
40
|
+
it 'should yield enumerator' do
|
40
41
|
expect(subject.each).to be_kind_of(Enumerator)
|
41
42
|
end
|
42
43
|
|
@@ -112,7 +113,7 @@ describe Rake::Funnel::Support::Finder do
|
|
112
113
|
context 'no matching files' do
|
113
114
|
it 'should fail' do
|
114
115
|
Dir.chdir(temp_dir) do
|
115
|
-
expect
|
116
|
+
expect { subject.single }.to raise_error(AmbiguousFileError, /error message/)
|
116
117
|
end
|
117
118
|
end
|
118
119
|
end
|
@@ -122,7 +123,7 @@ describe Rake::Funnel::Support::Finder do
|
|
122
123
|
|
123
124
|
it 'should fail' do
|
124
125
|
Dir.chdir(temp_dir) do
|
125
|
-
expect
|
126
|
+
expect { subject.single }.to raise_error(AmbiguousFileError, /error message/)
|
126
127
|
end
|
127
128
|
end
|
128
129
|
end
|
@@ -171,7 +172,7 @@ describe Rake::Funnel::Support::Finder do
|
|
171
172
|
describe '#all' do
|
172
173
|
context 'no matching files' do
|
173
174
|
it 'should fail' do
|
174
|
-
expect
|
175
|
+
expect { subject.all }.to raise_error(AmbiguousFileError, /error message/)
|
175
176
|
end
|
176
177
|
end
|
177
178
|
|
@@ -0,0 +1,183 @@
|
|
1
|
+
describe Rake::Funnel::Support::InstantiateSymbol do
|
2
|
+
module Creatable
|
3
|
+
class One
|
4
|
+
end
|
5
|
+
|
6
|
+
class Two
|
7
|
+
end
|
8
|
+
|
9
|
+
class Three
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ExplicitModuleDefinition
|
14
|
+
include Rake::Funnel::Support::InstantiateSymbol
|
15
|
+
instantiate Creatable
|
16
|
+
|
17
|
+
class Nested
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ImplicitModuleDefinition
|
22
|
+
include Rake::Funnel::Support::InstantiateSymbol
|
23
|
+
|
24
|
+
class Nested
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'module methods' do
|
29
|
+
subject {
|
30
|
+
ExplicitModuleDefinition.new
|
31
|
+
}
|
32
|
+
|
33
|
+
describe 'instance methods' do
|
34
|
+
it 'should not be public' do
|
35
|
+
expect(subject).not_to respond_to(:create)
|
36
|
+
expect(subject).not_to respond_to(:available)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'class methods' do
|
41
|
+
it 'should not be public' do
|
42
|
+
expect(subject.class).not_to respond_to(:instantiate)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'inspection' do
|
48
|
+
context 'implicit module' do
|
49
|
+
subject {
|
50
|
+
ImplicitModuleDefinition.new
|
51
|
+
}
|
52
|
+
|
53
|
+
it 'should yield constants in self' do
|
54
|
+
expect(subject.send(:available)).to eq([:ClassMethods, :Nested])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'explicit module' do
|
59
|
+
subject {
|
60
|
+
ExplicitModuleDefinition.new
|
61
|
+
}
|
62
|
+
|
63
|
+
it 'should yield sorted constants in module' do
|
64
|
+
expect(subject.send(:available)).to eq([:One, :Three, :Two])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'multiple uses' do
|
69
|
+
subject {
|
70
|
+
[
|
71
|
+
ExplicitModuleDefinition.new,
|
72
|
+
ImplicitModuleDefinition.new
|
73
|
+
]
|
74
|
+
}
|
75
|
+
|
76
|
+
it 'should not overlap' do
|
77
|
+
first = subject[0].send(:available)
|
78
|
+
second = subject[1].send(:available)
|
79
|
+
|
80
|
+
expect(first).not_to include(second)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'instantiation' do
|
86
|
+
subject {
|
87
|
+
ExplicitModuleDefinition.new
|
88
|
+
}
|
89
|
+
|
90
|
+
context 'with instance' do
|
91
|
+
it 'should return instance' do
|
92
|
+
instance = Object.new
|
93
|
+
|
94
|
+
expect(subject.send(:create, instance)).to eq(instance)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
context 'with nil' do
|
100
|
+
it 'should return nil' do
|
101
|
+
expect(subject.send(:create, nil)).to eq(nil)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'symbol not defined' do
|
106
|
+
it 'should fail' do
|
107
|
+
expect { subject.send(:create, :does_not_exist) }.to raise_error 'Unknown type to instantiate: :does_not_exist. Available types are: [:One, :Three, :Two]'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'instantiation fails' do
|
112
|
+
class WillFail
|
113
|
+
include Rake::Funnel::Support::InstantiateSymbol
|
114
|
+
|
115
|
+
class Failure
|
116
|
+
def initialize
|
117
|
+
raise "BAM!"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
subject {
|
123
|
+
WillFail.new
|
124
|
+
}
|
125
|
+
|
126
|
+
it 'should fail' do
|
127
|
+
expect { subject.send(:create, :Failure) }.to raise_error "BAM!"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'instantiation succeeds' do
|
132
|
+
it 'should return instance' do
|
133
|
+
expect(subject.send(:create, :One)).to be_an_instance_of(Creatable::One)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe 'args' do
|
138
|
+
module CreatableWithArgs
|
139
|
+
class None
|
140
|
+
def initialize
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class Single
|
145
|
+
def initialize(arg)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
class Multiple
|
150
|
+
def initialize(arg1, arg2)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
class WithArgs
|
156
|
+
include Rake::Funnel::Support::InstantiateSymbol
|
157
|
+
instantiate CreatableWithArgs
|
158
|
+
end
|
159
|
+
|
160
|
+
subject {
|
161
|
+
WithArgs.new
|
162
|
+
}
|
163
|
+
|
164
|
+
context 'no argument' do
|
165
|
+
it 'should not pass arg' do
|
166
|
+
expect(subject.send(:create, :None)).to be_an_instance_of(CreatableWithArgs::None)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'single argument' do
|
171
|
+
it 'should pass arg' do
|
172
|
+
expect(subject.send(:create, :Single, 1)).to be_an_instance_of(CreatableWithArgs::Single)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'multiple argument' do
|
177
|
+
it 'should pass args' do
|
178
|
+
expect(subject.send(:create, :Multiple, 1, 2)).to be_an_instance_of(CreatableWithArgs::Multiple)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|