albacore 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.autotest +4 -4
  2. data/.bundle/config +2 -2
  3. data/.rvmrc +1 -1
  4. data/Gemfile +12 -12
  5. data/README.markdown +92 -68
  6. data/VERSION +1 -1
  7. data/lib/albacore.rb +9 -9
  8. data/lib/albacore/albacoretask.rb +50 -50
  9. data/lib/albacore/aspnetcompiler.rb +58 -58
  10. data/lib/albacore/assemblyinfo.rb +140 -140
  11. data/lib/albacore/assemblyinfolanguages/cppcliengine.rb +17 -0
  12. data/lib/albacore/assemblyinfolanguages/csharpengine.rb +18 -18
  13. data/lib/albacore/assemblyinfolanguages/vbnetengine.rb +18 -18
  14. data/lib/albacore/config/aspnetcompilerconfig.rb +29 -29
  15. data/lib/albacore/config/assemblyinfoconfig.rb +13 -13
  16. data/lib/albacore/config/config.rb +22 -22
  17. data/lib/albacore/config/cscconfig.rb +28 -28
  18. data/lib/albacore/config/docuconfig.rb +23 -23
  19. data/lib/albacore/config/execconfig.rb +15 -15
  20. data/lib/albacore/config/fluentmigratorrunnerconfig.rb +15 -15
  21. data/lib/albacore/config/msbuildconfig.rb +29 -29
  22. data/lib/albacore/config/mspectestrunnerconfig.rb +15 -15
  23. data/lib/albacore/config/mstesttestrunnerconfig.rb +15 -15
  24. data/lib/albacore/config/nantconfig.rb +15 -15
  25. data/lib/albacore/config/nchurnconfig.rb +15 -15
  26. data/lib/albacore/config/ncoverconsoleconfig.rb +15 -15
  27. data/lib/albacore/config/ncoverreportconfig.rb +15 -15
  28. data/lib/albacore/config/ndependconfig.rb +15 -15
  29. data/lib/albacore/config/netversion.rb +21 -21
  30. data/lib/albacore/config/nugetpackconfig.rb +3 -3
  31. data/lib/albacore/config/nugetpublishconfig.rb +19 -0
  32. data/lib/albacore/config/nugetpushconfig.rb +19 -0
  33. data/lib/albacore/config/nunittestrunnerconfig.rb +14 -14
  34. data/lib/albacore/config/specflowreportconfig.rb +24 -24
  35. data/lib/albacore/config/sqlcmdconfig.rb +15 -15
  36. data/lib/albacore/config/unzipconfig.rb +15 -15
  37. data/lib/albacore/config/vssgetconfig.rb +14 -0
  38. data/lib/albacore/config/xbuildconfig.rb +15 -15
  39. data/lib/albacore/config/xunittestrunnerconfig.rb +15 -15
  40. data/lib/albacore/config/zipdirectoryconfig.rb +15 -15
  41. data/lib/albacore/csc.rb +66 -62
  42. data/lib/albacore/docu.rb +41 -41
  43. data/lib/albacore/exec.rb +18 -18
  44. data/lib/albacore/fluentmigratorrunner.rb +51 -46
  45. data/lib/albacore/msbuild.rb +55 -55
  46. data/lib/albacore/mspectestrunner.rb +50 -50
  47. data/lib/albacore/mstesttestrunner.rb +43 -43
  48. data/lib/albacore/nant.rb +38 -38
  49. data/lib/albacore/nchurn.rb +74 -74
  50. data/lib/albacore/ncoverconsole.rb +68 -68
  51. data/lib/albacore/ncoverreport.rb +62 -62
  52. data/lib/albacore/ncoverreports/assemblyfilter.rb +9 -9
  53. data/lib/albacore/ncoverreports/branchcoverage.rb +9 -9
  54. data/lib/albacore/ncoverreports/classfilter.rb +9 -9
  55. data/lib/albacore/ncoverreports/codecoveragebase.rb +25 -25
  56. data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +23 -23
  57. data/lib/albacore/ncoverreports/documentfilter.rb +9 -9
  58. data/lib/albacore/ncoverreports/fullcoveragereport.rb +13 -13
  59. data/lib/albacore/ncoverreports/methodcoverage.rb +9 -9
  60. data/lib/albacore/ncoverreports/methodfilter.rb +9 -9
  61. data/lib/albacore/ncoverreports/namespacefilter.rb +9 -9
  62. data/lib/albacore/ncoverreports/reportfilterbase.rb +26 -26
  63. data/lib/albacore/ncoverreports/summaryreport.rb +18 -18
  64. data/lib/albacore/ncoverreports/symbolcoverage.rb +9 -9
  65. data/lib/albacore/ndepend.rb +33 -33
  66. data/lib/albacore/nugetpublish.rb +47 -0
  67. data/lib/albacore/nugetpush.rb +46 -0
  68. data/lib/albacore/nunittestrunner.rb +41 -41
  69. data/lib/albacore/nuspec.rb +133 -109
  70. data/lib/albacore/output.rb +99 -99
  71. data/lib/albacore/plink.rb +47 -47
  72. data/lib/albacore/specflowreport.rb +62 -62
  73. data/lib/albacore/sqlcmd.rb +80 -80
  74. data/lib/albacore/support/attrmethods.rb +33 -33
  75. data/lib/albacore/support/createtask.rb +50 -30
  76. data/lib/albacore/support/failure.rb +15 -15
  77. data/lib/albacore/support/logging.rb +38 -38
  78. data/lib/albacore/support/openstruct.rb +13 -13
  79. data/lib/albacore/support/runcommand.rb +45 -45
  80. data/lib/albacore/support/supportlinux.rb +23 -23
  81. data/lib/albacore/support/updateattributes.rb +13 -13
  82. data/lib/albacore/support/yamlconfig.rb +18 -18
  83. data/lib/albacore/unzip.rb +28 -28
  84. data/lib/albacore/vssget.rb +44 -0
  85. data/lib/albacore/xbuild.rb +54 -54
  86. data/lib/albacore/xunittestrunner.rb +52 -52
  87. data/lib/albacore/zipdirectory.rb +105 -105
  88. data/rakefile.rb +297 -297
  89. data/spec/albacoremodel_spec.rb +53 -53
  90. data/spec/assemblyinfo_spec.rb +541 -541
  91. data/spec/attrmethods_spec.rb +136 -136
  92. data/spec/config_spec.rb +34 -34
  93. data/spec/createtask_spec.rb +236 -236
  94. data/spec/csc_spec.rb +253 -253
  95. data/spec/docu_spec.rb +109 -109
  96. data/spec/exec_spec.rb +45 -45
  97. data/spec/fluentmigratorrunner_spec.rb +254 -185
  98. data/spec/msbuild_spec.rb +215 -215
  99. data/spec/mspec_spec.rb +28 -28
  100. data/spec/mstesttestrunner_spec.rb +142 -142
  101. data/spec/nant_spec.rb +110 -110
  102. data/spec/nchurn_spec.rb +75 -75
  103. data/spec/ncoverconsole_spec.rb +353 -353
  104. data/spec/ncoverreport_spec.rb +619 -619
  105. data/spec/ndepend_spec.rb +72 -72
  106. data/spec/nunittestrunner_spec.rb +122 -122
  107. data/spec/nuspec_spec.rb +78 -78
  108. data/spec/patches/docu_patch.rb +12 -12
  109. data/spec/patches/fail_patch.rb +8 -8
  110. data/spec/patches/system_patch.rb +20 -20
  111. data/spec/plink_spec.rb +62 -62
  112. data/spec/runcommand_spec.rb +94 -94
  113. data/spec/spec_helper.rb +17 -17
  114. data/spec/specflowreport_spec.rb +146 -146
  115. data/spec/sqlcmd_spec.rb +334 -334
  116. data/spec/support/assemblyinfotester.rb +51 -51
  117. data/spec/support/ironruby_validator.rb +26 -26
  118. data/spec/support/msbuildtestdata.rb +32 -32
  119. data/spec/support/nanttestdata.rb +33 -33
  120. data/spec/support/ncoverconsoletestdata.rb +19 -19
  121. data/spec/support/ncoverreporttestdata.rb +26 -26
  122. data/spec/support/nokogiri_validator.rb +15 -15
  123. data/spec/support/outputtestdata.rb +12 -12
  124. data/spec/support/ziptestdata.rb +12 -12
  125. data/spec/unzip_spec.rb +15 -15
  126. data/spec/xbuild_spec.rb +15 -15
  127. data/spec/xunit_spec.rb +168 -168
  128. data/spec/yamlconfig_spec.rb +49 -49
  129. data/spec/zip_spec.rb +104 -104
  130. data/watchrtesting.rb +8 -8
  131. metadata +15 -119
