tool-shed 0.0.7 → 0.0.9
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.
- data/README.md +18 -19
- data/bin/as-concrete +16 -0
- data/lib/shed/asset_vacuum.rb +43 -20
- data/lib/shed/class_vacuum.rb +18 -9
- data/lib/shed/concrete.rb +100 -0
- data/lib/shed/interface.rb +163 -0
- data/lib/shed/manifest.rb +2 -2
- data/lib/shed/mixers/actionscript_class.rb +65 -0
- data/lib/shed/mixers/just_implement.rb +15 -0
- data/lib/shed/mixers/mock4as.rb +23 -0
- data/lib/shed/opts/concrete_opts.rb +33 -0
- data/lib/shed/opts/tool_opts.rb +3 -1
- data/lib/shed/style_vacuum.rb +14 -10
- data/lib/shed/tasks.rb +84 -0
- data/lib/shed/tool.rb +8 -0
- data/lib/shed/version.rb +1 -1
- data/lib/tool_shed.rb +7 -1
- data/rakefile.rb +28 -2
- data/test/fixtures/interface/ISeedPacket.as +61 -0
- data/test/fixtures/interface/IShed.as +17 -0
- data/test/fixtures/interface/Shed.as +14 -0
- data/test/unit/test_asdoc_package.rb +12 -6
- data/test/unit/test_asdoc_package_opts.rb +1 -1
- data/test/unit/test_asset_vacuum.rb +13 -7
- data/test/unit/test_asset_vacuum_opts.rb +0 -3
- data/test/unit/test_class_vacuum.rb +11 -6
- data/test/unit/test_concrete.rb +236 -0
- data/test/unit/test_concrete_opts.rb +54 -0
- data/test/unit/test_interface.rb +142 -0
- data/test/unit/test_manifest.rb +1 -1
- data/test/unit/test_manifest_opts.rb +1 -2
- data/test/unit/test_search.rb +1 -1
- data/test/unit/test_source_tools.rb +1 -1
- data/test/unit/test_stripper.rb +1 -1
- data/test/unit/test_style_vacuum.rb +20 -10
- data/test/unit/test_tool.rb +2 -1
- data/test/unit/test_tool_opts.rb +16 -3
- metadata +96 -117
@@ -0,0 +1,236 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
|
+
|
5
|
+
class TestConcrete < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def fix
|
8
|
+
File.expand_path(File.dirname(__FILE__)+ "/../fixtures/interface")
|
9
|
+
end
|
10
|
+
|
11
|
+
context "A concrete generator tool running with a missing interface file" do
|
12
|
+
|
13
|
+
should "exit with an error message" do
|
14
|
+
|
15
|
+
opts = ConcreteOpts.parse ['-i', "#{fix}/IDoNotExist.as"]
|
16
|
+
out = StringIO.new
|
17
|
+
|
18
|
+
begin
|
19
|
+
Concrete.new(opts,out)
|
20
|
+
flunk
|
21
|
+
rescue SystemExit => e
|
22
|
+
assert_equal 0, e.status
|
23
|
+
assert_match(/#{Tool::INVALID_OPTS}/, out.string)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
context "A concrete generator tool given an invalid interface file" do
|
31
|
+
|
32
|
+
should "exit with an error message" do
|
33
|
+
|
34
|
+
opts = ConcreteOpts.parse ['-i', "#{fix}/Shed.as"]
|
35
|
+
out = StringIO.new
|
36
|
+
|
37
|
+
begin
|
38
|
+
Concrete.new(opts,out)
|
39
|
+
flunk
|
40
|
+
rescue SystemExit => e
|
41
|
+
assert_equal 0, e.status
|
42
|
+
assert_match(/#{Tool::INVALID_OPTS} The specified/, out.string)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
context "A concrete generator tool" do
|
50
|
+
|
51
|
+
context "outputting actionscript classes" do
|
52
|
+
|
53
|
+
setup do
|
54
|
+
opts = ConcreteOpts.parse ['-i', "#{fix}/IShed.as"]
|
55
|
+
@out = StringIO.new
|
56
|
+
@concrete = Concrete.new(opts,@out)
|
57
|
+
end
|
58
|
+
|
59
|
+
should "output a string" do
|
60
|
+
assert_not_nil(@out.string)
|
61
|
+
end
|
62
|
+
|
63
|
+
should "output a package declaration" do
|
64
|
+
assert_match(/^package/, @out.string)
|
65
|
+
end
|
66
|
+
|
67
|
+
should "output a class declaration" do
|
68
|
+
assert_match(/^class Shed/, @out.string)
|
69
|
+
end
|
70
|
+
|
71
|
+
should "implement the expected interface" do
|
72
|
+
assert_match(/implements IShed$/, @out.string)
|
73
|
+
end
|
74
|
+
|
75
|
+
should "output getters with the expected return type" do
|
76
|
+
assert_match(/public function get windows\(\):int/, @out.string)
|
77
|
+
assert_match(/public function get doors\(\):uint/, @out.string)
|
78
|
+
end
|
79
|
+
|
80
|
+
should "output setters with the correct return type" do
|
81
|
+
assert_match(/public function set windows\(value:int\):void/, @out.string)
|
82
|
+
end
|
83
|
+
|
84
|
+
should "output setters with correct argument type" do
|
85
|
+
assert_match(/set windows\(value:int\)/, @out.string)
|
86
|
+
assert_match(/public function set windows\(value:int\)/, @out.string)
|
87
|
+
end
|
88
|
+
|
89
|
+
should "output methods" do
|
90
|
+
assert_match(/public function startHeater\(/, @out.string)
|
91
|
+
assert_match(/public function countTools\(\):Number/, @out.string)
|
92
|
+
end
|
93
|
+
|
94
|
+
should "output methods with the expected arguments" do
|
95
|
+
assert_match(/public function startHeater\(temperature:Number, fuel:String\):void/, @out.string)
|
96
|
+
end
|
97
|
+
|
98
|
+
should "output methods which return the expected values" do
|
99
|
+
assert_match(/return;/, @out.string)
|
100
|
+
end
|
101
|
+
|
102
|
+
should "have valid options" do
|
103
|
+
assert @concrete.valid_opts
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "outputting mock 4 as classes" do
|
108
|
+
|
109
|
+
setup do
|
110
|
+
opts = ConcreteOpts.parse ['-i', "#{fix}/IShed.as", '-t', 'mock4as']
|
111
|
+
@out = StringIO.new
|
112
|
+
@concrete = Concrete.new(opts,@out)
|
113
|
+
end
|
114
|
+
|
115
|
+
should "output a string" do
|
116
|
+
assert_not_nil(@out.string)
|
117
|
+
end
|
118
|
+
|
119
|
+
should "output a package declaration" do
|
120
|
+
assert_match(/^package/, @out.string)
|
121
|
+
end
|
122
|
+
|
123
|
+
should "output a class declaration" do
|
124
|
+
assert_match(/^class ShedMock/, @out.string)
|
125
|
+
end
|
126
|
+
|
127
|
+
should "extend a Mock" do
|
128
|
+
assert_match(/import org\.mock4as\.Mock;/, @out.string)
|
129
|
+
assert_match(/extends Mock/, @out.string)
|
130
|
+
end
|
131
|
+
|
132
|
+
should "implement the expected interface" do
|
133
|
+
assert_match(/implements IShed$/, @out.string)
|
134
|
+
end
|
135
|
+
|
136
|
+
should "output getters with the expected return type" do
|
137
|
+
assert_match(/public function get windows\(\):int/, @out.string)
|
138
|
+
assert_match(/public function get doors\(\):uint/, @out.string)
|
139
|
+
end
|
140
|
+
|
141
|
+
should "output getters with record statements" do
|
142
|
+
assert_match(/record\('windows'\);/, @out.string)
|
143
|
+
end
|
144
|
+
|
145
|
+
should "output setters with the correct return type" do
|
146
|
+
assert_match(/public function set windows\(value:int\):void/, @out.string)
|
147
|
+
end
|
148
|
+
|
149
|
+
should "output setters with correct argument type" do
|
150
|
+
assert_match(/set windows\(value:int\)/, @out.string)
|
151
|
+
assert_match(/public function set windows\(value:int\)/, @out.string)
|
152
|
+
end
|
153
|
+
|
154
|
+
should "output methods" do
|
155
|
+
assert_match(/public function startHeater\(/, @out.string)
|
156
|
+
assert_match(/public function countTools\(\):Number/, @out.string)
|
157
|
+
end
|
158
|
+
|
159
|
+
should "output methods with the expected arguments" do
|
160
|
+
assert_match(/public function startHeater\(temperature:Number, fuel:String\):void/, @out.string)
|
161
|
+
end
|
162
|
+
|
163
|
+
should "output methods with record statements" do
|
164
|
+
assert_match(/record\('openDoor'\);/, @out.string)
|
165
|
+
assert_match(/record\('countTools'\);/, @out.string)
|
166
|
+
assert_match(/record\('startHeater', temperature, fuel\);/, @out.string)
|
167
|
+
end
|
168
|
+
|
169
|
+
should "output methods which return the expected values" do
|
170
|
+
assert_match(/return expectedReturnFor\('countTools'\) as Number;/, @out.string)
|
171
|
+
end
|
172
|
+
|
173
|
+
should "have valid options" do
|
174
|
+
assert @concrete.valid_opts
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "outputting interface implementation" do
|
179
|
+
|
180
|
+
setup do
|
181
|
+
opts = ConcreteOpts.parse ['-i', "#{fix}/IShed.as", '-t', 'imp']
|
182
|
+
@out = StringIO.new
|
183
|
+
@concrete = Concrete.new(opts,@out)
|
184
|
+
end
|
185
|
+
|
186
|
+
should "output a string" do
|
187
|
+
assert_not_nil(@out.string)
|
188
|
+
end
|
189
|
+
|
190
|
+
should "not output a package declaration" do
|
191
|
+
assert_no_match(/^package/, @out.string)
|
192
|
+
end
|
193
|
+
|
194
|
+
should "not output a class declaration" do
|
195
|
+
assert_no_match(/^class Shed/, @out.string)
|
196
|
+
end
|
197
|
+
|
198
|
+
should "not implement the expected interface" do
|
199
|
+
assert_no_match(/implements IShed$/, @out.string)
|
200
|
+
end
|
201
|
+
|
202
|
+
should "output getters with the expected return type" do
|
203
|
+
assert_match(/public function get windows\(\):int/, @out.string)
|
204
|
+
assert_match(/public function get doors\(\):uint/, @out.string)
|
205
|
+
end
|
206
|
+
|
207
|
+
should "output setters with the correct return type" do
|
208
|
+
assert_match(/public function set windows\(value:int\):void/, @out.string)
|
209
|
+
end
|
210
|
+
|
211
|
+
should "output setters with correct argument type" do
|
212
|
+
assert_match(/set windows\(value:int\)/, @out.string)
|
213
|
+
assert_match(/public function set windows\(value:int\)/, @out.string)
|
214
|
+
end
|
215
|
+
|
216
|
+
should "output methods" do
|
217
|
+
assert_match(/public function startHeater\(/, @out.string)
|
218
|
+
assert_match(/public function countTools\(\):Number/, @out.string)
|
219
|
+
end
|
220
|
+
|
221
|
+
should "output methods with the expected arguments" do
|
222
|
+
assert_match(/public function startHeater\(temperature:Number, fuel:String\):void/, @out.string)
|
223
|
+
end
|
224
|
+
|
225
|
+
should "output methods which return the expected values" do
|
226
|
+
assert_match(/return;/, @out.string)
|
227
|
+
end
|
228
|
+
|
229
|
+
should "have valid options" do
|
230
|
+
assert @concrete.valid_opts
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
|
+
|
5
|
+
class TestConcreteOpt < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "A Concrete Tool Options Parser" do
|
8
|
+
|
9
|
+
should "return default hash if no arguments are specified" do
|
10
|
+
args = []
|
11
|
+
opts = ConcreteOpts.parse(args)
|
12
|
+
|
13
|
+
assert_equal false, opts[:verbose]
|
14
|
+
end
|
15
|
+
|
16
|
+
should "display a name" do
|
17
|
+
assert_match(/\w+/, ConcreteOpts.name)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "describe itself" do
|
21
|
+
assert_match(/\w+/, ConcreteOpts.description)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "define a type when -t is set" do
|
25
|
+
arg = 'olate'
|
26
|
+
opts = ConcreteOpts.parse ['-t', arg]
|
27
|
+
|
28
|
+
assert_equal arg, opts[:type]
|
29
|
+
end
|
30
|
+
|
31
|
+
should "define a type when --type is set" do
|
32
|
+
arg = '4as'
|
33
|
+
opts = ConcreteOpts.parse ['--type', arg]
|
34
|
+
|
35
|
+
assert_equal arg, opts[:type]
|
36
|
+
end
|
37
|
+
|
38
|
+
should "define a interface when -i is set" do
|
39
|
+
arg = 'org.helvector.IShed'
|
40
|
+
opts = ConcreteOpts.parse ['-i', arg]
|
41
|
+
|
42
|
+
assert_equal arg, opts[:interface]
|
43
|
+
end
|
44
|
+
|
45
|
+
should "define a interface when --interface is set" do
|
46
|
+
arg = 'org.helvector.IShed'
|
47
|
+
opts = ConcreteOpts.parse ['--interface', arg]
|
48
|
+
|
49
|
+
assert_equal arg, opts[:interface]
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
|
+
|
5
|
+
class TestInterface < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def fix
|
8
|
+
File.expand_path(File.dirname(__FILE__)+ "/../fixtures/interface")
|
9
|
+
end
|
10
|
+
|
11
|
+
context "load an interface with multiline methods and tokenise the contents" do
|
12
|
+
#TODO
|
13
|
+
setup do
|
14
|
+
file = File.new("#{fix}/ISeedPacket.as").read.strip
|
15
|
+
@parser = Interface.new(file)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "identify the interface name" do
|
19
|
+
assert_equal('ISeedPacket', @parser.name)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "identify the interface package" do
|
23
|
+
assert_equal('org.shed.bench.box', @parser.package)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "identify the accessors" do
|
27
|
+
p = @parser.get_property('material')
|
28
|
+
|
29
|
+
assert_not_nil(p)
|
30
|
+
assert(p[:gets])
|
31
|
+
assert(p[:sets])
|
32
|
+
assert_equal('String', p[:type])
|
33
|
+
assert_equal(1, @parser.properties.length)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "identify multiline methods defined in the interface" do
|
37
|
+
m = @parser.get_method('variety')
|
38
|
+
|
39
|
+
assert_not_nil(m)
|
40
|
+
assert_equal('variety', m[:name])
|
41
|
+
assert_equal(['one:Number', 'two:String', 'three:Function'], m[:arguments])
|
42
|
+
assert_equal('String', m[:return])
|
43
|
+
end
|
44
|
+
|
45
|
+
should "identify multiline methods with default arguments" do
|
46
|
+
m = @parser.get_method('age')
|
47
|
+
|
48
|
+
assert_not_nil(m)
|
49
|
+
assert_equal('age', m[:name])
|
50
|
+
assert_equal(['planted:Date', 'details:String="a,b,c"'], m[:arguments])
|
51
|
+
assert_equal('Date', m[:return])
|
52
|
+
|
53
|
+
m = nil
|
54
|
+
m = @parser.get_method('plant')
|
55
|
+
|
56
|
+
assert_not_nil(m)
|
57
|
+
assert_equal('plant', m[:name])
|
58
|
+
assert_equal(['a:String', 'b:Boolean=false', 'c:Seed=pod'], m[:arguments])
|
59
|
+
assert_equal('Boolean', m[:return])
|
60
|
+
end
|
61
|
+
|
62
|
+
should "identify methods with ...rest arguments" do
|
63
|
+
m = @parser.get_method('have')
|
64
|
+
|
65
|
+
assert_not_nil(m)
|
66
|
+
assert_equal('have', m[:name])
|
67
|
+
assert_equal(['a:String', '...rest'], m[:arguments])
|
68
|
+
assert_equal('Boolean', m[:return])
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
context "load an interface and tokenise the contents" do
|
74
|
+
setup do
|
75
|
+
file = File.new("#{fix}/IShed.as").read.strip
|
76
|
+
@parser = Interface.new(file)
|
77
|
+
end
|
78
|
+
|
79
|
+
should "identify the interface name" do
|
80
|
+
assert_equal('IShed', @parser.name)
|
81
|
+
end
|
82
|
+
|
83
|
+
should "identify the interface package" do
|
84
|
+
assert_equal('', @parser.package)
|
85
|
+
end
|
86
|
+
|
87
|
+
should "identify the accessors" do
|
88
|
+
p = @parser.get_property('windows')
|
89
|
+
|
90
|
+
assert_not_nil(p)
|
91
|
+
assert(p[:gets])
|
92
|
+
assert(p[:sets])
|
93
|
+
assert_equal('int', p[:type])
|
94
|
+
assert_equal(3, @parser.properties.length)
|
95
|
+
end
|
96
|
+
|
97
|
+
should "identify the setters" do
|
98
|
+
p = @parser.get_property('lamps')
|
99
|
+
|
100
|
+
assert_not_nil(p)
|
101
|
+
assert(!p[:gets])
|
102
|
+
assert(p[:sets])
|
103
|
+
assert_equal('Number', p[:type])
|
104
|
+
end
|
105
|
+
|
106
|
+
should "identify getters" do
|
107
|
+
p = @parser.get_property('doors')
|
108
|
+
|
109
|
+
assert_not_nil(p)
|
110
|
+
assert(p[:gets])
|
111
|
+
assert(!p[:sets])
|
112
|
+
assert_equal('uint', p[:type])
|
113
|
+
end
|
114
|
+
|
115
|
+
should "identify all methods defined in the interface" do
|
116
|
+
m = @parser.get_method('openDoor')
|
117
|
+
|
118
|
+
assert_not_nil(m)
|
119
|
+
assert_equal('openDoor', m[:name])
|
120
|
+
assert_equal([], m[:arguments])
|
121
|
+
assert_equal('void', m[:return])
|
122
|
+
|
123
|
+
m = @parser.get_method('startHeater')
|
124
|
+
|
125
|
+
assert_not_nil(m)
|
126
|
+
assert_equal('startHeater', m[:name])
|
127
|
+
assert_equal(['temperature:Number','fuel:String'], m[:arguments])
|
128
|
+
assert_equal('void', m[:return])
|
129
|
+
|
130
|
+
m = @parser.get_method('countTools')
|
131
|
+
|
132
|
+
assert_not_nil(m)
|
133
|
+
assert_equal('countTools', m[:name])
|
134
|
+
assert_equal([], m[:arguments])
|
135
|
+
assert_equal('Number', m[:return])
|
136
|
+
|
137
|
+
assert_equal(3, @parser.methods.length)
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
data/test/unit/test_manifest.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
4
|
|
5
|
-
class
|
5
|
+
class TestManifestOpt < Test::Unit::TestCase
|
6
6
|
|
7
7
|
context "A Manifest Tool Options Parser" do
|
8
8
|
|
@@ -13,7 +13,6 @@ class ManifestOptTest < Test::Unit::TestCase
|
|
13
13
|
assert_equal 'manifest.xml', opts[:output]
|
14
14
|
assert_equal '.', opts[:src]
|
15
15
|
assert_equal false, opts[:verbose]
|
16
|
-
|
17
16
|
end
|
18
17
|
|
19
18
|
should "display a name" do
|
data/test/unit/test_search.rb
CHANGED
data/test/unit/test_stripper.rb
CHANGED
@@ -11,6 +11,7 @@ class TestStyleVacuum < Test::Unit::TestCase
|
|
11
11
|
context "A style vacuum tool" do
|
12
12
|
|
13
13
|
context "with correct arguments" do
|
14
|
+
|
14
15
|
setup do
|
15
16
|
opt = { :src => "#{fix}/src",
|
16
17
|
:css_dir => "#{fix}/css",
|
@@ -32,25 +33,29 @@ class TestStyleVacuum < Test::Unit::TestCase
|
|
32
33
|
assert_not_equal("The required options were not specified\n", @out.string)
|
33
34
|
assert @tool.valid_opts
|
34
35
|
end
|
36
|
+
|
35
37
|
end
|
36
38
|
|
37
39
|
context "with incorrect arguments" do
|
38
|
-
setup do
|
39
|
-
opt = { :src => "#{fix}/src",
|
40
|
-
:css_dir => "#{fix}/src",
|
41
|
-
:output => '/tmp/as-style-vacuum.txt' }
|
42
|
-
|
43
|
-
@out = StringIO.new
|
44
|
-
@tool = StyleVacuum.new(opt,@out)
|
45
|
-
end
|
46
40
|
|
47
41
|
should "fail with a warning message" do
|
48
|
-
|
49
|
-
|
42
|
+
opt = { :src => "#{fix}/src", :css_dir => "#{fix}/src",
|
43
|
+
:output => '/tmp/as-style-vacuum.txt' }
|
44
|
+
out = StringIO.new
|
45
|
+
|
46
|
+
begin
|
47
|
+
StyleVacuum.new(opt,out)
|
48
|
+
flunk
|
49
|
+
rescue SystemExit => e
|
50
|
+
assert_equal 0, e.status
|
51
|
+
assert_match(/#{Tool::INVALID_OPTS} The specified/, out.string)
|
52
|
+
end
|
50
53
|
end
|
54
|
+
|
51
55
|
end
|
52
56
|
|
53
57
|
context "when given a css directory containing more than one css" do
|
58
|
+
|
54
59
|
setup do
|
55
60
|
opt = { :src => "#{fix}/src",
|
56
61
|
:css_dir => "#{fix}/css-multiple",
|
@@ -67,9 +72,11 @@ class TestStyleVacuum < Test::Unit::TestCase
|
|
67
72
|
should "find unused styles" do
|
68
73
|
assert @tool.unused.length == 3
|
69
74
|
end
|
75
|
+
|
70
76
|
end
|
71
77
|
|
72
78
|
context "when searching css files for style definitions" do
|
79
|
+
|
73
80
|
setup do
|
74
81
|
opt = { :src => "#{fix}/src",
|
75
82
|
:css_dir => "#{fix}/css-with-comments",
|
@@ -87,9 +94,11 @@ class TestStyleVacuum < Test::Unit::TestCase
|
|
87
94
|
should "ignore declarations that are commented out" do
|
88
95
|
assert_equal(false, @tool.declared.include?('aCommentedOutStyle'))
|
89
96
|
end
|
97
|
+
|
90
98
|
end
|
91
99
|
|
92
100
|
context "when searching mxml documents for style useage" do
|
101
|
+
|
93
102
|
setup do
|
94
103
|
opt = { :src => "#{fix}/src",
|
95
104
|
:css_dir => "#{fix}/css",
|
@@ -102,6 +111,7 @@ class TestStyleVacuum < Test::Unit::TestCase
|
|
102
111
|
should "find all values of syleName attributes" do
|
103
112
|
assert @tool.used.length == 2
|
104
113
|
end
|
114
|
+
|
105
115
|
end
|
106
116
|
|
107
117
|
end
|
data/test/unit/test_tool.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
4
|
|
5
|
-
class
|
5
|
+
class TestTool < Test::Unit::TestCase
|
6
6
|
|
7
7
|
context "A default tool-shed" do
|
8
8
|
|
@@ -52,6 +52,7 @@ class ToolTest < Test::Unit::TestCase
|
|
52
52
|
end
|
53
53
|
|
54
54
|
context "A verbose tool-shed" do
|
55
|
+
|
55
56
|
setup do
|
56
57
|
@out = StringIO.new
|
57
58
|
@tool = Tool.new({:verbose => true, :output => '/tmp/tool-shed.txt'}, @out)
|
data/test/unit/test_tool_opts.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
4
|
|
5
|
-
class
|
5
|
+
class TestToolOpts < Test::Unit::TestCase
|
6
6
|
|
7
7
|
context "A Tool Options Parser" do
|
8
8
|
|
@@ -17,13 +17,26 @@ class ToolOptsTest < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
should "
|
20
|
+
should "recognise default arguments if no switches are present" do
|
21
|
+
args = ['path/to/a/text.file']
|
22
|
+
opts = ToolOpts.parse(args)
|
21
23
|
|
22
|
-
|
24
|
+
assert_equal 'path/to/a/text.file', opts[:default]
|
25
|
+
end
|
26
|
+
|
27
|
+
should "recognise default arguments when switches are present" do
|
28
|
+
args = ['-v','path/to/a/text.file', '-s', 'path/to/source']
|
23
29
|
opts = ToolOpts.parse(args)
|
24
30
|
|
31
|
+
assert_equal 'path/to/a/text.file', opts[:default]
|
25
32
|
assert opts[:verbose]
|
33
|
+
end
|
26
34
|
|
35
|
+
should "define verbose mode when -v is set" do
|
36
|
+
args = ['-v']
|
37
|
+
opts = ToolOpts.parse(args)
|
38
|
+
|
39
|
+
assert opts[:verbose]
|
27
40
|
end
|
28
41
|
|
29
42
|
should "set source when -s or --source is specified" do
|