tap 0.7.9 → 0.8.0
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/History +28 -0
- data/MIT-LICENSE +1 -1
- data/README +71 -43
- data/Rakefile +81 -64
- data/Tutorial +235 -0
- data/bin/tap +80 -44
- data/lib/tap.rb +41 -12
- data/lib/tap/app.rb +243 -246
- data/lib/tap/file_task.rb +357 -118
- data/lib/tap/generator.rb +88 -29
- data/lib/tap/generator/generators/config/config_generator.rb +4 -2
- data/lib/tap/generator/generators/config/templates/config.erb +1 -2
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +3 -18
- data/lib/tap/generator/generators/file_task/templates/task.erb +22 -15
- data/lib/tap/generator/generators/file_task/templates/test.erb +13 -2
- data/{test/test/inference_methods/test_assert_files_exist/input/input_1.txt → lib/tap/generator/generators/generator/USAGE} +0 -0
- data/lib/tap/generator/generators/generator/generator_generator.rb +21 -0
- data/lib/tap/generator/generators/generator/templates/generator.erb +23 -0
- data/lib/tap/generator/generators/generator/templates/usage.erb +1 -0
- data/{test/test/inference_methods/test_assert_files_exist/input/input_2.txt → lib/tap/generator/generators/package/USAGE} +0 -0
- data/lib/tap/generator/generators/package/package_generator.rb +38 -0
- data/lib/tap/generator/generators/package/templates/package.erb +186 -0
- data/lib/tap/generator/generators/root/root_generator.rb +14 -9
- data/lib/tap/generator/generators/root/templates/Rakefile +20 -14
- data/{test/test/inference_methods/test_infer_glob/expected/file.yml → lib/tap/generator/generators/root/templates/ReadMe.txt} +0 -0
- data/lib/tap/generator/generators/root/templates/tap.yml +82 -0
- data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +0 -1
- data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +2 -1
- data/{test/test/inference_methods/test_infer_glob/expected/file_1.txt → lib/tap/generator/generators/script/USAGE} +0 -0
- data/lib/tap/generator/generators/script/script_generator.rb +17 -0
- data/lib/tap/generator/generators/script/templates/script.erb +42 -0
- data/lib/tap/generator/generators/task/task_generator.rb +1 -1
- data/lib/tap/generator/generators/task/templates/task.erb +24 -16
- data/lib/tap/generator/generators/task/templates/test.erb +13 -17
- data/lib/tap/generator/generators/workflow/templates/task.erb +10 -10
- data/lib/tap/generator/generators/workflow/templates/test.erb +1 -1
- data/lib/tap/generator/generators/workflow/workflow_generator.rb +3 -18
- data/lib/tap/root.rb +108 -146
- data/lib/tap/script.rb +362 -0
- data/lib/tap/script/console.rb +28 -0
- data/lib/tap/script/destroy.rb +13 -1
- data/lib/tap/script/generate.rb +13 -1
- data/lib/tap/script/run.rb +100 -57
- data/lib/tap/support/batch_queue.rb +0 -3
- data/lib/tap/support/logger.rb +6 -3
- data/lib/tap/support/rake.rb +54 -0
- data/lib/tap/support/task_configuration.rb +169 -0
- data/lib/tap/support/tdoc.rb +198 -0
- data/lib/tap/support/tdoc/config_attr.rb +338 -0
- data/lib/tap/support/tdoc/tdoc_html_generator.rb +38 -0
- data/lib/tap/support/tdoc/tdoc_html_template.rb +42 -0
- data/lib/tap/support/versions.rb +33 -1
- data/lib/tap/task.rb +339 -227
- data/lib/tap/test.rb +86 -128
- data/lib/tap/test/env_vars.rb +16 -5
- data/lib/tap/test/file_methods.rb +373 -0
- data/lib/tap/test/subset_methods.rb +299 -180
- data/lib/tap/version.rb +2 -1
- data/lib/tap/workflow.rb +2 -0
- data/test/app/lib/app_test_task.rb +1 -0
- data/test/app_test.rb +327 -83
- data/test/check/binding_eval.rb +23 -0
- data/test/check/define_method_check.rb +22 -0
- data/test/check/dependencies_check.rb +175 -0
- data/test/check/inheritance_check.rb +22 -0
- data/test/file_task_test.rb +524 -291
- data/test/{test/inference_methods/test_infer_glob/expected/file_2.txt → root/glob/one.txt} +0 -0
- data/test/root/glob/two.txt +0 -0
- data/test/root_test.rb +330 -262
- data/test/script_test.rb +194 -0
- data/test/support/audit_test.rb +5 -2
- data/test/support/combinator_test.rb +10 -10
- data/test/support/rake_test.rb +35 -0
- data/test/support/task_configuration_test.rb +272 -0
- data/test/support/tdoc_test.rb +363 -0
- data/test/support/templater_test.rb +2 -2
- data/test/support/versions_test.rb +32 -0
- data/test/tap_test_helper.rb +39 -0
- data/test/task_base_test.rb +115 -0
- data/test/task_class_test.rb +56 -4
- data/test/task_execute_test.rb +29 -0
- data/test/task_test.rb +89 -70
- data/test/test/env_vars_test.rb +48 -0
- data/test/test/{inference_methods → file_methods}/test_assert_expected/expected/file.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_assert_expected/expected/folder/file.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_assert_expected/input/file.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_assert_expected/input/folder/file.txt +0 -0
- data/test/test/file_methods/test_assert_files_exist/input/input_1.txt +0 -0
- data/test/test/file_methods/test_assert_files_exist/input/input_2.txt +0 -0
- data/test/test/file_methods/test_assert_output_files_equal/expected/one.txt +1 -0
- data/test/test/file_methods/test_assert_output_files_equal/expected/two.txt +1 -0
- data/test/test/file_methods/test_assert_output_files_equal/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_output_files_equal/input/two.txt +1 -0
- data/test/test/{inference_methods → file_methods}/test_file_compare/expected/output_1.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_file_compare/expected/output_2.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_file_compare/input/input_1.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_file_compare/input/input_2.txt +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file.yml +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file_1.txt +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file_2.txt +0 -0
- data/test/test/file_methods/test_method_glob/expected/file.yml +0 -0
- data/test/test/file_methods/test_method_glob/expected/file_1.txt +0 -0
- data/test/test/file_methods/test_method_glob/expected/file_2.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_yml_compare/expected/output_1.yml +0 -0
- data/test/test/{inference_methods → file_methods}/test_yml_compare/expected/output_2.yml +0 -0
- data/test/test/{inference_methods → file_methods}/test_yml_compare/input/input_1.yml +0 -0
- data/test/test/{inference_methods → file_methods}/test_yml_compare/input/input_2.yml +0 -0
- data/test/test/file_methods_test.rb +204 -0
- data/test/test/subset_methods_test.rb +93 -33
- data/test/test/test_assert_expected_result_files/expected/task/name/a.txt +1 -0
- data/test/test/test_assert_expected_result_files/expected/task/name/b.txt +1 -0
- data/test/test/test_assert_expected_result_files/input/a.txt +1 -0
- data/test/test/test_assert_expected_result_files/input/b.txt +1 -0
- data/test/test/test_file_task_test/expected/one.txt +1 -0
- data/test/test/test_file_task_test/expected/two.txt +1 -0
- data/test/test/test_file_task_test/input/one.txt +1 -0
- data/test/test/test_file_task_test/input/two.txt +1 -0
- data/test/test_test.rb +143 -3
- data/test/workflow_test.rb +2 -0
- data/vendor/rails_generator.rb +56 -0
- data/vendor/rails_generator/base.rb +263 -0
- data/vendor/rails_generator/commands.rb +581 -0
- data/vendor/rails_generator/generated_attribute.rb +42 -0
- data/vendor/rails_generator/lookup.rb +209 -0
- data/vendor/rails_generator/manifest.rb +53 -0
- data/vendor/rails_generator/options.rb +143 -0
- data/vendor/rails_generator/scripts.rb +83 -0
- data/vendor/rails_generator/scripts/destroy.rb +7 -0
- data/vendor/rails_generator/scripts/generate.rb +7 -0
- data/vendor/rails_generator/scripts/update.rb +12 -0
- data/vendor/rails_generator/simple_logger.rb +46 -0
- data/vendor/rails_generator/spec.rb +44 -0
- metadata +180 -196
- data/lib/tap/generator/generators/root/templates/app.yml +0 -19
- data/lib/tap/generator/generators/root/templates/config/process_tap_request.yml +0 -4
- data/lib/tap/generator/generators/root/templates/lib/process_tap_request.rb +0 -26
- data/lib/tap/generator/generators/root/templates/public/images/nav.jpg +0 -0
- data/lib/tap/generator/generators/root/templates/public/stylesheets/color.css +0 -57
- data/lib/tap/generator/generators/root/templates/public/stylesheets/layout.css +0 -108
- data/lib/tap/generator/generators/root/templates/public/stylesheets/normalize.css +0 -40
- data/lib/tap/generator/generators/root/templates/public/stylesheets/typography.css +0 -21
- data/lib/tap/generator/generators/root/templates/server/config/environment.rb +0 -60
- data/lib/tap/generator/generators/root/templates/server/lib/tasks/clear_database_prerequisites.rake +0 -5
- data/lib/tap/generator/generators/root/templates/server/test/test_helper.rb +0 -53
- data/lib/tap/script/server.rb +0 -12
- data/lib/tap/support/rap.rb +0 -38
- data/lib/tap/test/inference_methods.rb +0 -298
- data/test/task/config/task_with_config.yml +0 -1
- data/test/test/inference_methods_test.rb +0 -311
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
+
|
|
3
|
+
# = Section One
|
|
4
|
+
# section one
|
|
5
|
+
#
|
|
6
|
+
# == Section Two
|
|
7
|
+
# section two
|
|
8
|
+
# line two
|
|
9
|
+
class TaskDocumentation < Tap::Task
|
|
10
|
+
config :c_nodoc, 'value' # :nodoc:
|
|
11
|
+
config(:c_accessor, 'value') # c_accessor
|
|
12
|
+
|
|
13
|
+
config_reader
|
|
14
|
+
|
|
15
|
+
config :c_reader, 'value' # c_reader
|
|
16
|
+
|
|
17
|
+
declare_config
|
|
18
|
+
|
|
19
|
+
config :c, 'value' # c
|
|
20
|
+
|
|
21
|
+
# c_conventional
|
|
22
|
+
config :c_conventional, 'value'
|
|
23
|
+
config :c_without_doc, 'value'
|
|
24
|
+
|
|
25
|
+
# c_multiline1
|
|
26
|
+
config(:c_multiline, 'value' ) # c_multiline2
|
|
27
|
+
|
|
28
|
+
config :c_with_attr, 'value', {:key => 'value'} # c_with_attr
|
|
29
|
+
|
|
30
|
+
config :alt_c, 'value' # alt_c
|
|
31
|
+
config :alt_c_with_attr, 'value', :key => 'value' # alt_c_with_attr
|
|
32
|
+
config :alt_c_without_value # alt_c_without_value
|
|
33
|
+
|
|
34
|
+
# declare_config
|
|
35
|
+
declare_config :declare_config
|
|
36
|
+
# confg_accessor
|
|
37
|
+
config_accessor :config_accessor
|
|
38
|
+
# config_reader
|
|
39
|
+
config_reader :config_reader
|
|
40
|
+
# config_writer
|
|
41
|
+
config_writer :config_writer
|
|
42
|
+
|
|
43
|
+
# multi_config_accessor
|
|
44
|
+
config_accessor :multi_config_accessor1, :multi_config_accessor2
|
|
45
|
+
|
|
46
|
+
# attr_accessor
|
|
47
|
+
attr_accessor :attr_accessor # ignored
|
|
48
|
+
attr_accessor :attr_accessor_without_doc
|
|
49
|
+
|
|
50
|
+
# multi_attr_accessor
|
|
51
|
+
attr_accessor :multi_attr_accessor1, :multi_attr_accessor2
|
|
52
|
+
|
|
53
|
+
config_accessor = [:is, :not, :documented]
|
|
54
|
+
attr_accessor = [:is, :not, :documented]
|
|
55
|
+
|
|
56
|
+
def process(input)
|
|
57
|
+
config(:is, :not, :documented)
|
|
58
|
+
config :is, :not, :documented
|
|
59
|
+
declare_config :is, :not, :documented
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def config(*args)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def declare_config(*args)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# nested doc
|
|
70
|
+
module Nested
|
|
71
|
+
# class doc
|
|
72
|
+
class Klass
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# mod doc
|
|
76
|
+
module Mod
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class NotATask
|
|
81
|
+
class << self
|
|
82
|
+
def config_accessor(*args)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
config = "is not documented"
|
|
87
|
+
declare_config = [:is, :not, :documented]
|
|
88
|
+
|
|
89
|
+
config_accessor :is, :documented
|
|
90
|
+
|
|
91
|
+
config_accessor = [:is, :not, :documented]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class TDocTest < Test::Unit::TestCase
|
|
95
|
+
include Tap::Test::SubsetMethods
|
|
96
|
+
|
|
97
|
+
condition(:irb_variant) { env('tdoc_with_irb') }
|
|
98
|
+
if satisfied?(:irb_variant)
|
|
99
|
+
require 'irb'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
require 'tap/support/tdoc'
|
|
103
|
+
include Tap::Support
|
|
104
|
+
|
|
105
|
+
TDoc.document(__FILE__)
|
|
106
|
+
|
|
107
|
+
#
|
|
108
|
+
# RDoc RubyLex and RubyToken redefinition test
|
|
109
|
+
#
|
|
110
|
+
|
|
111
|
+
def test_rubylex_and_rubytoken_redefinition
|
|
112
|
+
filepath = __FILE__
|
|
113
|
+
tl = RDoc::TopLevel.new(filepath)
|
|
114
|
+
stats = RDoc::Stats.new
|
|
115
|
+
options = Options.instance
|
|
116
|
+
parser = RDoc::RubyParser.new(tl, filepath, File.read(filepath), options, stats)
|
|
117
|
+
|
|
118
|
+
assert Tap::Support::TDoc::ConfigParser.included_modules.include?(RDoc::RubyToken)
|
|
119
|
+
assert RDoc::RubyParser.included_modules.include?(RDoc::RubyToken)
|
|
120
|
+
assert_equal RDoc::RubyLex, parser.instance_variable_get("@scanner").class
|
|
121
|
+
|
|
122
|
+
if satisfied?(:irb_variant)
|
|
123
|
+
assert_not_equal RubyToken, RDoc::RubyToken
|
|
124
|
+
assert_not_equal RubyLex, RDoc::RubyLex
|
|
125
|
+
assert RubyLex.included_modules.include?(RubyToken)
|
|
126
|
+
assert !RubyLex.included_modules.include?(RDoc::RubyLex)
|
|
127
|
+
else
|
|
128
|
+
flunk unless !Object.const_defined?(:RubyToken) || RubyToken == RDoc::RubyToken
|
|
129
|
+
flunk unless !Object.const_defined?(:RubyLex) || RubyLex == RDoc::RubyLex
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
#
|
|
134
|
+
# [] tests
|
|
135
|
+
#
|
|
136
|
+
|
|
137
|
+
def test_get_class_documentation
|
|
138
|
+
c = TDoc[TaskDocumentation]
|
|
139
|
+
assert_equal RDoc::NormalClass, c.class
|
|
140
|
+
assert_equal "# = Section One\n# section one\n#\n# == Section Two\n# section two\n# line two\n", c.comment
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
c = TDoc[Nested]
|
|
144
|
+
assert_equal RDoc::NormalModule, c.class
|
|
145
|
+
assert_equal "# nested doc\n", c.comment
|
|
146
|
+
|
|
147
|
+
c = TDoc[Nested::Klass]
|
|
148
|
+
assert_equal RDoc::NormalClass, c.class
|
|
149
|
+
assert_equal "# class doc\n", c.comment
|
|
150
|
+
|
|
151
|
+
c = TDoc[Nested::Mod]
|
|
152
|
+
assert_equal RDoc::NormalModule, c.class
|
|
153
|
+
assert_equal "# mod doc\n", c.comment
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_get_documentation_works_for_strings_and_constants
|
|
157
|
+
assert_equal RDoc::NormalClass, TDoc[Nested::Klass].class
|
|
158
|
+
assert_equal TDoc["Nested::Klass"].object_id, TDoc[Nested::Klass].object_id
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def test_configs_are_documented
|
|
162
|
+
c = TDoc[TaskDocumentation]
|
|
163
|
+
|
|
164
|
+
attributes = c.attributes.collect do |attribute|
|
|
165
|
+
case attribute
|
|
166
|
+
when TDoc::ConfigAttr
|
|
167
|
+
{:comment => attribute.original_comment,
|
|
168
|
+
:name => attribute.name,
|
|
169
|
+
:rw => attribute.rw,
|
|
170
|
+
:text => attribute.text}
|
|
171
|
+
else
|
|
172
|
+
{:comment => attribute.comment,
|
|
173
|
+
:name => attribute.name,
|
|
174
|
+
:rw => attribute.rw,
|
|
175
|
+
:text => attribute.text}
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
expected_attributes.each_with_index do |expected, i|
|
|
180
|
+
assert_equal expected, attributes[i], "unequal attribute (index=#{i})"
|
|
181
|
+
end
|
|
182
|
+
assert_equal expected_attributes.length, attributes.length
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
#
|
|
186
|
+
# accessor extensions
|
|
187
|
+
#
|
|
188
|
+
|
|
189
|
+
def test_comment_sections
|
|
190
|
+
c = TDoc[TaskDocumentation]
|
|
191
|
+
|
|
192
|
+
assert c.respond_to?(:comment_sections)
|
|
193
|
+
assert_equal({
|
|
194
|
+
"Section One" => "# section one\n#\n",
|
|
195
|
+
"Section Two" => "# section two\n# line two\n"},
|
|
196
|
+
c.comment_sections)
|
|
197
|
+
|
|
198
|
+
assert_equal({
|
|
199
|
+
"Section Two" => "# section two\n# line two\n"},
|
|
200
|
+
c.comment_sections(/two/i))
|
|
201
|
+
|
|
202
|
+
assert_equal({
|
|
203
|
+
"Section Two" => "section two\nline two"},
|
|
204
|
+
c.comment_sections(/two/i, true))
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# def test_collect_configurations
|
|
208
|
+
# c = TDoc.document(TaskDocumentation, __FILE__)
|
|
209
|
+
# assert_equal expected_attributes[0..-5], TDoc.collect_configurations(c)
|
|
210
|
+
# end
|
|
211
|
+
#
|
|
212
|
+
# def test_collect_attributes
|
|
213
|
+
# c = TDoc.document(TaskDocumentation, __FILE__)
|
|
214
|
+
# assert_equal expected_attributes[-4..-1], TDoc.collect_attributes(c)
|
|
215
|
+
# end
|
|
216
|
+
|
|
217
|
+
def expected_attributes
|
|
218
|
+
@expected_attributes ||= [{
|
|
219
|
+
:comment=>nil,
|
|
220
|
+
:name=>"c_accessor",
|
|
221
|
+
:rw=>"RW",
|
|
222
|
+
:text=>"# c_accessor"},
|
|
223
|
+
{
|
|
224
|
+
:comment=>nil,
|
|
225
|
+
:name=>"c_reader",
|
|
226
|
+
:rw=>"R",
|
|
227
|
+
:text=>"# c_reader"},
|
|
228
|
+
{
|
|
229
|
+
:comment=>nil,
|
|
230
|
+
:name=>"c",
|
|
231
|
+
:rw=>nil,
|
|
232
|
+
:text=>"# c"},
|
|
233
|
+
{
|
|
234
|
+
:comment=>"# c_conventional\n",
|
|
235
|
+
:name=>"c_conventional",
|
|
236
|
+
:rw=>nil,
|
|
237
|
+
:text=>""},
|
|
238
|
+
{
|
|
239
|
+
:comment=>nil,
|
|
240
|
+
:name=>"c_without_doc",
|
|
241
|
+
:rw=>nil,
|
|
242
|
+
:text=>""},
|
|
243
|
+
{
|
|
244
|
+
:comment=>"# c_multiline1\n",
|
|
245
|
+
:name=>"c_multiline",
|
|
246
|
+
:rw=>nil,
|
|
247
|
+
:text=>"# c_multiline2"},
|
|
248
|
+
{
|
|
249
|
+
:comment=>nil,
|
|
250
|
+
:name=>"c_with_attr",
|
|
251
|
+
:rw=>nil,
|
|
252
|
+
:text=>"# c_with_attr"},
|
|
253
|
+
{
|
|
254
|
+
:comment=>nil,
|
|
255
|
+
:name=>"alt_c",
|
|
256
|
+
:rw=>nil,
|
|
257
|
+
:text=>"# alt_c"},
|
|
258
|
+
{
|
|
259
|
+
:comment=>nil,
|
|
260
|
+
:name=>"alt_c_with_attr",
|
|
261
|
+
:rw=>nil,
|
|
262
|
+
:text=>"# alt_c_with_attr"},
|
|
263
|
+
{
|
|
264
|
+
:comment=>nil,
|
|
265
|
+
:name=>"alt_c_without_value",
|
|
266
|
+
:rw=>nil,
|
|
267
|
+
:text=>"# alt_c_without_value"},
|
|
268
|
+
{
|
|
269
|
+
:comment=>"# declare_config\n",
|
|
270
|
+
:name=>"declare_config",
|
|
271
|
+
:rw=>nil,
|
|
272
|
+
:text=>""},
|
|
273
|
+
{
|
|
274
|
+
:comment=>"# confg_accessor\n",
|
|
275
|
+
:name=>"config_accessor",
|
|
276
|
+
:rw=>"RW",
|
|
277
|
+
:text=>""},
|
|
278
|
+
{
|
|
279
|
+
:comment=>"# config_reader\n",
|
|
280
|
+
:name=>"config_reader",
|
|
281
|
+
:rw=>"R",
|
|
282
|
+
:text=>""},
|
|
283
|
+
{
|
|
284
|
+
:comment=>"# config_writer\n",
|
|
285
|
+
:name=>"config_writer",
|
|
286
|
+
:rw=>"W",
|
|
287
|
+
:text=>""},
|
|
288
|
+
{
|
|
289
|
+
:comment=>"# multi_config_accessor\n",
|
|
290
|
+
:name=>"multi_config_accessor1",
|
|
291
|
+
:rw=>"RW",
|
|
292
|
+
:text=>""},
|
|
293
|
+
{
|
|
294
|
+
:comment=>"# multi_config_accessor\n",
|
|
295
|
+
:name=>"multi_config_accessor2",
|
|
296
|
+
:rw=>"RW",
|
|
297
|
+
:text=>""},
|
|
298
|
+
{
|
|
299
|
+
:comment=>"# attr_accessor\n",
|
|
300
|
+
:name=>"attr_accessor",
|
|
301
|
+
:rw=>"RW",
|
|
302
|
+
:text=>"# ignored"},
|
|
303
|
+
{
|
|
304
|
+
:comment=>nil,
|
|
305
|
+
:name=>"attr_accessor_without_doc",
|
|
306
|
+
:rw=>"RW",
|
|
307
|
+
:text=>""},
|
|
308
|
+
{
|
|
309
|
+
:comment=>"# multi_attr_accessor\n",
|
|
310
|
+
:name=>"multi_attr_accessor1",
|
|
311
|
+
:rw=>"RW",
|
|
312
|
+
:text=>""},
|
|
313
|
+
{
|
|
314
|
+
:comment=>"# multi_attr_accessor\n",
|
|
315
|
+
:name=>"multi_attr_accessor2",
|
|
316
|
+
:rw=>"RW",
|
|
317
|
+
:text=>""}]
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
#
|
|
321
|
+
# NotATask documentation
|
|
322
|
+
#
|
|
323
|
+
|
|
324
|
+
# def test_not_a_task_document
|
|
325
|
+
# c = TDoc.document(NotATask, __FILE__)
|
|
326
|
+
#
|
|
327
|
+
# assert_equal RDoc::NormalClass, c.class
|
|
328
|
+
# assert_equal "", c.comment
|
|
329
|
+
#
|
|
330
|
+
# attributes = c.attributes.collect do |attribute|
|
|
331
|
+
# case attribute
|
|
332
|
+
# when TDoc::ConfigAttr
|
|
333
|
+
# {:comment => attribute.original_comment,
|
|
334
|
+
# :name => attribute.name,
|
|
335
|
+
# :rw => attribute.rw,
|
|
336
|
+
# :text => attribute.text}
|
|
337
|
+
# else
|
|
338
|
+
# {:comment => attribute.comment,
|
|
339
|
+
# :name => attribute.name,
|
|
340
|
+
# :rw => attribute.rw,
|
|
341
|
+
# :text => attribute.text}
|
|
342
|
+
# end
|
|
343
|
+
# end
|
|
344
|
+
#
|
|
345
|
+
# not_a_task_expected_attributes.each_with_index do |expected, i|
|
|
346
|
+
# assert_equal expected, attributes[i], "unequal attribute (index=#{i})"
|
|
347
|
+
# end
|
|
348
|
+
# assert_equal not_a_task_expected_attributes.length, attributes.length
|
|
349
|
+
# end
|
|
350
|
+
|
|
351
|
+
def not_a_task_expected_attributes
|
|
352
|
+
@not_a_task_expected_attributes ||= [{
|
|
353
|
+
:comment=>nil,
|
|
354
|
+
:name=>"is",
|
|
355
|
+
:rw=>"RW",
|
|
356
|
+
:text=>""},
|
|
357
|
+
{
|
|
358
|
+
:comment=>nil,
|
|
359
|
+
:name=>"documented",
|
|
360
|
+
:rw=>"RW",
|
|
361
|
+
:text=>""}]
|
|
362
|
+
end
|
|
363
|
+
end
|
|
@@ -150,10 +150,10 @@ class TemplaterTest < Test::Unit::TestCase
|
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
def test_run_methods_raises_no_method_error_when_method_does_not_exist
|
|
153
|
-
|
|
153
|
+
[
|
|
154
154
|
'non_existant!',
|
|
155
155
|
'non existant!'
|
|
156
|
-
|
|
156
|
+
].each do |key|
|
|
157
157
|
t = Templater.new(key => 'entry')
|
|
158
158
|
assert !t.templates.first.respond_to?(key)
|
|
159
159
|
assert_raise(NoMethodError) { t.run_methods }
|
|
@@ -3,6 +3,7 @@ require 'tap/support/versions'
|
|
|
3
3
|
|
|
4
4
|
class VersionTest < Test::Unit::TestCase
|
|
5
5
|
include Tap::Support::Versions
|
|
6
|
+
include Tap::Test::SubsetMethods
|
|
6
7
|
|
|
7
8
|
def test_documentation
|
|
8
9
|
assert_equal "path/to/file-1.0.txt", version("path/to/file.txt", 1.0)
|
|
@@ -68,4 +69,35 @@ class VersionTest < Test::Unit::TestCase
|
|
|
68
69
|
assert_equal "path/to/file-1.0", increment("path/to/file-1.0", nil)
|
|
69
70
|
assert_equal "path/to/file", increment("path/to/file", nil)
|
|
70
71
|
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# compare versions test
|
|
75
|
+
#
|
|
76
|
+
|
|
77
|
+
def test_compare_versions_documentation
|
|
78
|
+
assert_equal 1, compare_versions("1.0.0", "0.9.9")
|
|
79
|
+
assert_equal 0, compare_versions(1.1, 1.1)
|
|
80
|
+
assert_equal(-1, compare_versions([0,9], [0,9,1]) )
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_compare_versions
|
|
84
|
+
[
|
|
85
|
+
["1", "0"],
|
|
86
|
+
["1.1", "1.0"],
|
|
87
|
+
["1.0", "0.9"],
|
|
88
|
+
["1.0.0.0", "0.9"],
|
|
89
|
+
["1.0", "0.9.0.0"]
|
|
90
|
+
].each do |a,b|
|
|
91
|
+
assert_equal 1, compare_versions(a,b)
|
|
92
|
+
assert_equal 0, compare_versions(a,a)
|
|
93
|
+
assert_equal 0, compare_versions(b,b)
|
|
94
|
+
assert_equal(-1, compare_versions(b,a))
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_compare_versions_handles_numeric_and_array_input
|
|
99
|
+
assert_equal 1, compare_versions(1, 0.9)
|
|
100
|
+
assert_equal 1, compare_versions([1,0], [0,9])
|
|
101
|
+
assert_equal 1, compare_versions(["1","0"], ["0","9"])
|
|
102
|
+
end
|
|
71
103
|
end
|
data/test/tap_test_helper.rb
CHANGED
|
@@ -2,3 +2,42 @@ require 'rubygems'
|
|
|
2
2
|
|
|
3
3
|
require File.dirname(__FILE__) + '/../lib/tap'
|
|
4
4
|
require 'tap/test'
|
|
5
|
+
|
|
6
|
+
unless defined?(TapTestMethods)
|
|
7
|
+
|
|
8
|
+
# Some convenience methods used in testing tasks, workflows, app, etc.
|
|
9
|
+
module TapTestMethods # :nodoc:
|
|
10
|
+
attr_accessor :runlist
|
|
11
|
+
|
|
12
|
+
# Setup clears the test using clear_tasks and assures that Tap::App.instance
|
|
13
|
+
# is the test-specific application.
|
|
14
|
+
def setup
|
|
15
|
+
super
|
|
16
|
+
clear_runlist
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Clears all declared tasks, sets the application trace option to false, makes directories (if flagged
|
|
20
|
+
# and as needed), and clears the runlist.
|
|
21
|
+
def clear_runlist
|
|
22
|
+
# clear the attributes
|
|
23
|
+
@runlist = []
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# A tracing procedure. echo adds input to runlist then returns input.
|
|
27
|
+
def echo
|
|
28
|
+
lambda do |task, input|
|
|
29
|
+
@runlist << input
|
|
30
|
+
input
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# A tracing procedure for numeric inputs. add_one adds the input to
|
|
35
|
+
# runlist then returns input + 1.
|
|
36
|
+
def add_one
|
|
37
|
+
lambda do |task, input|
|
|
38
|
+
@runlist << input
|
|
39
|
+
input += 1
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|