@@ -1,136 +1,136 @@
1
- require 'spec_helper'
2
- require 'albacore/support/attrmethods'
3
-
4
- describe "when setting an array attribute value without the equal sign" do
5
- before :each do
6
- class Test_Class
7
- extend AttrMethods
8
- attr_array :test
9
- end
10
-
11
- @test = Test_Class.new
12
- @test.test 1, 2, 3, 4
13
- end
14
-
15
- it "should set the array to the specified values" do
16
- @test.test.length.should be(4)
17
- end
18
- end
19
-
20
- describe "when setting an array attribute with a params list, using the equal sign" do
21
- before :each do
22
- class Test_Class
23
- extend AttrMethods
24
- attr_array :test
25
- end
26
-
27
- @test = Test_Class.new
28
- @test.test = 1, 2, 3, 4
29
- end
30
-
31
- it "should set the array to the specified values" do
32
- @test.test.length.should be(4)
33
- end
34
- end
35
-
36
- describe "when setting an array attribute to an array variable using the equal sign" do
37
- before :each do
38
- class TestClass
39
- extend AttrMethods
40
- attr_array :test
41
- end
42
-
43
- test_values = [1, 2, 3, 4, 5]
44
- @test = TestClass.new
45
- @test.test = test_values
46
- end
47
-
48
- it "should set the array to the values contained in the variable" do
49
- @test.test.length.should be(5)
50
- end
51
- end
52
-
53
- describe "when setting an array attribute to an array without the equal sign" do
54
- before :each do
55
- class TestClass
56
- extend AttrMethods
57
- attr_array :test
58
- end
59
-
60
- @test = TestClass.new
61
- @test.test [1, 2, 3, 4, 5, 6]
62
- end
63
-
64
- it "should set the array to the values specified" do
65
- @test.test.length.should be(6)
66
- end
67
- end
68
-
69
- describe "when setting a hash attribute value without the equal sign" do
70
- before :each do
71
- class Test_Class
72
- extend AttrMethods
73
- attr_hash :test
74
- end
75
-
76
- @test = Test_Class.new
77
- @test.test "a" => "b", "c" => "d"
78
- end
79
-
80
- it "should set the hash to the specified values" do
81
- @test.test.length.should be(2)
82
- end
83
- end
84
-
85
- describe "when setting a hash attribute with a params list, using the equal sign" do
86
- before :each do
87
- class Test_Class
88
- extend AttrMethods
89
- attr_hash :test
90
- end
91
-
92
- @test = Test_Class.new
93
- @test.test = {"a" => "b", "c" => "d"}
94
- end
95
-
96
- it "should set the hash to the specified values" do
97
- @test.test.length.should be(2)
98
- end
99
- end
100
-
101
- describe "when setting a hash attribute to an hash variable using the equal sign" do
102
- before :each do
103
- class TestClass
104
- extend AttrMethods
105
- attr_hash :test
106
- end
107
-
108
- test_values = {"a" => "b", "c" => "d", "e" => "f"}
109
- @test = TestClass.new
110
- @test.test = test_values
111
- end
112
-
113
- it "should set the hash to the values contained in the variable" do
114
- @test.test.length.should be(3)
115
- end
116
- end
117
-
118
- describe "when setting a hash attribute to a hash across multiple lines" do
119
- before :each do
120
- class TestClass
121
- extend AttrMethods
122
- attr_hash :test
123
- end
124
-
125
- @test = TestClass.new
126
- @test.test(
127
- :a => "b",
128
- :c => "d",
129
- :e => "f"
130
- )
131
- end
132
-
133
- it "should set the hash to the values" do
134
- @test.test.length.should be(3)
135
- end
136
- end
1
+ require 'spec_helper'
2
+ require 'albacore/support/attrmethods'
3
+
4
+ describe "when setting an array attribute value without the equal sign" do
5
+ before :each do
6
+ class Test_Class
7
+ extend AttrMethods
8
+ attr_array :test
9
+ end
10
+
11
+ @test = Test_Class.new
12
+ @test.test 1, 2, 3, 4
13
+ end
14
+
15
+ it "should set the array to the specified values" do
16
+ @test.test.length.should be(4)
17
+ end
18
+ end
19
+
20
+ describe "when setting an array attribute with a params list, using the equal sign" do
21
+ before :each do
22
+ class Test_Class
23
+ extend AttrMethods
24
+ attr_array :test
25
+ end
26
+
27
+ @test = Test_Class.new
28
+ @test.test = 1, 2, 3, 4
29
+ end
30
+
31
+ it "should set the array to the specified values" do
32
+ @test.test.length.should be(4)
33
+ end
34
+ end
35
+
36
+ describe "when setting an array attribute to an array variable using the equal sign" do
37
+ before :each do
38
+ class TestClass
39
+ extend AttrMethods
40
+ attr_array :test
41
+ end
42
+
43
+ test_values = [1, 2, 3, 4, 5]
44
+ @test = TestClass.new
45
+ @test.test = test_values
46
+ end
47
+
48
+ it "should set the array to the values contained in the variable" do
49
+ @test.test.length.should be(5)
50
+ end
51
+ end
52
+
53
+ describe "when setting an array attribute to an array without the equal sign" do
54
+ before :each do
55
+ class TestClass
56
+ extend AttrMethods
57
+ attr_array :test
58
+ end
59
+
60
+ @test = TestClass.new
61
+ @test.test [1, 2, 3, 4, 5, 6]
62
+ end
63
+
64
+ it "should set the array to the values specified" do
65
+ @test.test.length.should be(6)
66
+ end
67
+ end
68
+
69
+ describe "when setting a hash attribute value without the equal sign" do
70
+ before :each do
71
+ class Test_Class
72
+ extend AttrMethods
73
+ attr_hash :test
74
+ end
75
+
76
+ @test = Test_Class.new
77
+ @test.test "a" => "b", "c" => "d"
78
+ end
79
+
80
+ it "should set the hash to the specified values" do
81
+ @test.test.length.should be(2)
82
+ end
83
+ end
84
+
85
+ describe "when setting a hash attribute with a params list, using the equal sign" do
86
+ before :each do
87
+ class Test_Class
88
+ extend AttrMethods
89
+ attr_hash :test
90
+ end
91
+
92
+ @test = Test_Class.new
93
+ @test.test = {"a" => "b", "c" => "d"}
94
+ end
95
+
96
+ it "should set the hash to the specified values" do
97
+ @test.test.length.should be(2)
98
+ end
99
+ end
100
+
101
+ describe "when setting a hash attribute to an hash variable using the equal sign" do
102
+ before :each do
103
+ class TestClass
104
+ extend AttrMethods
105
+ attr_hash :test
106
+ end
107
+
108
+ test_values = {"a" => "b", "c" => "d", "e" => "f"}
109
+ @test = TestClass.new
110
+ @test.test = test_values
111
+ end
112
+
113
+ it "should set the hash to the values contained in the variable" do
114
+ @test.test.length.should be(3)
115
+ end
116
+ end
117
+
118
+ describe "when setting a hash attribute to a hash across multiple lines" do
119
+ before :each do
120
+ class TestClass
121
+ extend AttrMethods
122
+ attr_hash :test
123
+ end
124
+
125
+ @test = TestClass.new
126
+ @test.test(
127
+ :a => "b",
128
+ :c => "d",
129
+ :e => "f"
130
+ )
131
+ end
132
+
133
+ it "should set the hash to the values" do
134
+ @test.test.length.should be(3)
135
+ end
136
+ end
@@ -1,34 +1,34 @@
1
- require 'spec_helper'
2
- require 'albacore/albacoretask'
3
- require 'albacore/config/config'
4
-
5
- class ConfigTest
6
- include Albacore::Task
7
- end
8
-
9
- module ConfigModuleTest
10
- include Albacore::Configuration
11
-
12
- def mixin_worked
13
- true
14
- end
15
- end
16
-
17
- describe "when configuring log level to verbose" do
18
- let :test do
19
- Albacore.configure do |config|
20
- config.log_level = :verbose
21
- end
22
- test = ConfigTest.new
23
- end
24
-
25
- it "should set the log level for any model" do
26
- test.log_level.should == :verbose
27
- end
28
- end
29
-
30
- describe "when including Albacore::Configuration in a module" do
31
- it "should mix the module into the Albacore.configuration" do
32
- Albacore.configuration.mixin_worked.should be_true
33
- end
34
- end
1
+ require 'spec_helper'
2
+ require 'albacore/albacoretask'
3
+ require 'albacore/config/config'
4
+
5
+ class ConfigTest
6
+ include Albacore::Task
7
+ end
8
+
9
+ module ConfigModuleTest
10
+ include Albacore::Configuration
11
+
12
+ def mixin_worked
13
+ true
14
+ end
15
+ end
16
+
17
+ describe "when configuring log level to verbose" do
18
+ let :test do
19
+ Albacore.configure do |config|
20
+ config.log_level = :verbose
21
+ end
22
+ test = ConfigTest.new
23
+ end
24
+
25
+ it "should set the log level for any model" do
26
+ test.log_level.should == :verbose
27
+ end
28
+ end
29
+
30
+ describe "when including Albacore::Configuration in a module" do
31
+ it "should mix the module into the Albacore.configuration" do
32
+ Albacore.configuration.mixin_worked.should be_true
33
+ end
34
+ end
@@ -1,236 +1,236 @@
1
- require 'spec_helper'
2
- require 'albacore/albacoretask'
3
- require 'fail_patch'
4
-
5
- class SampleObject
6
- include Albacore::Task
7
-
8
- attr_array :array
9
- attr_hash :hash
10
-
11
- def get_array
12
- @array
13
- end
14
-
15
- def get_hash
16
- @hash
17
- end
18
-
19
- def execute
20
- end
21
- end
22
-
23
- class RunCommandObject
24
- include Albacore::Task
25
- include Albacore::RunCommand
26
-
27
- def execute
28
- result = run_command "Run Command Test Object"
29
- end
30
- end
31
-
32
- class ConfigByNameOverride < SampleObject
33
- attr_accessor :task_name
34
- def load_config_by_task_name(name)
35
- @task_name = name
36
- end
37
- end
38
-
39
- describe "when defining a task" do
40
- before :all do
41
- Albacore.create_task :sampletask, ConfigByNameOverride
42
-
43
- sampletask :sample do |x|
44
- @config_obj = x
45
- end
46
- Rake::Task[:sample].invoke
47
- end
48
-
49
- it "should yield the object for configuration" do
50
- @config_obj.class.should == ConfigByNameOverride
51
- end
52
-
53
- it "should yield the object for execution" do
54
- @task_obj.should == @sample_object
55
- end
56
-
57
- it "should call the yaml configuration by task name" do
58
- @config_obj.task_name.should == :sample
59
- end
60
- end
61
-
62
- describe "when execution fails" do
63
- before :all do
64
- Albacore.create_task :failing_task, SampleObject
65
-
66
- failing_task :sample_fail do |x|
67
- x.extend(FailPatch)
68
- x.fail
69
- end
70
- Rake::Task[:sample_fail].invoke
71
- end
72
-
73
- it "should fail the rake task" do
74
- $task_failed.should == true
75
- end
76
- end
77
-
78
- describe "when task args are used" do
79
- before :all do
80
- Albacore.create_task :task_with_args, SampleObject
81
-
82
- task_with_args :sampletask_withargs, [:arg1] do |t, args|
83
- @args = args
84
- end
85
-
86
- Rake::Task[:sampletask_withargs].invoke("test")
87
- end
88
-
89
- it "should provide the task args" do
90
- @args.arg1.should == "test"
91
- end
92
- end
93
-
94
- describe "when calling a task method without providing a task name" do
95
- before :all do
96
- Albacore.create_task :task_without_name, SampleObject
97
-
98
- task_without_name do |t|
99
- @task_without_name_called = true
100
- end
101
-
102
- Rake::Task[:task_without_name].invoke
103
- end
104
-
105
- it "should create the the task by the task method's name" do
106
- @task_without_name_called = true
107
- end
108
- end
109
-
110
- describe "when calling a task method without providing a task parameter" do
111
- before :all do
112
- Albacore.create_task :task_without_param, SampleObject
113
-
114
- task_without_param do
115
- @task_without_param_called = true
116
- end
117
-
118
- Rake::Task[:task_without_param].invoke
119
- end
120
-
121
- it "should execute the task with no parameter provided" do
122
- @task_without_param_called = true
123
- end
124
- end
125
-
126
- describe "when calling a task without a task definition block" do
127
-
128
- before :all do
129
- Albacore.create_task :task_without_body, SampleObject
130
-
131
- task_without_body
132
-
133
- begin
134
- Rake::Task[:task_without_body].invoke
135
- @failed = false
136
- rescue
137
- @failed = true
138
- end
139
- end
140
-
141
- it "should execute the task" do
142
- @failed.should be_false
143
- end
144
- end
145
-
146
- describe "when creating two tasks and executing them" do
147
- before :all do
148
- Albacore.create_task :multiple_instance_task, SampleObject
149
-
150
- multiple_instance_task :multi_instance_1 do |mi|
151
- mi.array 1, 2
152
- mi.hash = { :a => :b, :c => :d }
153
- @instance_1 = mi
154
- end
155
-
156
- multiple_instance_task :multi_instance_2 do |mi|
157
- mi.array 3, 4
158
- mi.hash = { :e => :f, :g => :h }
159
- @instance_2 = mi
160
- end
161
-
162
- Rake::Task[:multi_instance_1].invoke
163
- Rake::Task[:multi_instance_2].invoke
164
- end
165
-
166
- it "should specify the array values once per task" do
167
- @instance_1.array.should == [1, 2]
168
- @instance_2.array.should == [3, 4]
169
- end
170
-
171
- it "should specify the hash values once per task" do
172
- @instance_1.hash.should == { :a => :b, :c => :d }
173
- @instance_2.hash.should == { :e => :f, :g => :h }
174
- end
175
-
176
- it "should create two separate instances of the task object" do
177
- @instance_1.object_id.should_not == @instance_2.object_id
178
- end
179
- end
180
-
181
- describe "when running two instances of a command line task" do
182
- before :all do
183
- Albacore.create_task :run_command_task, RunCommandObject do |ex|
184
- ex.execute
185
- end
186
-
187
- run_command_task :one do |x|
188
- x.extend(SystemPatch)
189
- x.command = "set"
190
- x.parameters "_albacore_test = test_one"
191
- @one = x
192
- end
193
-
194
- run_command_task :two do |x|
195
- x.extend(SystemPatch)
196
- x.command = "set"
197
- x.parameters "_another_albacore_test = test_two"
198
- @two = x
199
- end
200
-
201
- Rake::Task[:one].invoke
202
- Rake::Task[:two].invoke
203
- end
204
-
205
- it "should only pass the parameters specified to the first command" do
206
- @one.system_command.should == "\"set\" _albacore_test = test_one"
207
- end
208
-
209
- it "should only pass the parameters specified to the second command" do
210
- @two.system_command.should == "\"set\" _another_albacore_test = test_two"
211
- end
212
- end
213
-
214
- describe "when adding prerequisites through the rake api" do
215
- let :obj do
216
- Albacore.create_task :dependency_task, Object
217
-
218
- require 'ostruct'
219
- obj = OpenStruct.new
220
-
221
- task :first_task
222
- task :second_task do
223
- obj.dependency_called = true
224
- end
225
-
226
- firsttask = Rake::Task[:first_task]
227
- firsttask.enhance [:second_task]
228
- firsttask.invoke
229
-
230
- obj
231
- end
232
-
233
- it "should call the dependent tasks" do
234
- obj.dependency_called.should be_true
235
- end
236
- end
1
+ require 'spec_helper'
2
+ require 'albacore/albacoretask'
3
+ require 'fail_patch'
4
+
5
+ class SampleObject
6
+ include Albacore::Task
7
+
8
+ attr_array :array
9
+ attr_hash :hash
10
+
11
+ def get_array
12
+ @array
13
+ end
14
+
15
+ def get_hash
16
+ @hash
17
+ end
18
+
19
+ def execute
20
+ end
21
+ end
22
+
23
+ class RunCommandObject
24
+ include Albacore::Task
25
+ include Albacore::RunCommand
26
+
27
+ def execute
28
+ result = run_command "Run Command Test Object"
29
+ end
30
+ end
31
+
32
+ class ConfigByNameOverride < SampleObject
33
+ attr_accessor :task_name
34
+ def load_config_by_task_name(name)
35
+ @task_name = name
36
+ end
37
+ end
38
+
39
+ describe "when defining a task" do
40
+ before :all do
41
+ Albacore.create_task :sampletask, ConfigByNameOverride
42
+
43
+ sampletask :sample do |x|
44
+ @config_obj = x
45
+ end
46
+ Rake::Task[:sample].invoke
47
+ end
48
+
49
+ it "should yield the object for configuration" do
50
+ @config_obj.class.should == ConfigByNameOverride
51
+ end
52
+
53
+ it "should yield the object for execution" do
54
+ @task_obj.should == @sample_object
55
+ end
56
+
57
+ it "should call the yaml configuration by task name" do
58
+ @config_obj.task_name.should == :sample
59
+ end
60
+ end
61
+
62
+ describe "when execution fails" do
63
+ before :all do
64
+ Albacore.create_task :failing_task, SampleObject
65
+
66
+ failing_task :sample_fail do |x|
67
+ x.extend(FailPatch)
68
+ x.fail
69
+ end
70
+ Rake::Task[:sample_fail].invoke
71
+ end
72
+
73
+ it "should fail the rake task" do
74
+ $task_failed.should == true
75
+ end
76
+ end
77
+
78
+ describe "when task args are used" do
79
+ before :all do
80
+ Albacore.create_task :task_with_args, SampleObject
81
+
82
+ task_with_args :sampletask_withargs, [:arg1] do |t, args|
83
+ @args = args
84
+ end
85
+
86
+ Rake::Task[:sampletask_withargs].invoke("test")
87
+ end
88
+
89
+ it "should provide the task args" do
90
+ @args.arg1.should == "test"
91
+ end
92
+ end
93
+
94
+ describe "when calling a task method without providing a task name" do
95
+ before :all do
96
+ Albacore.create_task :task_without_name, SampleObject
97
+
98
+ task_without_name do |t|
99
+ @task_without_name_called = true
100
+ end
101
+
102
+ Rake::Task[:task_without_name].invoke
103
+ end
104
+
105
+ it "should create the the task by the task method's name" do
106
+ @task_without_name_called = true
107
+ end
108
+ end
109
+
110
+ describe "when calling a task method without providing a task parameter" do
111
+ before :all do
112
+ Albacore.create_task :task_without_param, SampleObject
113
+
114
+ task_without_param do
115
+ @task_without_param_called = true
116
+ end
117
+
118
+ Rake::Task[:task_without_param].invoke
119
+ end
120
+
121
+ it "should execute the task with no parameter provided" do
122
+ @task_without_param_called = true
123
+ end
124
+ end
125
+
126
+ describe "when calling a task without a task definition block" do
127
+
128
+ before :all do
129
+ Albacore.create_task :task_without_body, SampleObject
130
+
131
+ task_without_body
132
+
133
+ begin
134
+ Rake::Task[:task_without_body].invoke
135
+ @failed = false
136
+ rescue
137
+ @failed = true
138
+ end
139
+ end
140
+
141
+ it "should execute the task" do
142
+ @failed.should be_false
143
+ end
144
+ end
145
+
146
+ describe "when creating two tasks and executing them" do
147
+ before :all do
148
+ Albacore.create_task :multiple_instance_task, SampleObject
149
+
150
+ multiple_instance_task :multi_instance_1 do |mi|
151
+ mi.array 1, 2
152
+ mi.hash = { :a => :b, :c => :d }
153
+ @instance_1 = mi
154
+ end
155
+
156
+ multiple_instance_task :multi_instance_2 do |mi|
157
+ mi.array 3, 4
158
+ mi.hash = { :e => :f, :g => :h }
159
+ @instance_2 = mi
160
+ end
161
+
162
+ Rake::Task[:multi_instance_1].invoke
163
+ Rake::Task[:multi_instance_2].invoke
164
+ end
165
+
166
+ it "should specify the array values once per task" do
167
+ @instance_1.array.should == [1, 2]
168
+ @instance_2.array.should == [3, 4]
169
+ end
170
+
171
+ it "should specify the hash values once per task" do
172
+ @instance_1.hash.should == { :a => :b, :c => :d }
173
+ @instance_2.hash.should == { :e => :f, :g => :h }
174
+ end
175
+
176
+ it "should create two separate instances of the task object" do
177
+ @instance_1.object_id.should_not == @instance_2.object_id
178
+ end
179
+ end
180
+
181
+ describe "when running two instances of a command line task" do
182
+ before :all do
183
+ Albacore.create_task :run_command_task, RunCommandObject do |ex|
184
+ ex.execute
185
+ end
186
+
187
+ run_command_task :one do |x|
188
+ x.extend(SystemPatch)
189
+ x.command = "set"
190
+ x.parameters "_albacore_test = test_one"
191
+ @one = x
192
+ end
193
+
194
+ run_command_task :two do |x|
195
+ x.extend(SystemPatch)
196
+ x.command = "set"
197
+ x.parameters "_another_albacore_test = test_two"
198
+ @two = x
199
+ end
200
+
201
+ Rake::Task[:one].invoke
202
+ Rake::Task[:two].invoke
203
+ end
204
+
205
+ it "should only pass the parameters specified to the first command" do
206
+ @one.system_command.should == "\"set\" _albacore_test = test_one"
207
+ end
208
+
209
+ it "should only pass the parameters specified to the second command" do
210
+ @two.system_command.should == "\"set\" _another_albacore_test = test_two"
211
+ end
212
+ end
213
+
214
+ describe "when adding prerequisites through the rake api" do
215
+ let :obj do
216
+ Albacore.create_task :dependency_task, Object
217
+
218
+ require 'ostruct'
219
+ obj = OpenStruct.new
220
+
221
+ task :first_task
222
+ task :second_task do
223
+ obj.dependency_called = true
224
+ end
225
+
226
+ firsttask = Rake::Task[:first_task]
227
+ firsttask.enhance [:second_task]
228
+ firsttask.invoke
229
+
230
+ obj
231
+ end
232
+
233
+ it "should call the dependent tasks" do
234
+ obj.dependency_called.should be_true
235
+ end
236
+ end