tap 0.9.1 → 0.10.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 +37 -30
- data/MIT-LICENSE +1 -1
- data/README +92 -44
- data/bin/tap +62 -75
- data/cmd/console.rb +42 -0
- data/cmd/destroy.rb +16 -0
- data/cmd/generate.rb +16 -0
- data/cmd/run.rb +126 -0
- data/doc/Class Reference +362 -0
- data/doc/Command Reference +153 -0
- data/doc/Tutorial +237 -0
- data/lib/tap.rb +6 -45
- data/lib/tap/app.rb +126 -500
- data/lib/tap/constants.rb +2 -29
- data/lib/tap/env.rb +555 -250
- data/lib/tap/file_task.rb +60 -103
- data/lib/tap/generator/base.rb +109 -0
- data/lib/tap/generator/destroy.rb +37 -0
- data/lib/tap/generator/generate.rb +61 -0
- data/lib/tap/generator/generators/command/command_generator.rb +16 -12
- data/lib/tap/generator/generators/command/templates/command.erb +13 -19
- data/lib/tap/generator/generators/config/config_generator.rb +18 -27
- data/lib/tap/generator/generators/config/templates/doc.erb +12 -0
- data/lib/tap/generator/generators/config/templates/nodoc.erb +8 -0
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +16 -11
- data/lib/tap/generator/generators/file_task/templates/file.txt +11 -2
- data/lib/tap/generator/generators/file_task/templates/result.yml +6 -0
- data/lib/tap/generator/generators/file_task/templates/task.erb +24 -31
- data/lib/tap/generator/generators/file_task/templates/test.erb +18 -22
- data/lib/tap/generator/generators/root/root_generator.rb +45 -31
- data/lib/tap/generator/generators/root/templates/Rakefile +64 -41
- data/lib/tap/generator/generators/root/templates/gemspec +27 -0
- data/lib/tap/generator/generators/root/templates/tapfile +8 -0
- data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +0 -0
- data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +1 -1
- data/lib/tap/generator/generators/root/templates/test/tapfile_test.rb +15 -0
- data/lib/tap/generator/generators/task/task_generator.rb +21 -28
- data/lib/tap/generator/generators/task/templates/task.erb +13 -23
- data/lib/tap/generator/generators/task/templates/test.erb +15 -18
- data/lib/tap/generator/manifest.rb +14 -0
- data/lib/tap/patches/rake/rake_test_loader.rb +0 -0
- data/lib/tap/patches/rake/testtask.rb +0 -0
- data/lib/tap/patches/ruby19/backtrace_filter.rb +0 -0
- data/lib/tap/patches/ruby19/parsedate.rb +0 -0
- data/lib/tap/root.rb +260 -21
- data/lib/tap/support/aggregator.rb +11 -11
- data/lib/tap/support/assignments.rb +172 -0
- data/lib/tap/support/audit.rb +20 -18
- data/lib/tap/support/batchable.rb +21 -10
- data/lib/tap/support/batchable_class.rb +107 -0
- data/lib/tap/support/class_configuration.rb +154 -239
- data/lib/tap/support/command_line.rb +97 -102
- data/lib/tap/support/comment.rb +270 -0
- data/lib/tap/support/configurable.rb +86 -65
- data/lib/tap/support/configurable_class.rb +296 -0
- data/lib/tap/support/configuration.rb +122 -0
- data/lib/tap/support/constant.rb +70 -0
- data/lib/tap/support/constant_utils.rb +127 -0
- data/lib/tap/support/declarations.rb +111 -0
- data/lib/tap/support/executable.rb +30 -17
- data/lib/tap/support/executable_queue.rb +0 -0
- data/lib/tap/support/framework.rb +71 -0
- data/lib/tap/support/framework_class.rb +199 -0
- data/lib/tap/support/instance_configuration.rb +147 -0
- data/lib/tap/support/lazydoc.rb +428 -0
- data/lib/tap/support/manifest.rb +89 -0
- data/lib/tap/support/run_error.rb +0 -0
- data/lib/tap/support/shell_utils.rb +33 -9
- data/lib/tap/support/summary.rb +30 -0
- data/lib/tap/support/tdoc.rb +339 -134
- data/lib/tap/support/tdoc/tdoc_html_generator.rb +0 -0
- data/lib/tap/support/tdoc/tdoc_html_template.rb +0 -0
- data/lib/tap/support/templater.rb +180 -0
- data/lib/tap/support/validation.rb +409 -76
- data/lib/tap/support/versions.rb +5 -3
- data/lib/tap/task.rb +78 -174
- data/lib/tap/tasks/dump.rb +56 -0
- data/lib/tap/tasks/rake.rb +93 -0
- data/lib/tap/test.rb +3 -3
- data/lib/tap/test/env_vars.rb +2 -2
- data/lib/tap/test/file_methods.rb +19 -20
- data/lib/tap/test/script_methods.rb +144 -0
- data/lib/tap/test/subset_methods.rb +1 -1
- data/lib/tap/test/tap_methods.rb +28 -62
- data/lib/tap/workflow.rb +22 -39
- metadata +48 -179
- data/Basic Overview +0 -151
- data/Command Reference +0 -99
- data/Rakefile +0 -127
- data/Tutorial +0 -287
- data/lib/tap/cmd/console.rb +0 -31
- data/lib/tap/cmd/destroy.rb +0 -20
- data/lib/tap/cmd/generate.rb +0 -20
- data/lib/tap/cmd/run.rb +0 -151
- data/lib/tap/dump.rb +0 -57
- data/lib/tap/generator.rb +0 -91
- data/lib/tap/generator/generators/command/USAGE +0 -6
- data/lib/tap/generator/generators/config/USAGE +0 -21
- data/lib/tap/generator/generators/config/templates/config.erb +0 -1
- data/lib/tap/generator/generators/file_task/USAGE +0 -3
- data/lib/tap/generator/generators/file_task/templates/file.yml +0 -3
- data/lib/tap/generator/generators/generator/USAGE +0 -0
- data/lib/tap/generator/generators/generator/generator_generator.rb +0 -21
- data/lib/tap/generator/generators/generator/templates/generator.erb +0 -32
- data/lib/tap/generator/generators/generator/templates/usage.erb +0 -1
- data/lib/tap/generator/generators/root/USAGE +0 -0
- data/lib/tap/generator/generators/root/templates/ReadMe.txt +0 -0
- data/lib/tap/generator/generators/root/templates/tap.yml +0 -80
- data/lib/tap/generator/generators/task/USAGE +0 -3
- data/lib/tap/generator/generators/workflow/USAGE +0 -0
- data/lib/tap/generator/generators/workflow/templates/task.erb +0 -16
- data/lib/tap/generator/generators/workflow/templates/test.erb +0 -7
- data/lib/tap/generator/generators/workflow/workflow_generator.rb +0 -6
- data/lib/tap/generator/options.rb +0 -26
- data/lib/tap/generator/usage.rb +0 -26
- data/lib/tap/support/batchable_methods.rb +0 -34
- data/lib/tap/support/command_line_methods.rb +0 -76
- data/lib/tap/support/configurable_methods.rb +0 -224
- data/lib/tap/support/logger.rb +0 -88
- data/lib/tap/support/rake.rb +0 -43
- data/lib/tap/support/tdoc/config_attr.rb +0 -362
- data/test/app/config/another/task.yml +0 -1
- data/test/app/config/batch.yml +0 -2
- data/test/app/config/empty.yml +0 -0
- data/test/app/config/erb.yml +0 -2
- data/test/app/config/some/task.yml +0 -1
- data/test/app/config/template.yml +0 -2
- data/test/app/config/version-0.1.yml +0 -1
- data/test/app/config/version.yml +0 -1
- data/test/app/lib/app_test_task.rb +0 -3
- data/test/app_test.rb +0 -1849
- data/test/env/test_configure/recurse_a.yml +0 -2
- data/test/env/test_configure/recurse_b.yml +0 -2
- data/test/env/test_configure/tap.yml +0 -23
- data/test/env/test_load_env_config/dir/tap.yml +0 -3
- data/test/env/test_load_env_config/recurse_a.yml +0 -2
- data/test/env/test_load_env_config/recurse_b.yml +0 -2
- data/test/env/test_load_env_config/tap.yml +0 -3
- data/test/env_test.rb +0 -198
- data/test/file_task/config/batch.yml +0 -2
- data/test/file_task/config/configured.yml +0 -1
- data/test/file_task/old_file_one.txt +0 -0
- data/test/file_task/old_file_two.txt +0 -0
- data/test/file_task_test.rb +0 -1291
- data/test/root/alt_lib/alt_module.rb +0 -4
- data/test/root/file.txt +0 -0
- data/test/root/glob/one.txt +0 -0
- data/test/root/glob/two.txt +0 -0
- data/test/root/lib/absolute_alt_filepath.rb +0 -2
- data/test/root/lib/alternative_filepath.rb +0 -2
- data/test/root/lib/another_module.rb +0 -2
- data/test/root/lib/nested/some_module.rb +0 -4
- data/test/root/lib/no_module_included.rb +0 -0
- data/test/root/lib/some/module.rb +0 -4
- data/test/root/lib/some_class.rb +0 -2
- data/test/root/lib/some_module.rb +0 -3
- data/test/root/load_path/load_path_module.rb +0 -2
- data/test/root/load_path/skip_module.rb +0 -2
- data/test/root/mtime/older.txt +0 -0
- data/test/root/unload/full_path.rb +0 -2
- data/test/root/unload/loaded_by_nested.rb +0 -2
- data/test/root/unload/nested/nested_load.rb +0 -6
- data/test/root/unload/nested/nested_with_ext.rb +0 -4
- data/test/root/unload/nested/relative_path.rb +0 -4
- data/test/root/unload/older.rb +0 -2
- data/test/root/unload/unload_base.rb +0 -9
- data/test/root/versions/another.yml +0 -0
- data/test/root/versions/file-0.1.2.yml +0 -0
- data/test/root/versions/file-0.1.yml +0 -0
- data/test/root/versions/file.yml +0 -0
- data/test/root_test.rb +0 -718
- data/test/support/aggregator_test.rb +0 -99
- data/test/support/audit_test.rb +0 -445
- data/test/support/batchable_test.rb +0 -74
- data/test/support/class_configuration_test.rb +0 -331
- data/test/support/command_line_test.rb +0 -58
- data/test/support/configurable/config/configured.yml +0 -2
- data/test/support/configurable_test.rb +0 -295
- data/test/support/executable_queue_test.rb +0 -103
- data/test/support/executable_test.rb +0 -38
- data/test/support/logger_test.rb +0 -31
- data/test/support/rake_test.rb +0 -37
- data/test/support/shell_utils_test.rb +0 -24
- data/test/support/tdoc_test.rb +0 -370
- data/test/support/validation_test.rb +0 -54
- data/test/support/versions_test.rb +0 -103
- data/test/tap_test_helper.rb +0 -57
- data/test/tap_test_suite.rb +0 -7
- data/test/task/config/batch.yml +0 -2
- data/test/task/config/batched.yml +0 -2
- data/test/task/config/configured.yml +0 -1
- data/test/task/config/example.yml +0 -1
- data/test/task_base_test.rb +0 -24
- data/test/task_syntax_test.rb +0 -300
- data/test/task_test.rb +0 -320
- data/test/test/env_vars_test.rb +0 -48
- data/test/test/file_methods/test_assert_files/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +0 -1
- 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/file_methods_doc/test_sub/expected/one.txt +0 -1
- data/test/test/file_methods_doc/test_sub/expected/two.txt +0 -1
- data/test/test/file_methods_doc/test_sub/input/one.txt +0 -1
- data/test/test/file_methods_doc/test_sub/input/two.txt +0 -1
- data/test/test/file_methods_doc_test.rb +0 -29
- data/test/test/file_methods_test.rb +0 -275
- data/test/test/subset_methods_test.rb +0 -171
- data/test/test/tap_methods/test_assert_files/expected/task/name/a.txt +0 -1
- data/test/test/tap_methods/test_assert_files/expected/task/name/b.txt +0 -1
- data/test/test/tap_methods/test_assert_files/input/a.txt +0 -1
- data/test/test/tap_methods/test_assert_files/input/b.txt +0 -1
- data/test/test/tap_methods_test.rb +0 -399
- data/test/workflow_test.rb +0 -120
- data/vendor/rails_generator.rb +0 -56
- data/vendor/rails_generator/base.rb +0 -263
- data/vendor/rails_generator/commands.rb +0 -581
- data/vendor/rails_generator/generated_attribute.rb +0 -42
- data/vendor/rails_generator/lookup.rb +0 -209
- data/vendor/rails_generator/manifest.rb +0 -53
- data/vendor/rails_generator/options.rb +0 -143
- data/vendor/rails_generator/scripts.rb +0 -83
- data/vendor/rails_generator/scripts/destroy.rb +0 -7
- data/vendor/rails_generator/scripts/generate.rb +0 -7
- data/vendor/rails_generator/scripts/update.rb +0 -12
- data/vendor/rails_generator/simple_logger.rb +0 -46
- data/vendor/rails_generator/spec.rb +0 -44
data/test/support/rake_test.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
|
|
3
|
-
class RakeTest < Test::Unit::TestCase
|
|
4
|
-
acts_as_tap_test
|
|
5
|
-
|
|
6
|
-
def test_tap_with_rake
|
|
7
|
-
extended_test do
|
|
8
|
-
require 'tap/support/rake'
|
|
9
|
-
app.extend Tap::Support::Rake
|
|
10
|
-
|
|
11
|
-
runlist = []
|
|
12
|
-
t1 = task :task => [:prerequisite] do
|
|
13
|
-
runlist << :task
|
|
14
|
-
end
|
|
15
|
-
t2 = task :prerequisite do
|
|
16
|
-
runlist << :prerequisite
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
assert_equal [], runlist
|
|
20
|
-
app.task(:task).enq
|
|
21
|
-
app.run
|
|
22
|
-
assert_equal [:prerequisite, :task], runlist
|
|
23
|
-
|
|
24
|
-
# notice the tasks do not get re-run
|
|
25
|
-
app.task(:task).enq
|
|
26
|
-
app.run
|
|
27
|
-
assert_equal [:prerequisite, :task], runlist
|
|
28
|
-
|
|
29
|
-
# check that Rake still works natively
|
|
30
|
-
t1.instance_variable_set("@already_invoked", false)
|
|
31
|
-
t2.instance_variable_set("@already_invoked", false)
|
|
32
|
-
|
|
33
|
-
Rake.application.lookup(:task).invoke
|
|
34
|
-
assert_equal [:prerequisite, :task, :prerequisite, :task], runlist
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
require 'tap/support/shell_utils'
|
|
3
|
-
|
|
4
|
-
class ShellUtilsTest < Test::Unit::TestCase
|
|
5
|
-
include Tap::Support::ShellUtils
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
# capture_sh test
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
def test_capture_sh
|
|
12
|
-
assert_equal "hello\n", capture_sh('echo hello')
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_capture_sh_with_block
|
|
16
|
-
was_in_block = false
|
|
17
|
-
result = capture_sh('echo hello') do |ok, status|
|
|
18
|
-
assert ok
|
|
19
|
-
was_in_block = true
|
|
20
|
-
end
|
|
21
|
-
assert_equal "hello\n", result
|
|
22
|
-
assert was_in_block
|
|
23
|
-
end
|
|
24
|
-
end
|
data/test/support/tdoc_test.rb
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
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
|
-
config(:c_validation, 'value') {|value| } # c_validation
|
|
13
|
-
|
|
14
|
-
config_reader
|
|
15
|
-
|
|
16
|
-
config :c_reader, 'value' # c_reader
|
|
17
|
-
|
|
18
|
-
declare_config
|
|
19
|
-
|
|
20
|
-
config :c, 'value' # c
|
|
21
|
-
|
|
22
|
-
# c_conventional
|
|
23
|
-
config :c_conventional, 'value'
|
|
24
|
-
config :c_without_doc, 'value'
|
|
25
|
-
|
|
26
|
-
# c_multiline1
|
|
27
|
-
config(:c_multiline, 'value' ) # c_multiline2
|
|
28
|
-
|
|
29
|
-
config :alt_c, 'value' # alt_c
|
|
30
|
-
config :alt_c_validation, 'value' do |value| # alt_c_validation
|
|
31
|
-
end
|
|
32
|
-
config :alt_c_without_value # alt_c_without_value
|
|
33
|
-
config :alt_c_validation_without_value do |value| # alt_c_validation_without_value
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# declare_config
|
|
37
|
-
declare_config :declare_config
|
|
38
|
-
# confg_accessor
|
|
39
|
-
config_accessor :config_accessor
|
|
40
|
-
# config_reader
|
|
41
|
-
config_reader :config_reader
|
|
42
|
-
# config_writer
|
|
43
|
-
config_writer :config_writer
|
|
44
|
-
|
|
45
|
-
# multi_config_accessor
|
|
46
|
-
config_accessor :multi_config_accessor1, :multi_config_accessor2
|
|
47
|
-
|
|
48
|
-
# attr_accessor
|
|
49
|
-
attr_accessor :attr_accessor # ignored
|
|
50
|
-
attr_accessor :attr_accessor_without_doc
|
|
51
|
-
|
|
52
|
-
# multi_attr_accessor
|
|
53
|
-
attr_accessor :multi_attr_accessor1, :multi_attr_accessor2
|
|
54
|
-
|
|
55
|
-
config_accessor = [:is, :not, :documented]
|
|
56
|
-
attr_accessor = [:is, :not, :documented]
|
|
57
|
-
|
|
58
|
-
def process(input)
|
|
59
|
-
config(:is, :not, :documented)
|
|
60
|
-
config :is, :not, :documented
|
|
61
|
-
declare_config :is, :not, :documented
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def config(*args)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def declare_config(*args)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# nested doc
|
|
72
|
-
module Nested
|
|
73
|
-
# class doc
|
|
74
|
-
class Klass
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# mod doc
|
|
78
|
-
module Mod
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
class NotATask
|
|
83
|
-
class << self
|
|
84
|
-
def config_accessor(*args)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
config = "is not documented"
|
|
89
|
-
declare_config = [:is, :not, :documented]
|
|
90
|
-
|
|
91
|
-
config_accessor :is, :documented
|
|
92
|
-
|
|
93
|
-
config_accessor = [:is, :not, :documented]
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
class TDocTest < Test::Unit::TestCase
|
|
97
|
-
include Tap::Test::SubsetMethods
|
|
98
|
-
|
|
99
|
-
condition(:irb_variant) { env('tdoc_with_irb') }
|
|
100
|
-
if satisfied?(:irb_variant)
|
|
101
|
-
require 'irb'
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
require 'tap/support/tdoc'
|
|
105
|
-
include Tap::Support
|
|
106
|
-
|
|
107
|
-
TDoc.document(__FILE__)
|
|
108
|
-
|
|
109
|
-
#
|
|
110
|
-
# RDoc RubyLex and RubyToken redefinition test
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
def test_rubylex_and_rubytoken_redefinition
|
|
114
|
-
filepath = __FILE__
|
|
115
|
-
tl = RDoc::TopLevel.new(filepath)
|
|
116
|
-
stats = RDoc::Stats.new
|
|
117
|
-
options = Options.instance
|
|
118
|
-
parser = RDoc::RubyParser.new(tl, filepath, File.read(filepath), options, stats)
|
|
119
|
-
|
|
120
|
-
assert Tap::Support::TDoc::ConfigParser.included_modules.include?(RDoc::RubyToken)
|
|
121
|
-
assert RDoc::RubyParser.included_modules.include?(RDoc::RubyToken)
|
|
122
|
-
assert_equal RDoc::RubyLex, parser.instance_variable_get("@scanner").class
|
|
123
|
-
|
|
124
|
-
if satisfied?(:irb_variant)
|
|
125
|
-
assert_not_equal RubyToken, RDoc::RubyToken
|
|
126
|
-
assert_not_equal RubyLex, RDoc::RubyLex
|
|
127
|
-
assert RubyLex.included_modules.include?(RubyToken)
|
|
128
|
-
assert !RubyLex.included_modules.include?(RDoc::RubyLex)
|
|
129
|
-
else
|
|
130
|
-
flunk unless !Object.const_defined?(:RubyToken) || RubyToken == RDoc::RubyToken
|
|
131
|
-
flunk unless !Object.const_defined?(:RubyLex) || RubyLex == RDoc::RubyLex
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
#
|
|
136
|
-
# [] tests
|
|
137
|
-
#
|
|
138
|
-
|
|
139
|
-
def test_get_class_documentation
|
|
140
|
-
c = TDoc[TaskDocumentation]
|
|
141
|
-
assert_equal RDoc::NormalClass, c.class
|
|
142
|
-
assert_equal "# = Section One\n# section one\n#\n# == Section Two\n# section two\n# line two\n", c.comment
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
c = TDoc[Nested]
|
|
146
|
-
assert_equal RDoc::NormalModule, c.class
|
|
147
|
-
assert_equal "# nested doc\n", c.comment
|
|
148
|
-
|
|
149
|
-
c = TDoc[Nested::Klass]
|
|
150
|
-
assert_equal RDoc::NormalClass, c.class
|
|
151
|
-
assert_equal "# class doc\n", c.comment
|
|
152
|
-
|
|
153
|
-
c = TDoc[Nested::Mod]
|
|
154
|
-
assert_equal RDoc::NormalModule, c.class
|
|
155
|
-
assert_equal "# mod doc\n", c.comment
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def test_get_documentation_works_for_strings_and_constants
|
|
159
|
-
assert_equal RDoc::NormalClass, TDoc[Nested::Klass].class
|
|
160
|
-
assert_equal TDoc["Nested::Klass"].object_id, TDoc[Nested::Klass].object_id
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def test_configs_are_documented
|
|
164
|
-
c = TDoc[TaskDocumentation]
|
|
165
|
-
|
|
166
|
-
attributes = c.attributes.collect do |attribute|
|
|
167
|
-
case attribute
|
|
168
|
-
when TDoc::ConfigAttr
|
|
169
|
-
{:comment => attribute.original_comment,
|
|
170
|
-
:name => attribute.name,
|
|
171
|
-
:rw => attribute.rw,
|
|
172
|
-
:text => attribute.text}
|
|
173
|
-
else
|
|
174
|
-
{:comment => attribute.comment,
|
|
175
|
-
:name => attribute.name,
|
|
176
|
-
:rw => attribute.rw,
|
|
177
|
-
:text => attribute.text}
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
expected_attributes.each_with_index do |expected, i|
|
|
182
|
-
assert_equal expected, attributes[i], "unequal attribute (index=#{i})"
|
|
183
|
-
end
|
|
184
|
-
assert_equal expected_attributes.length, attributes.length
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
#
|
|
188
|
-
# accessor extensions
|
|
189
|
-
#
|
|
190
|
-
|
|
191
|
-
def test_comment_sections
|
|
192
|
-
c = TDoc[TaskDocumentation]
|
|
193
|
-
|
|
194
|
-
assert c.respond_to?(:comment_sections)
|
|
195
|
-
assert_equal({
|
|
196
|
-
"Section One" => "# section one\n#\n",
|
|
197
|
-
"Section Two" => "# section two\n# line two\n"},
|
|
198
|
-
c.comment_sections)
|
|
199
|
-
|
|
200
|
-
assert_equal({
|
|
201
|
-
"Section Two" => "# section two\n# line two\n"},
|
|
202
|
-
c.comment_sections(/two/i))
|
|
203
|
-
|
|
204
|
-
assert_equal({
|
|
205
|
-
"Section Two" => "section two\nline two"},
|
|
206
|
-
c.comment_sections(/two/i, true))
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
# def test_collect_configurations
|
|
210
|
-
# c = TDoc.document(TaskDocumentation, __FILE__)
|
|
211
|
-
# assert_equal expected_attributes[0..-5], TDoc.collect_configurations(c)
|
|
212
|
-
# end
|
|
213
|
-
#
|
|
214
|
-
# def test_collect_attributes
|
|
215
|
-
# c = TDoc.document(TaskDocumentation, __FILE__)
|
|
216
|
-
# assert_equal expected_attributes[-4..-1], TDoc.collect_attributes(c)
|
|
217
|
-
# end
|
|
218
|
-
|
|
219
|
-
def expected_attributes
|
|
220
|
-
@expected_attributes ||= [{
|
|
221
|
-
:comment=>nil,
|
|
222
|
-
:name=>"c_accessor",
|
|
223
|
-
:rw=>"RW",
|
|
224
|
-
:text=>"# c_accessor ('value')"},
|
|
225
|
-
{
|
|
226
|
-
:comment=>nil,
|
|
227
|
-
:name=>"c_validation",
|
|
228
|
-
:rw=>"RW",
|
|
229
|
-
:text=>"# c_validation ('value')"},
|
|
230
|
-
{
|
|
231
|
-
:comment=>nil,
|
|
232
|
-
:name=>"c_reader",
|
|
233
|
-
:rw=>"R",
|
|
234
|
-
:text=>"# c_reader ('value')"},
|
|
235
|
-
{
|
|
236
|
-
:comment=>nil,
|
|
237
|
-
:name=>"c",
|
|
238
|
-
:rw=>nil,
|
|
239
|
-
:text=>"# c ('value')"},
|
|
240
|
-
{
|
|
241
|
-
:comment=>"# c_conventional\n",
|
|
242
|
-
:name=>"c_conventional",
|
|
243
|
-
:rw=>nil,
|
|
244
|
-
:text=>" ('value')"},
|
|
245
|
-
{
|
|
246
|
-
:comment=>nil,
|
|
247
|
-
:name=>"c_without_doc",
|
|
248
|
-
:rw=>nil,
|
|
249
|
-
:text=>" ('value')"},
|
|
250
|
-
{
|
|
251
|
-
:comment=>"# c_multiline1\n",
|
|
252
|
-
:name=>"c_multiline",
|
|
253
|
-
:rw=>nil,
|
|
254
|
-
:text=>"# c_multiline2 ('value')"},
|
|
255
|
-
{
|
|
256
|
-
:comment=>nil,
|
|
257
|
-
:name=>"alt_c",
|
|
258
|
-
:rw=>nil,
|
|
259
|
-
:text=>"# alt_c ('value')"},
|
|
260
|
-
{
|
|
261
|
-
:comment=>nil,
|
|
262
|
-
:name=>"alt_c_validation",
|
|
263
|
-
:rw=>nil,
|
|
264
|
-
:text=>"# alt_c_validation ('value')"},
|
|
265
|
-
{
|
|
266
|
-
:comment=>nil,
|
|
267
|
-
:name=>"alt_c_without_value",
|
|
268
|
-
:rw=>nil,
|
|
269
|
-
:text=>"# alt_c_without_value"},
|
|
270
|
-
{
|
|
271
|
-
:comment=>nil,
|
|
272
|
-
:name=>"alt_c_validation_without_value",
|
|
273
|
-
:rw=>nil,
|
|
274
|
-
:text=>"# alt_c_validation_without_value"},
|
|
275
|
-
{
|
|
276
|
-
:comment=>"# declare_config\n",
|
|
277
|
-
:name=>"declare_config",
|
|
278
|
-
:rw=>nil,
|
|
279
|
-
:text=>""},
|
|
280
|
-
{
|
|
281
|
-
:comment=>"# confg_accessor\n",
|
|
282
|
-
:name=>"config_accessor",
|
|
283
|
-
:rw=>"RW",
|
|
284
|
-
:text=>""},
|
|
285
|
-
{
|
|
286
|
-
:comment=>"# config_reader\n",
|
|
287
|
-
:name=>"config_reader",
|
|
288
|
-
:rw=>"R",
|
|
289
|
-
:text=>""},
|
|
290
|
-
{
|
|
291
|
-
:comment=>"# config_writer\n",
|
|
292
|
-
:name=>"config_writer",
|
|
293
|
-
:rw=>"W",
|
|
294
|
-
:text=>""},
|
|
295
|
-
{
|
|
296
|
-
:comment=>"# multi_config_accessor\n",
|
|
297
|
-
:name=>"multi_config_accessor1",
|
|
298
|
-
:rw=>"RW",
|
|
299
|
-
:text=>""},
|
|
300
|
-
{
|
|
301
|
-
:comment=>"# multi_config_accessor\n",
|
|
302
|
-
:name=>"multi_config_accessor2",
|
|
303
|
-
:rw=>"RW",
|
|
304
|
-
:text=>""},
|
|
305
|
-
{
|
|
306
|
-
:comment=>"# attr_accessor\n",
|
|
307
|
-
:name=>"attr_accessor",
|
|
308
|
-
:rw=>"RW",
|
|
309
|
-
:text=>"# ignored"},
|
|
310
|
-
{
|
|
311
|
-
:comment=>nil,
|
|
312
|
-
:name=>"attr_accessor_without_doc",
|
|
313
|
-
:rw=>"RW",
|
|
314
|
-
:text=>""},
|
|
315
|
-
{
|
|
316
|
-
:comment=>"# multi_attr_accessor\n",
|
|
317
|
-
:name=>"multi_attr_accessor1",
|
|
318
|
-
:rw=>"RW",
|
|
319
|
-
:text=>""},
|
|
320
|
-
{
|
|
321
|
-
:comment=>"# multi_attr_accessor\n",
|
|
322
|
-
:name=>"multi_attr_accessor2",
|
|
323
|
-
:rw=>"RW",
|
|
324
|
-
:text=>""}]
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
#
|
|
328
|
-
# NotATask documentation
|
|
329
|
-
#
|
|
330
|
-
|
|
331
|
-
# def test_not_a_task_document
|
|
332
|
-
# c = TDoc.document(NotATask, __FILE__)
|
|
333
|
-
#
|
|
334
|
-
# assert_equal RDoc::NormalClass, c.class
|
|
335
|
-
# assert_equal "", c.comment
|
|
336
|
-
#
|
|
337
|
-
# attributes = c.attributes.collect do |attribute|
|
|
338
|
-
# case attribute
|
|
339
|
-
# when TDoc::ConfigAttr
|
|
340
|
-
# {:comment => attribute.original_comment,
|
|
341
|
-
# :name => attribute.name,
|
|
342
|
-
# :rw => attribute.rw,
|
|
343
|
-
# :text => attribute.text}
|
|
344
|
-
# else
|
|
345
|
-
# {:comment => attribute.comment,
|
|
346
|
-
# :name => attribute.name,
|
|
347
|
-
# :rw => attribute.rw,
|
|
348
|
-
# :text => attribute.text}
|
|
349
|
-
# end
|
|
350
|
-
# end
|
|
351
|
-
#
|
|
352
|
-
# not_a_task_expected_attributes.each_with_index do |expected, i|
|
|
353
|
-
# assert_equal expected, attributes[i], "unequal attribute (index=#{i})"
|
|
354
|
-
# end
|
|
355
|
-
# assert_equal not_a_task_expected_attributes.length, attributes.length
|
|
356
|
-
# end
|
|
357
|
-
|
|
358
|
-
def not_a_task_expected_attributes
|
|
359
|
-
@not_a_task_expected_attributes ||= [{
|
|
360
|
-
:comment=>nil,
|
|
361
|
-
:name=>"is",
|
|
362
|
-
:rw=>"RW",
|
|
363
|
-
:text=>""},
|
|
364
|
-
{
|
|
365
|
-
:comment=>nil,
|
|
366
|
-
:name=>"documented",
|
|
367
|
-
:rw=>"RW",
|
|
368
|
-
:text=>""}]
|
|
369
|
-
end
|
|
370
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
require 'tap/support/validation'
|
|
3
|
-
|
|
4
|
-
class ValidationTest < Test::Unit::TestCase
|
|
5
|
-
include Tap::Support::Validation
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
# validate test
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
def test_validate
|
|
12
|
-
assert_equal 1, validate(1, Integer)
|
|
13
|
-
assert_raise(ValidationError) { validate(nil, Integer) }
|
|
14
|
-
assert_equal 1, validate(1, [Integer, nil])
|
|
15
|
-
assert_equal nil, validate(nil, [Integer, nil])
|
|
16
|
-
|
|
17
|
-
assert_equal "str", validate("str", /str/)
|
|
18
|
-
assert_raise(ValidationError) { validate("str", /non/) }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
#
|
|
22
|
-
# check test
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
def test_check_returns_validation_block
|
|
26
|
-
m = check(Integer)
|
|
27
|
-
assert_equal Proc, m.class
|
|
28
|
-
assert_equal 1, m.call(1)
|
|
29
|
-
assert_raise(ValidationError) { m.call(nil) }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
#
|
|
33
|
-
# yaml test
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
def test_yaml_doc
|
|
37
|
-
b = yaml(Integer, nil)
|
|
38
|
-
assert_equal Proc, b.class
|
|
39
|
-
assert_equal 1, b.call(1)
|
|
40
|
-
assert_equal 1, b.call("1")
|
|
41
|
-
assert_equal nil, b.call(nil)
|
|
42
|
-
assert_raise(ValidationError) { b.call("str") }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_yaml_block_loads_strings_as_yaml_and_checks_result
|
|
46
|
-
m = yaml(Integer)
|
|
47
|
-
assert_equal Proc, m.class
|
|
48
|
-
assert_equal 1, m.call(1)
|
|
49
|
-
assert_equal 1, m.call("1")
|
|
50
|
-
assert_raise(ValidationError) { m.call(nil) }
|
|
51
|
-
assert_raise(ValidationError) { m.call("str") }
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
end
|