ruby-lint 1.1.0 → 2.0.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.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +43 -29
  3. data/LICENSE +1 -1
  4. data/README.md +0 -1
  5. data/bin/ruby-lint +91 -3
  6. data/checksum/ruby-lint-1.1.0.gem.sha512 +1 -0
  7. data/doc/changelog.md +30 -0
  8. data/doc/code_analysis.md +13 -0
  9. data/doc/configuration.md +5 -24
  10. data/lib/ruby-lint.rb +7 -10
  11. data/lib/ruby-lint/analysis/argument_amount.rb +2 -0
  12. data/lib/ruby-lint/analysis/base.rb +12 -0
  13. data/lib/ruby-lint/analysis/pedantics.rb +2 -0
  14. data/lib/ruby-lint/analysis/shadowing_variables.rb +2 -0
  15. data/lib/ruby-lint/analysis/undefined_methods.rb +5 -2
  16. data/lib/ruby-lint/analysis/undefined_variables.rb +2 -0
  17. data/lib/ruby-lint/analysis/unused_variables.rb +2 -0
  18. data/lib/ruby-lint/analysis/useless_equality_checks.rb +2 -0
  19. data/lib/ruby-lint/ast/node.rb +0 -15
  20. data/lib/ruby-lint/command.rb +100 -0
  21. data/lib/ruby-lint/configuration.rb +35 -66
  22. data/lib/ruby-lint/constant_path.rb +7 -2
  23. data/lib/ruby-lint/definition/ruby_object.rb +20 -6
  24. data/lib/ruby-lint/definitions/core/argf.rb +3 -3
  25. data/lib/ruby-lint/definitions/gems/minitest.rb +792 -0
  26. data/lib/ruby-lint/file_list.rb +1 -1
  27. data/lib/ruby-lint/file_loader.rb +2 -20
  28. data/lib/ruby-lint/file_scanner.rb +11 -2
  29. data/lib/ruby-lint/method_evaluation.rb +21 -0
  30. data/lib/ruby-lint/presenter/base.rb +18 -0
  31. data/lib/ruby-lint/presenter/json.rb +3 -1
  32. data/lib/ruby-lint/presenter/syntastic.rb +3 -1
  33. data/lib/ruby-lint/presenter/text.rb +3 -1
  34. data/lib/ruby-lint/runner.rb +6 -63
  35. data/lib/ruby-lint/variable_predicates.rb +3 -3
  36. data/lib/ruby-lint/version.rb +1 -1
  37. data/lib/ruby-lint/virtual_machine.rb +4 -1
  38. data/ruby-lint.gemspec +13 -4
  39. metadata +12 -187
  40. data/.editorconfig +0 -15
  41. data/.gitignore +0 -6
  42. data/.ruby-version +0 -1
  43. data/.travis.yml +0 -19
  44. data/Gemfile +0 -15
  45. data/MANIFEST +0 -469
  46. data/Rakefile +0 -25
  47. data/benchmark/bootup.rb +0 -13
  48. data/benchmark/virtual_machine.rb +0 -17
  49. data/checksum/.gitkeep +0 -0
  50. data/doc/.gitkeep +0 -0
  51. data/doc/css/.gitkeep +0 -0
  52. data/doc/images/.gitkeep +0 -0
  53. data/gen/rails/constants.txt +0 -12
  54. data/gen/rails/requires.rb +0 -2
  55. data/gen/stdlib/constants.rb +0 -30
  56. data/gen/stdlib/constants.txt +0 -214
  57. data/gen/stdlib/requires.rb +0 -64
  58. data/lib/ruby-lint/benchmark/average.rb +0 -115
  59. data/lib/ruby-lint/cache.rb +0 -121
  60. data/lib/ruby-lint/cache_entry.rb +0 -44
  61. data/lib/ruby-lint/cli.rb +0 -4
  62. data/lib/ruby-lint/cli/analyze.rb +0 -209
  63. data/lib/ruby-lint/cli/base.rb +0 -103
  64. data/lib/ruby-lint/cli/cache.rb +0 -60
  65. data/lib/ruby-lint/default_names.rb +0 -19
  66. data/lib/ruby-lint/definitions/gems/.gitkeep +0 -0
  67. data/lib/ruby-lint/node_hash.rb +0 -105
  68. data/misc/stdlib.rb +0 -66
  69. data/profiling/virtual_machine.rb +0 -20
  70. data/ruby-lint.yml +0 -7
  71. data/spec/fixtures/associating.rb +0 -7
  72. data/spec/fixtures/complex/rails/basic_controller.rb +0 -9
  73. data/spec/fixtures/complex/rcap.rb +0 -67
  74. data/spec/fixtures/complex/slop.rb +0 -701
  75. data/spec/fixtures/config.yml +0 -8
  76. data/spec/fixtures/deeply/nested/file.rb +0 -1
  77. data/spec/fixtures/file_scanner/lib/example/recursive/source.rb +0 -6
  78. data/spec/fixtures/file_scanner/lib/example/recursive/target.rb +0 -8
  79. data/spec/fixtures/file_scanner/lib/example/user.rb +0 -6
  80. data/spec/fixtures/file_scanner/lib/ruby-lint/definition/constant_proxy.rb +0 -6
  81. data/spec/fixtures/file_scanner/lib/ruby-lint/global_scope.rb +0 -6
  82. data/spec/fixtures/file_scanner/lib/test-dashes/foo.rb +0 -4
  83. data/spec/fixtures/file_scanner/rails/app/models/example/user.rb +0 -6
  84. data/spec/fixtures/file_scanner/rails/app/models/user.rb +0 -4
  85. data/spec/fixtures/invalid.rb +0 -3
  86. data/spec/fixtures/invalid_2.rb +0 -3
  87. data/spec/fixtures/syntax_error.rb +0 -1
  88. data/spec/fixtures/uses_external.rb +0 -1
  89. data/spec/fixtures/uses_external_invalid.rb +0 -3
  90. data/spec/fixtures/uses_external_namespace.rb +0 -1
  91. data/spec/fixtures/valid.rb +0 -3
  92. data/spec/ruby-lint/analysis/argument_amount_spec.rb +0 -131
  93. data/spec/ruby-lint/analysis/base_spec.rb +0 -24
  94. data/spec/ruby-lint/analysis/pedantics_spec.rb +0 -63
  95. data/spec/ruby-lint/analysis/shadowing_variables_spec.rb +0 -85
  96. data/spec/ruby-lint/analysis/undefined_methods_spec.rb +0 -337
  97. data/spec/ruby-lint/analysis/undefined_variables_spec.rb +0 -138
  98. data/spec/ruby-lint/analysis/unused_variables_spec.rb +0 -270
  99. data/spec/ruby-lint/analysis/useless_equality_checks_spec.rb +0 -107
  100. data/spec/ruby-lint/ast/node_spec.rb +0 -39
  101. data/spec/ruby-lint/cache_entry_spec.rb +0 -25
  102. data/spec/ruby-lint/cache_spec.rb +0 -53
  103. data/spec/ruby-lint/cli/analyze_spec.rb +0 -52
  104. data/spec/ruby-lint/configuration_spec.rb +0 -126
  105. data/spec/ruby-lint/constant_loader_spec.rb +0 -79
  106. data/spec/ruby-lint/constant_path.rb +0 -63
  107. data/spec/ruby-lint/definition/constant_proxy_spec.rb +0 -85
  108. data/spec/ruby-lint/definition/dsl_spec.rb +0 -135
  109. data/spec/ruby-lint/definition/registry_spec.rb +0 -106
  110. data/spec/ruby-lint/definition/ruby_method_spec.rb +0 -106
  111. data/spec/ruby-lint/definition/ruby_object_spec.rb +0 -264
  112. data/spec/ruby-lint/definition_builder/primitive_spec.rb +0 -62
  113. data/spec/ruby-lint/definition_builder/ruby_class_spec.rb +0 -107
  114. data/spec/ruby-lint/definition_builder/ruby_method_spec.rb +0 -53
  115. data/spec/ruby-lint/definition_builder/ruby_module_spec.rb +0 -52
  116. data/spec/ruby-lint/definitions/argv_spec.rb +0 -18
  117. data/spec/ruby-lint/definitions/env_spec.rb +0 -13
  118. data/spec/ruby-lint/definitions/file_spec.rb +0 -17
  119. data/spec/ruby-lint/definitions/fixnum_spec.rb +0 -18
  120. data/spec/ruby-lint/definitions/io_spec.rb +0 -15
  121. data/spec/ruby-lint/definitions/kernel_spec.rb +0 -18
  122. data/spec/ruby-lint/definitions/range_spec.rb +0 -21
  123. data/spec/ruby-lint/definitions/string_spec.rb +0 -20
  124. data/spec/ruby-lint/docstring/mapping.rb +0 -27
  125. data/spec/ruby-lint/docstring/parser_spec.rb +0 -88
  126. data/spec/ruby-lint/extensions/string_spec.rb +0 -7
  127. data/spec/ruby-lint/file_list_spec.rb +0 -25
  128. data/spec/ruby-lint/file_loader_spec.rb +0 -69
  129. data/spec/ruby-lint/file_scanner_spec.rb +0 -84
  130. data/spec/ruby-lint/inspector_spec.rb +0 -224
  131. data/spec/ruby-lint/iterator_spec.rb +0 -151
  132. data/spec/ruby-lint/method_call/.gitkeep +0 -0
  133. data/spec/ruby-lint/nested_stack_spec.rb +0 -23
  134. data/spec/ruby-lint/node_hash_spec.rb +0 -56
  135. data/spec/ruby-lint/parser_spec.rb +0 -38
  136. data/spec/ruby-lint/presenter/json_spec.rb +0 -58
  137. data/spec/ruby-lint/presenter/syntastic_spec.rb +0 -49
  138. data/spec/ruby-lint/presenter/text_spec.rb +0 -49
  139. data/spec/ruby-lint/report/entry_spec.rb +0 -58
  140. data/spec/ruby-lint/report_spec.rb +0 -39
  141. data/spec/ruby-lint/runner_spec.rb +0 -74
  142. data/spec/ruby-lint/variable_predicates_spec.rb +0 -30
  143. data/spec/ruby-lint/virtual_machine/alias_spec.rb +0 -55
  144. data/spec/ruby-lint/virtual_machine/assignments/arrays_spec.rb +0 -87
  145. data/spec/ruby-lint/virtual_machine/assignments/assignment_arguments_spec.rb +0 -14
  146. data/spec/ruby-lint/virtual_machine/assignments/constants_spec.rb +0 -23
  147. data/spec/ruby-lint/virtual_machine/assignments/hashes_spec.rb +0 -52
  148. data/spec/ruby-lint/virtual_machine/assignments/optional_spec.rb +0 -41
  149. data/spec/ruby-lint/virtual_machine/assignments/range_spec.rb +0 -28
  150. data/spec/ruby-lint/virtual_machine/assignments/return_values_spec.rb +0 -78
  151. data/spec/ruby-lint/virtual_machine/assignments/variables_spec.rb +0 -130
  152. data/spec/ruby-lint/virtual_machine/associate_nodes_spec.rb +0 -61
  153. data/spec/ruby-lint/virtual_machine/autoloading_spec.rb +0 -18
  154. data/spec/ruby-lint/virtual_machine/blocks_spec.rb +0 -90
  155. data/spec/ruby-lint/virtual_machine/classes/class_methods_spec.rb +0 -21
  156. data/spec/ruby-lint/virtual_machine/classes/extending_spec.rb +0 -109
  157. data/spec/ruby-lint/virtual_machine/classes/redefining_spec.rb +0 -51
  158. data/spec/ruby-lint/virtual_machine/classes/sclass_spec.rb +0 -96
  159. data/spec/ruby-lint/virtual_machine/classes/scoping_spec.rb +0 -60
  160. data/spec/ruby-lint/virtual_machine/complex/rails_spec.rb +0 -21
  161. data/spec/ruby-lint/virtual_machine/complex/rcap_spec.rb +0 -15
  162. data/spec/ruby-lint/virtual_machine/complex/slop_spec.rb +0 -16
  163. data/spec/ruby-lint/virtual_machine/constants_spec.rb +0 -31
  164. data/spec/ruby-lint/virtual_machine/for_spec.rb +0 -16
  165. data/spec/ruby-lint/virtual_machine/freeze_spec.rb +0 -13
  166. data/spec/ruby-lint/virtual_machine/global_variables_spec.rb +0 -15
  167. data/spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb +0 -15
  168. data/spec/ruby-lint/virtual_machine/interpolation_spec.rb +0 -12
  169. data/spec/ruby-lint/virtual_machine/location_spec.rb +0 -64
  170. data/spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb +0 -57
  171. data/spec/ruby-lint/virtual_machine/methods/attr_spec.rb +0 -182
  172. data/spec/ruby-lint/virtual_machine/methods/calls_spec.rb +0 -25
  173. data/spec/ruby-lint/virtual_machine/methods/define_method_spec.rb +0 -41
  174. data/spec/ruby-lint/virtual_machine/methods/defining_spec.rb +0 -40
  175. data/spec/ruby-lint/virtual_machine/methods/docstrings_spec.rb +0 -80
  176. data/spec/ruby-lint/virtual_machine/methods/exporting_spec.rb +0 -19
  177. data/spec/ruby-lint/virtual_machine/methods/kernel_spec.rb +0 -25
  178. data/spec/ruby-lint/virtual_machine/methods/parameters_spec.rb +0 -89
  179. data/spec/ruby-lint/virtual_machine/methods/patching_spec.rb +0 -20
  180. data/spec/ruby-lint/virtual_machine/methods/scoping_spec.rb +0 -63
  181. data/spec/ruby-lint/virtual_machine/methods/square_bracket_spec.rb +0 -32
  182. data/spec/ruby-lint/virtual_machine/methods/visibility_spec.rb +0 -64
  183. data/spec/ruby-lint/virtual_machine/modules_spec.rb +0 -205
  184. data/spec/ruby-lint/virtual_machine/reference_amount_spec.rb +0 -81
  185. data/spec/ruby-lint/virtual_machine/self_spec.rb +0 -37
  186. data/spec/ruby-lint/virtual_machine/unused_spec.rb +0 -17
  187. data/spec/spec_helper.rb +0 -28
  188. data/spec/support/building.rb +0 -50
  189. data/spec/support/coveralls.rb +0 -5
  190. data/spec/support/definitions.rb +0 -39
  191. data/spec/support/fixtures.rb +0 -20
  192. data/spec/support/parsing.rb +0 -30
  193. data/spec/support/simplecov.rb +0 -18
  194. data/spec/support/versions.rb +0 -9
  195. data/task/build.rake +0 -4
  196. data/task/checksum.rake +0 -13
  197. data/task/coverage.rake +0 -6
  198. data/task/doc.rake +0 -16
  199. data/task/generate.rake +0 -77
  200. data/task/graphviz.rake +0 -12
  201. data/task/manifest.rake +0 -8
  202. data/task/tag.rake +0 -6
  203. data/task/test.rake +0 -4
  204. data/task/todo.rake +0 -6
  205. data/task/travis.rake +0 -8
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::DefinitionBuilder::Primitive do
4
- before :all do
5
- @vm = RubyLint::VirtualMachine.new
6
- end
7
-
8
- example 'build an integer definition' do
9
- builder = RubyLint::DefinitionBuilder::Primitive.new(s(:int, 10), @vm)
10
- built = builder.build
11
-
12
- built.type.should == :int
13
- built.value.should == 10
14
- end
15
-
16
- example 'build a float definition' do
17
- builder = RubyLint::DefinitionBuilder::Primitive.new(s(:float, 10.0), @vm)
18
- built = builder.build
19
-
20
- built.type.should == :float
21
- built.value.should == 10.0
22
- end
23
-
24
- example 'build a string definition' do
25
- builder = RubyLint::DefinitionBuilder::Primitive.new(s(:str, 'a'), @vm)
26
- built = builder.build
27
-
28
- built.type.should == :str
29
- built.value.should == 'a'
30
- end
31
-
32
- example 'build a symbol definition' do
33
- builder = RubyLint::DefinitionBuilder::Primitive.new(s(:sym, :a), @vm)
34
- built = builder.build
35
-
36
- built.type.should == :sym
37
- built.value.should == :a
38
- end
39
-
40
- example 'build primitives as instances by default' do
41
- builder = RubyLint::DefinitionBuilder::Primitive.new(s(:int, 10), @vm)
42
-
43
- builder.build.instance?.should == true
44
- end
45
-
46
- example 'allow custom options to be defined' do
47
- builder = RubyLint::DefinitionBuilder::Primitive.new(
48
- s(:int, 10),
49
- @vm,
50
- :instance_type => :class
51
- )
52
-
53
- builder.build.class?.should == true
54
- end
55
-
56
- example 'include the definitions of the corresponding Ruby class' do
57
- builder = RubyLint::DefinitionBuilder::Primitive.new(s(:int, 10), @vm)
58
- built = builder.build
59
-
60
- built.lookup(:instance_method, 'to_s').is_a?(ruby_object).should == true
61
- end
62
- end
@@ -1,107 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::DefinitionBuilder::RubyClass do
4
- describe 'using an implicit parent class' do
5
- before :all do
6
- node = s(:class, s(:const, nil, :A), nil, s(:nil))
7
- @vm = RubyLint::VirtualMachine.new
8
- @builder = RubyLint::DefinitionBuilder::RubyClass.new(node, @vm)
9
- end
10
-
11
- example 'return the name of the class' do
12
- @builder.build.name.should == 'A'
13
- end
14
-
15
- example 'return the type of the class' do
16
- @builder.build.type.should == :const
17
- end
18
-
19
- example 'return the parent definitions' do
20
- built = @builder.build
21
-
22
- built.parents.length.should == 2
23
-
24
- built.parents[0].name.should == 'Object'
25
- built.parents[1].name.should == 'root'
26
- end
27
-
28
- example 'return the reference amount' do
29
- @builder.build.reference_amount.should == 1
30
- end
31
-
32
- example 'return the scope to define the class in' do
33
- @builder.scope.should == @vm.current_scope
34
- end
35
- end
36
-
37
- describe 'using an explicit parent class' do
38
- before :all do
39
- node = s(:class, s(:const, nil, :A), s(:const, nil, :B), s(:nil))
40
- @vm = RubyLint::VirtualMachine.new
41
- parent = @vm.definitions.define_constant('B')
42
-
43
- @builder = RubyLint::DefinitionBuilder::RubyClass.new(
44
- node,
45
- @vm,
46
- :parent => parent
47
- )
48
- end
49
-
50
- example 'return the name of the class' do
51
- @builder.build.name.should == 'A'
52
- end
53
-
54
- example 'return the parent definitions' do
55
- built = @builder.build
56
-
57
- built.parents.length.should == 2
58
-
59
- built.parents[0].name.should == 'B'
60
- built.parents[1].name.should == 'root'
61
- end
62
-
63
- example 'return the scope to define the class in' do
64
- @builder.scope.should == @vm.current_scope
65
- end
66
- end
67
-
68
- describe 'using constant paths' do
69
- before :all do
70
- node = s(
71
- :class,
72
- s(:const, s(:const, nil, :A), :B),
73
- s(:const, s(:const, nil, :C), :D),
74
- s(:nil)
75
- )
76
-
77
- @vm = RubyLint::VirtualMachine.new
78
-
79
- @vm.definitions.define_constant('A')
80
-
81
- d_const = @vm.definitions.define_constant('C').define_constant('D')
82
-
83
- @builder = RubyLint::DefinitionBuilder::RubyClass.new(
84
- node,
85
- @vm,
86
- :parent => d_const
87
- )
88
- end
89
-
90
- example 'return the name of the class' do
91
- @builder.build.name.should == 'B'
92
- end
93
-
94
- example 'return the parent definitions' do
95
- built = @builder.build
96
-
97
- built.parents.length.should == 2
98
-
99
- built.parents[0].name.should == 'D'
100
- built.parents[1].name.should == 'root'
101
- end
102
-
103
- example 'return the scope to define the class in' do
104
- @builder.scope.should == @vm.definitions.lookup(:const, 'A')
105
- end
106
- end
107
- end
@@ -1,53 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::DefinitionBuilder::RubyMethod do
4
- describe 'defining a method without a receiver' do
5
- before :all do
6
- node = s(:def, :example, s(:args), s(:nil))
7
- @vm = RubyLint::VirtualMachine.new
8
- @builder = RubyLint::DefinitionBuilder::RubyMethod.new(node, @vm)
9
- end
10
-
11
- example 'return the name of the method' do
12
- @builder.build.name.should == 'example'
13
- end
14
-
15
- example 'return the type of the method' do
16
- @builder.build.type.should == :instance_method
17
- end
18
-
19
- example 'return the parent definitions' do
20
- @builder.build.parents.should == [@vm.current_scope]
21
- end
22
-
23
- example 'return the scope to define the method in' do
24
- @builder.scope.should == @vm.current_scope
25
- end
26
- end
27
-
28
- describe 'defining a method with a constant as a receiver' do
29
- before :all do
30
- node = s(:defs, s(:const, nil, :A), :example, s(:args), s(:nil))
31
- @vm = RubyLint::VirtualMachine.new
32
- a_const = @vm.definitions.define_constant('A')
33
-
34
- @builder = RubyLint::DefinitionBuilder::RubyMethod.new(
35
- node,
36
- @vm,
37
- :receiver => a_const
38
- )
39
- end
40
-
41
- example 'return the name of the method' do
42
- @builder.build.name.should == 'example'
43
- end
44
-
45
- example 'return the parent definitions' do
46
- @builder.build.parents.should == [@vm.definitions.lookup(:const, 'A')]
47
- end
48
-
49
- example 'return the scope to define the method in' do
50
- @builder.scope.should == @vm.definitions.lookup(:const, 'A')
51
- end
52
- end
53
- end
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::DefinitionBuilder::RubyModule do
4
- describe 'building a simple module' do
5
- before :all do
6
- node = s(:module, s(:const, nil, :A), s(:nil))
7
- @vm = RubyLint::VirtualMachine.new
8
- @builder = RubyLint::DefinitionBuilder::RubyModule.new(node, @vm)
9
- @module = @vm.definitions.lookup(:const, 'Module')
10
- end
11
-
12
- example 'return the name of the module' do
13
- @builder.build.name.should == 'A'
14
- end
15
-
16
- example 'return the parent definitions' do
17
- @builder.build.parents.should == [@module, @vm.current_scope]
18
- end
19
-
20
- example 'return the reference amount' do
21
- @builder.build.reference_amount.should == 1
22
- end
23
-
24
- example 'return the scope to define the module in' do
25
- @builder.scope.should == @vm.current_scope
26
- end
27
- end
28
-
29
- describe 'using constant paths' do
30
- before :all do
31
- node = s(:module, s(:const, s(:const, nil, :A), :B), s(:nil))
32
- @vm = RubyLint::VirtualMachine.new
33
-
34
- @vm.definitions.define_constant('A')
35
-
36
- @builder = RubyLint::DefinitionBuilder::RubyModule.new(node, @vm)
37
- @module = @vm.definitions.lookup(:const, 'Module')
38
- end
39
-
40
- example 'return the name of the module' do
41
- @builder.build.name.should == 'B'
42
- end
43
-
44
- example 'return the parent definitions' do
45
- @builder.build.parents.should == [@module, @vm.current_scope]
46
- end
47
-
48
- example 'return the scope to define the module in' do
49
- @builder.scope.should == @vm.definitions.lookup(:const, 'A')
50
- end
51
- end
52
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ruby-lint definitions' do
4
- context 'ARGV' do
5
- before :all do
6
- root = load_definitions('ARGV', 'Array')
7
- @const = root.lookup(:const, 'ARGV')
8
- end
9
-
10
- example 'treat ARGV as an instance' do
11
- @const.instance?.should == true
12
- end
13
-
14
- example 'ARGV should be an Array' do
15
- @const.has_definition?(:instance_method, 'each').should == true
16
- end
17
- end
18
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ruby-lint definitions' do
4
- context 'ENV' do
5
- before :all do
6
- @const = load_definitions('ENV').lookup(:const, 'ENV')
7
- end
8
-
9
- example 'treat ENV as an instance' do
10
- @const.instance?.should == true
11
- end
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ruby-lint definitions' do
4
- context 'File' do
5
- before :all do
6
- @file = load_definitions('File').lookup(:const, 'File')
7
- end
8
-
9
- example 'File.read should be defined' do
10
- @file.has_definition?(:method, 'read').should == true
11
- end
12
-
13
- example 'File.open should be defined' do
14
- @file.has_definition?(:method, 'open').should == true
15
- end
16
- end
17
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ruby-lint definitions' do
4
- context 'Fixnum' do
5
- before :all do
6
- root = load_definitions('Fixnum', 'Integer', 'Numeric')
7
- @fixnum = root.lookup(:const, 'Fixnum')
8
- end
9
-
10
- example 'inherit from Integer' do
11
- @fixnum.parents.map(&:name).include?('Integer').should == true
12
- end
13
-
14
- example 'respond to methods from Numeric' do
15
- @fixnum.has_definition?(:instance_method, '%').should == true
16
- end
17
- end
18
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ruby-lint definitions' do
4
- context 'IO' do
5
- before :all do
6
- @root = load_definitions('STDERR', 'STDOUT', 'STDIN')
7
- end
8
-
9
- example 'treat STDERR/STDOUT/STDIN as instances' do
10
- %w{STDERR STDOUT STDIN}.each do |name|
11
- @root.lookup(:const, name).instance?.should == true
12
- end
13
- end
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ruby-lint definitions' do
4
- context 'Kernel' do
5
- before :all do
6
- @root = load_definitions('Kernel')
7
- @kernel = @root.lookup(:const, 'Kernel')
8
- end
9
-
10
- example 'The method is_a?() should be a class method' do
11
- @kernel.defines?(:method, 'is_a?').should == true
12
- end
13
-
14
- example 'The method is_a?() should be an instance method' do
15
- @kernel.defines?(:instance_method, 'is_a?').should == true
16
- end
17
- end
18
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ruby-lint definitions' do
4
- context 'Range' do
5
- before :all do
6
- @range = load_definitions('Range', 'Enumerable').lookup(:const, 'Range')
7
- end
8
-
9
- example 'Enumerable should be a parent' do
10
- @range.parents.map(&:name).include?('Enumerable').should == true
11
- end
12
-
13
- example 'inherit methods from Enumrable' do
14
- @range.has_definition?(:instance_method, 'map').should == true
15
- end
16
-
17
- example 'do not define Enumerable methods directly' do
18
- @range.defines?(:instance_method, 'map').should == false
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ruby-lint definitions' do
4
- context 'String' do
5
- before :all do
6
- @string = load_definitions('String').lookup(:const, 'String')
7
- end
8
-
9
- example 'define self as a class method' do
10
- @string.lookup(:method, 'self').return_value.class?.should == true
11
- end
12
-
13
- example 'define self as an instance method' do
14
- @string.lookup(:instance_method, 'self')
15
- .return_value
16
- .instance?
17
- .should == true
18
- end
19
- end
20
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::Docstring::Mapping do
4
- let(:param_tag) { RubyLint::Docstring::ParamTag }
5
- let(:return_tag) { RubyLint::Docstring::ReturnTag }
6
-
7
- let(:tags) do
8
- [
9
- param_tag.new(:name => 'number', :types => ['Numeric']),
10
- param_tag.new(:name => 'number2', :types => ['Integer']),
11
- return_tag.new(:types => ['Numeric'])
12
- ]
13
- end
14
-
15
- example 'map parameter tags by their names' do
16
- mapping = RubyLint::Docstring::Mapping.new(tags)
17
-
18
- mapping.param_tags['number'].types.should == ['Numeric']
19
- mapping.param_tags['number2'].types.should == ['Integer']
20
- end
21
-
22
- example 'map a return tag' do
23
- mapping = RubyLint::Docstring::Mapping.new(tags)
24
-
25
- mapping.return_tag.types.should == ['Numeric']
26
- end
27
- end