yardstick 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +4 -0
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +11 -16
  6. data/CONTRIBUTING.md +11 -0
  7. data/Gemfile +3 -59
  8. data/Gemfile.devtools +54 -0
  9. data/Guardfile +32 -0
  10. data/LICENSE +1 -1
  11. data/README.md +71 -55
  12. data/Rakefile +2 -7
  13. data/TODO +12 -0
  14. data/bin/yardstick +1 -0
  15. data/config/devtools.yml +2 -0
  16. data/config/flay.yml +2 -2
  17. data/config/flog.yml +1 -1
  18. data/config/mutant.yml +3 -0
  19. data/config/{site.reek → reek.yml} +31 -25
  20. data/config/rubocop.yml +49 -0
  21. data/config/yardstick.yml +31 -0
  22. data/lib/yardstick.rb +35 -15
  23. data/lib/yardstick/cli.rb +7 -7
  24. data/lib/yardstick/config.rb +176 -0
  25. data/lib/yardstick/document.rb +215 -0
  26. data/lib/yardstick/document_set.rb +21 -0
  27. data/lib/yardstick/measurement.rb +18 -145
  28. data/lib/yardstick/measurement_set.rb +2 -2
  29. data/lib/yardstick/parser.rb +61 -0
  30. data/lib/yardstick/processor.rb +21 -35
  31. data/lib/yardstick/rake/measurement.rb +7 -49
  32. data/lib/yardstick/rake/verify.rb +28 -55
  33. data/lib/yardstick/report_output.rb +57 -0
  34. data/lib/yardstick/rule.rb +64 -37
  35. data/lib/yardstick/rule_config.rb +56 -0
  36. data/lib/yardstick/rules/api_tag.rb +95 -0
  37. data/lib/yardstick/rules/example_tag.rb +33 -0
  38. data/lib/yardstick/rules/return_tag.rb +21 -0
  39. data/lib/yardstick/rules/summary.rb +87 -0
  40. data/lib/yardstick/version.rb +1 -1
  41. data/lib/yardstick/yard_ext.rb +1 -6
  42. data/spec/integration/yardstick/class_methods/measure_spec.rb +22 -0
  43. data/spec/integration/yardstick/class_methods/measure_string_spec.rb +20 -0
  44. data/spec/integration/yardstick/document/file_spec.rb +16 -0
  45. data/spec/integration/yardstick/document/line_spec.rb +25 -0
  46. data/spec/integration/yardstick/document/path_spec.rb +45 -0
  47. data/spec/integration/yardstick/processor/process_string_spec.rb +401 -0
  48. data/spec/integration/yardstick/rake/measurement_spec.rb +22 -0
  49. data/spec/integration/yardstick/rake/verify_spec.rb +19 -0
  50. data/spec/shared/measured_itself_behavior.rb +15 -0
  51. data/spec/spec_helper.rb +13 -26
  52. data/spec/support/document_mock.rb +16 -0
  53. data/spec/support/rules.rb +51 -0
  54. data/spec/unit/yardstick/class_methods/measure_spec.rb +31 -0
  55. data/spec/unit/yardstick/class_methods/measure_string_spec.rb +33 -0
  56. data/spec/unit/yardstick/cli_spec.rb +11 -8
  57. data/spec/unit/yardstick/config/class_methods/coerce_spec.rb +32 -0
  58. data/spec/unit/yardstick/config/for_rule_spec.rb +47 -0
  59. data/spec/unit/yardstick/config/initialize_spec.rb +21 -0
  60. data/spec/unit/yardstick/config/output_spec.rb +15 -0
  61. data/spec/unit/yardstick/config/output_writer_spec.rb +20 -0
  62. data/spec/unit/yardstick/config/path_spec.rb +13 -0
  63. data/spec/unit/yardstick/config/path_writer_spec.rb +11 -0
  64. data/spec/unit/yardstick/config/require_exact_threshold_predicate_spec.rb +19 -0
  65. data/spec/unit/yardstick/config/require_exact_threshold_writer_spec.rb +19 -0
  66. data/spec/unit/yardstick/config/set_defaults_spec.rb +42 -0
  67. data/spec/unit/yardstick/config/threshold_writer_spec.rb +15 -0
  68. data/spec/unit/yardstick/config/verbose_predicate_spec.rb +19 -0
  69. data/spec/unit/yardstick/config/verbose_writer_spec.rb +19 -0
  70. data/spec/unit/yardstick/document/api_predicate_spec.rb +25 -0
  71. data/spec/unit/yardstick/document/class_methods/measure_spec.rb +25 -0
  72. data/spec/unit/yardstick/document/class_methods/register_rule_spec.rb +19 -0
  73. data/spec/unit/yardstick/document/class_methods/registered_rules_spec.rb +9 -0
  74. data/spec/unit/yardstick/document/docstring_spec.rb +11 -0
  75. data/spec/unit/yardstick/document/file_spec.rb +14 -0
  76. data/spec/unit/yardstick/document/has_tag_predicate_spec.rb +15 -0
  77. data/spec/unit/yardstick/document/line_spec.rb +12 -0
  78. data/spec/unit/yardstick/document/null_tag/text_spec.rb +9 -0
  79. data/spec/unit/yardstick/document/null_tag/types_spec.rb +9 -0
  80. data/spec/unit/yardstick/document/path_spec.rb +12 -0
  81. data/spec/unit/yardstick/document/summary_text_spec.rb +23 -0
  82. data/spec/unit/yardstick/document/tag_text_spec.rb +17 -0
  83. data/spec/unit/yardstick/document/tag_types_spec.rb +18 -0
  84. data/spec/unit/yardstick/document/visibility_spec.rb +22 -0
  85. data/spec/unit/yardstick/document_set/measure_spec.rb +28 -0
  86. data/spec/unit/yardstick/measurement/description_spec.rb +12 -0
  87. data/spec/unit/yardstick/measurement/initialize_spec.rb +12 -0
  88. data/spec/unit/yardstick/measurement/ok_predicate_spec.rb +21 -0
  89. data/spec/unit/yardstick/measurement/puts_spec.rb +62 -0
  90. data/spec/unit/yardstick/measurement/skip_predicate_spec.rb +27 -0
  91. data/spec/unit/yardstick/measurement_set/coverage_spec.rb +23 -0
  92. data/spec/unit/yardstick/measurement_set/failed_spec.rb +28 -0
  93. data/spec/unit/yardstick/measurement_set/initialize_spec.rb +27 -0
  94. data/spec/unit/yardstick/measurement_set/puts_spec.rb +63 -0
  95. data/spec/unit/yardstick/measurement_set/successful_spec.rb +13 -0
  96. data/spec/unit/yardstick/measurement_set/total_spec.rb +12 -0
  97. data/spec/unit/yardstick/ordered_set/each_spec.rb +18 -0
  98. data/spec/unit/yardstick/ordered_set/empty_predicate_spec.rb +19 -0
  99. data/spec/unit/yardstick/ordered_set/include_predicate_spec.rb +21 -0
  100. data/spec/unit/yardstick/ordered_set/index_spec.rb +21 -0
  101. data/spec/unit/yardstick/ordered_set/left_shift_operator_spec.rb +16 -0
  102. data/spec/unit/yardstick/ordered_set/length_spec.rb +11 -0
  103. data/spec/unit/yardstick/ordered_set/merge_spec.rb +16 -0
  104. data/spec/unit/yardstick/parser/class_methods/parse_paths_spec.rb +28 -0
  105. data/spec/unit/yardstick/parser/class_methods/parse_string_spec.rb +28 -0
  106. data/spec/unit/yardstick/processor/process_spec.rb +17 -0
  107. data/spec/unit/yardstick/processor/process_string_spec.rb +17 -0
  108. data/spec/unit/yardstick/rake/measurement/initialize_spec.rb +64 -0
  109. data/spec/unit/yardstick/rake/measurement/yardstick_measure_spec.rb +22 -0
  110. data/spec/unit/yardstick/rake/verify/initialize_spec.rb +72 -0
  111. data/spec/unit/yardstick/rake/verify/verify_measurements_spec.rb +85 -0
  112. data/spec/unit/yardstick/report_output/class_methods/coerce_spec.rb +18 -0
  113. data/spec/unit/yardstick/report_output/initialize_spec.rb +11 -0
  114. data/spec/unit/yardstick/report_output/to_s_spec.rb +12 -0
  115. data/spec/unit/yardstick/report_output/write_spec.rb +31 -0
  116. data/spec/unit/yardstick/round_percentage_spec.rb +9 -0
  117. data/spec/unit/yardstick/rule/class_methods/coerce_spec.rb +21 -0
  118. data/spec/unit/yardstick/rule/class_methods/inherited_spec.rb +15 -0
  119. data/spec/unit/yardstick/rule/enabled_predicate_spec.rb +18 -0
  120. data/spec/unit/yardstick/rule/initialize_spec.rb +25 -0
  121. data/spec/unit/yardstick/rule/validatable_predicate_spec.rb +11 -0
  122. data/spec/unit/yardstick/rule_config/enabled_for_path_predicate_spec.rb +41 -0
  123. data/spec/unit/yardstick/rule_config/initialize_spec.rb +16 -0
  124. data/spec/unit/yardstick/rules/api_tag/inclusion/valid_predicate_spec.rb +27 -0
  125. data/spec/unit/yardstick/rules/api_tag/presence/valid_predicate_spec.rb +25 -0
  126. data/spec/unit/yardstick/rules/api_tag/private_method/valid_predicate_spec.rb +21 -0
  127. data/spec/unit/yardstick/rules/api_tag/private_method/validatable_predicate_spec.rb +21 -0
  128. data/spec/unit/yardstick/rules/api_tag/protected_method/valid_predicate_spec.rb +25 -0
  129. data/spec/unit/yardstick/rules/api_tag/protected_method/validatable_predicate_spec.rb +21 -0
  130. data/spec/unit/yardstick/rules/example_tag/valid_predicate_spec.rb +25 -0
  131. data/spec/unit/yardstick/rules/example_tag/validatable_predicate_spec.rb +32 -0
  132. data/spec/unit/yardstick/rules/return_tag/valid_predicate_spec.rb +21 -0
  133. data/spec/unit/yardstick/rules/summary/delimiter/valid_predicate_spec.rb +21 -0
  134. data/spec/unit/yardstick/rules/summary/length/valid_predicate_spec.rb +27 -0
  135. data/spec/unit/yardstick/rules/summary/presence/valid_predicate_spec.rb +21 -0
  136. data/spec/unit/yardstick/rules/summary/presence/validatable_predicate_spec.rb +21 -0
  137. data/spec/unit/yardstick/rules/summary/single_line/valid_predicate_spec.rb +21 -0
  138. data/yardstick.gemspec +7 -11
  139. metadata +222 -65
  140. data/.rvmrc +0 -1
  141. data/lib/yardstick/measurable.rb +0 -67
  142. data/lib/yardstick/method.rb +0 -113
  143. data/lib/yardstick/rule_set.rb +0 -22
  144. data/spec/support/config_alias.rb +0 -5
  145. data/spec/unit/yardstick/measurement_set_spec.rb +0 -266
  146. data/spec/unit/yardstick/measurement_spec.rb +0 -257
  147. data/spec/unit/yardstick/method_spec.rb +0 -357
  148. data/spec/unit/yardstick/rake/measurement_spec.rb +0 -175
  149. data/spec/unit/yardstick/rake/verify_spec.rb +0 -231
  150. data/spec/unit/yardstick/rule_spec.rb +0 -36
  151. data/spec/unit/yardstick_spec.rb +0 -71
  152. data/tasks/metrics/ci.rake +0 -9
  153. data/tasks/metrics/flay.rake +0 -53
  154. data/tasks/metrics/flog.rake +0 -44
  155. data/tasks/metrics/heckle.rake +0 -52
  156. data/tasks/metrics/metric_fu.rake +0 -31
  157. data/tasks/metrics/reek.rake +0 -21
  158. data/tasks/metrics/roodi.rake +0 -19
  159. data/tasks/metrics/yardstick.rake +0 -27
  160. data/tasks/spec.rake +0 -64
  161. data/tasks/yard.rake +0 -11
@@ -1,257 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- shared_examples_for 'measurement is successful' do
6
- before do
7
- @measurement = Yardstick::Measurement.new('successful', @docstring) { true }
8
- end
9
- end
10
-
11
- shared_examples_for 'measurement is skipped' do
12
- before do
13
- @measurement = Yardstick::Measurement.new('skipped', @docstring) { skip }
14
- end
15
- end
16
-
17
- shared_examples_for 'measurement is not successful' do
18
- before do
19
- @measurement = Yardstick::Measurement.new('not successful', @docstring) { false }
20
- end
21
- end
22
-
23
- shared_examples_for 'measurement is not implemented' do
24
- before do
25
- @measurement = Yardstick::Measurement.new('not implemented', @docstring) { todo }
26
- end
27
- end
28
-
29
- shared_examples_for 'measurement is displayed' do
30
- before do
31
- capture_stdout { @measurement.puts }
32
- end
33
- end
34
-
35
- shared_examples_for 'measurement is sent to object' do
36
- before do
37
- io = StringIO.new
38
- @measurement.puts(io)
39
- io.rewind
40
- @output = io.read
41
- end
42
- end
43
-
44
- describe Yardstick::Measurement do
45
- before do
46
- YARD.parse_string(<<-RUBY)
47
- class MeasurementTest
48
- def test
49
- end
50
- end
51
- RUBY
52
-
53
- @docstring = YARD::Registry.all(:method).first.docstring
54
- end
55
-
56
- describe '.new' do
57
- before do
58
- @measurement = Yardstick::Measurement.new('test measurement', @docstring) { true }
59
- end
60
-
61
- it 'should return a Measurement' do
62
- @measurement.should be_kind_of(Yardstick::Measurement)
63
- end
64
- end
65
-
66
- describe '#description' do
67
- before do
68
- @description = 'test measurement'
69
-
70
- @measurement = Yardstick::Measurement.new(@description, @docstring) { true }
71
- end
72
-
73
- it 'should return the expected description' do
74
- @measurement.description.should equal(@description)
75
- end
76
- end
77
-
78
- describe '#ok?' do
79
- describe 'when the measurement is successful' do
80
- it_should_behave_like 'measurement is successful'
81
-
82
- it 'should return true' do
83
- @measurement.ok?.should be_true
84
- end
85
- end
86
-
87
- describe 'when the measurement is skipped' do
88
- it_should_behave_like 'measurement is skipped'
89
-
90
- it 'should return true' do
91
- @measurement.ok?.should be_true
92
- end
93
- end
94
-
95
- describe 'when the measurement is not successful' do
96
- it_should_behave_like 'measurement is not successful'
97
-
98
- it 'should return false' do
99
- @measurement.ok?.should be_false
100
- end
101
- end
102
-
103
- describe 'when the measurement is not implemented' do
104
- it_should_behave_like 'measurement is not implemented'
105
-
106
- it 'should return false' do
107
- @measurement.ok?.should be_false
108
- end
109
- end
110
- end
111
-
112
- describe '#skip?' do
113
- describe 'when the measurement is successful' do
114
- it_should_behave_like 'measurement is successful'
115
-
116
- it 'should return false' do
117
- @measurement.skip?.should be_false
118
- end
119
- end
120
-
121
- describe 'when the measurement is skipped' do
122
- it_should_behave_like 'measurement is skipped'
123
-
124
- it 'should return true' do
125
- @measurement.skip?.should be_true
126
- end
127
- end
128
-
129
- describe 'when the measurement is not successful' do
130
- it_should_behave_like 'measurement is not successful'
131
-
132
- it 'should return false' do
133
- @measurement.skip?.should be_false
134
- end
135
- end
136
-
137
- describe 'when the measurement is not implemented' do
138
- it_should_behave_like 'measurement is not implemented'
139
-
140
- it 'should return false' do
141
- @measurement.skip?.should be_false
142
- end
143
- end
144
- end
145
-
146
- describe '#todo?' do
147
- describe 'when the measurement is successful' do
148
- it_should_behave_like 'measurement is successful'
149
-
150
- it 'should return false' do
151
- @measurement.todo?.should be_false
152
- end
153
- end
154
-
155
- describe 'when the measurement is skipped' do
156
- it_should_behave_like 'measurement is skipped'
157
-
158
- it 'should return false' do
159
- @measurement.todo?.should be_false
160
- end
161
- end
162
-
163
- describe 'when the measurement is not successful' do
164
- it_should_behave_like 'measurement is not successful'
165
-
166
- it 'should return false' do
167
- @measurement.todo?.should be_false
168
- end
169
- end
170
-
171
- describe 'when the measurement is not implemented' do
172
- it_should_behave_like 'measurement is not implemented'
173
-
174
- it 'should return true' do
175
- @measurement.todo?.should be_true
176
- end
177
- end
178
- end
179
-
180
- describe '#puts' do
181
- describe 'with no arguments' do
182
- describe 'when the measurement is successful' do
183
- it_should_behave_like 'measurement is successful'
184
- it_should_behave_like 'measurement is displayed'
185
-
186
- it 'should not display any output' do
187
- @output.should == ''
188
- end
189
- end
190
-
191
- describe 'when the measurement is skipped' do
192
- it_should_behave_like 'measurement is skipped'
193
- it_should_behave_like 'measurement is displayed'
194
-
195
- it 'should not display any output' do
196
- @output.should == ''
197
- end
198
- end
199
-
200
- describe 'when the measurement is not successful' do
201
- it_should_behave_like 'measurement is not successful'
202
- it_should_behave_like 'measurement is displayed'
203
-
204
- it 'should display output' do
205
- @output.should == "(stdin):2: MeasurementTest#test: not successful\n"
206
- end
207
- end
208
-
209
- describe 'when the measurement is not implemented' do
210
- it_should_behave_like 'measurement is not implemented'
211
- it_should_behave_like 'measurement is displayed'
212
-
213
- it 'should display output' do
214
- @output.should == "(stdin):2: MeasurementTest#test: not implemented\n"
215
- end
216
- end
217
- end
218
-
219
- describe 'with an object implementing #puts' do
220
- describe 'when the measurement is successful' do
221
- it_should_behave_like 'measurement is successful'
222
- it_should_behave_like 'measurement is sent to object'
223
-
224
- it 'should not display any output' do
225
- @output.should == ''
226
- end
227
- end
228
-
229
- describe 'when the measurement is skipped' do
230
- it_should_behave_like 'measurement is skipped'
231
- it_should_behave_like 'measurement is sent to object'
232
-
233
- it 'should not display any output' do
234
- @output.should == ''
235
- end
236
- end
237
-
238
- describe 'when the measurement is not successful' do
239
- it_should_behave_like 'measurement is not successful'
240
- it_should_behave_like 'measurement is sent to object'
241
-
242
- it 'should display output' do
243
- @output.should == "(stdin):2: MeasurementTest#test: not successful\n"
244
- end
245
- end
246
-
247
- describe 'when the measurement is not implemented' do
248
- it_should_behave_like 'measurement is not implemented'
249
- it_should_behave_like 'measurement is sent to object'
250
-
251
- it 'should display output' do
252
- @output.should == "(stdin):2: MeasurementTest#test: not implemented\n"
253
- end
254
- end
255
- end
256
- end
257
- end
@@ -1,357 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- shared_examples_for 'method is measured' do
6
- before do
7
- @measurements = docstring.measure
8
- end
9
-
10
- it 'should return a MeasurementSet' do
11
- @measurements.should be_kind_of(Yardstick::MeasurementSet)
12
- end
13
- end
14
-
15
- shared_examples_for 'a valid method' do
16
- before do
17
- YARD.parse_string(<<-RUBY)
18
- # This is a method summary that is the maximum --- exactly 80 characters in length
19
- #
20
- # @example
21
- # test('Hello World') # => nil
22
- #
23
- # @param [#to_str] value
24
- # the value
25
- #
26
- # @return [nil]
27
- # returns nil
28
- #
29
- # @api public
30
- def test(value)
31
- end
32
- RUBY
33
- end
34
- end
35
-
36
- describe Yardstick::Method do
37
- def docstring
38
- YARD::Registry.all(:method).first.docstring
39
- end
40
-
41
- describe '#measure' do
42
- describe 'with a method summary' do
43
- it_should_behave_like 'a valid method'
44
- it_should_behave_like 'method is measured'
45
-
46
- it 'should have a correct measurement' do
47
- @measurements.detect { |measurement| measurement.description == 'The method summary should be specified' }.should be_ok
48
- end
49
- end
50
-
51
- describe 'without a method summary' do
52
- before do
53
- YARD.parse_string('def test(value); end')
54
- end
55
-
56
- it_should_behave_like 'method is measured'
57
-
58
- it 'should have an incorrect measurement' do
59
- @measurements.detect { |measurement| measurement.description == 'The method summary should be specified' }.should_not be_ok
60
- end
61
- end
62
-
63
- describe 'with a method summary that is 80 characters in length' do
64
- it_should_behave_like 'a valid method'
65
- it_should_behave_like 'method is measured'
66
-
67
- it 'should have a correct measurement' do
68
- @measurements.detect { |measurement| measurement.description == 'The method summary should be less than 80 characters in length' }.should be_ok
69
- end
70
- end
71
-
72
- describe 'with a method summary that is 81 characters in length' do
73
- before do
74
- YARD.parse_string(<<-RUBY)
75
- # This is a method summary greater than the maximum - it is 81 characters in length
76
- def test(value)
77
- end
78
- RUBY
79
- end
80
-
81
- it_should_behave_like 'method is measured'
82
-
83
- it 'should have an incorrect measurement' do
84
- @measurements.detect { |measurement| measurement.description == 'The method summary should be less than 80 characters in length' }.should_not be_ok
85
- end
86
- end
87
-
88
- describe 'with a method summary that does not end in a period' do
89
- it_should_behave_like 'a valid method'
90
- it_should_behave_like 'method is measured'
91
-
92
- it 'should have a correct measurement' do
93
- @measurements.detect { |measurement| measurement.description == 'The method summary should not end in a period' }.should be_ok
94
- end
95
- end
96
-
97
- describe 'with a method summary that does end in a period' do
98
- before do
99
- YARD.parse_string(<<-RUBY)
100
- # This method summary ends in a period.
101
- def test(value)
102
- end
103
- RUBY
104
- end
105
-
106
- it_should_behave_like 'method is measured'
107
-
108
- it 'should have an incorrect measurement' do
109
- @measurements.detect { |measurement| measurement.description == 'The method summary should not end in a period' }.should_not be_ok
110
- end
111
- end
112
-
113
- describe 'with a method summary that is on one line' do
114
- it_should_behave_like 'a valid method'
115
- it_should_behave_like 'method is measured'
116
-
117
- it 'should have a correct measurement' do
118
- @measurements.detect { |measurement| measurement.description == 'The method summary should be a single line' }.should be_ok
119
- end
120
- end
121
-
122
- describe 'with a method summary that is not on one line' do
123
- before do
124
- YARD.parse_string(<<-RUBY)
125
- # This method summary
126
- # is on two lines
127
- def test(value)
128
- end
129
- RUBY
130
- end
131
-
132
- it_should_behave_like 'method is measured'
133
-
134
- it 'should have an incorrect measurement' do
135
- @measurements.detect { |measurement| measurement.description == 'The method summary should be a single line' }.should_not be_ok
136
- end
137
- end
138
-
139
- describe 'with a method that has an @example tag' do
140
- it_should_behave_like 'a valid method'
141
- it_should_behave_like 'method is measured'
142
-
143
- it 'should have a correct measurement' do
144
- @measurements.detect { |measurement| measurement.description == 'The public/semipublic method should have an example specified' }.should be_ok
145
- end
146
- end
147
-
148
- describe 'with a method that is private' do
149
- before do
150
- YARD.parse_string(<<-RUBY)
151
- # @api private
152
- def test(value)
153
- end
154
- RUBY
155
- end
156
-
157
- it_should_behave_like 'method is measured'
158
-
159
- it 'should be skipped' do
160
- @measurements.detect { |measurement| measurement.description == 'The public/semipublic method should have an example specified' }.should be_skip
161
- end
162
- end
163
-
164
- describe 'with a method that does not have an @example tag, and has an undefined @return tag' do
165
- before do
166
- YARD.parse_string(<<-RUBY)
167
- # @return [undefined]
168
- #
169
- # @api public
170
- def test(value)
171
- end
172
- RUBY
173
- end
174
-
175
- it_should_behave_like 'method is measured'
176
-
177
- it 'should be skipped' do
178
- @measurements.detect { |measurement| measurement.description == 'The public/semipublic method should have an example specified' }.should be_skip
179
- end
180
- end
181
-
182
- describe 'with a method that has an @api tag' do
183
- it_should_behave_like 'a valid method'
184
- it_should_behave_like 'method is measured'
185
-
186
- it 'should have a correct measurement' do
187
- @measurements.detect { |measurement| measurement.description == 'The @api tag should be specified' }.should be_ok
188
- end
189
- end
190
-
191
- describe 'with a method that does not have an @api tag' do
192
- before do
193
- YARD.parse_string('def test(value); end')
194
- end
195
-
196
- it_should_behave_like 'method is measured'
197
-
198
- it 'should have an incorrect measurement' do
199
- @measurements.detect { |measurement| measurement.description == 'The @api tag should be specified' }.should_not be_ok
200
- end
201
- end
202
-
203
- describe 'with a method that has a public @api tag' do
204
- it_should_behave_like 'a valid method'
205
- it_should_behave_like 'method is measured'
206
-
207
- it 'should have a correct measurement' do
208
- @measurements.detect { |measurement| measurement.description == 'The @api tag must be either public, semipublic or private' }.should be_ok
209
- end
210
- end
211
-
212
- describe 'with a method that has an invalid @api tag' do
213
- before do
214
- YARD.parse_string(<<-RUBY)
215
- # @api invalid
216
- def test(value)
217
- end
218
- RUBY
219
- end
220
-
221
- it_should_behave_like 'method is measured'
222
-
223
- it 'should have an incorrect measurement' do
224
- @measurements.detect { |measurement| measurement.description == 'The @api tag must be either public, semipublic or private' }.should_not be_ok
225
- end
226
- end
227
-
228
- describe 'with a protected method and a semipublic @api tag' do
229
- before do
230
- YARD.parse_string(<<-RUBY)
231
- protected
232
-
233
- # @api semipublic
234
- def test(value)
235
- end
236
- RUBY
237
- end
238
-
239
- it_should_behave_like 'method is measured'
240
-
241
- it 'should have a correct measurement' do
242
- @measurements.detect { |measurement| measurement.description == 'A method with protected visibility must have an @api tag of semipublic or private' }.should be_ok
243
- end
244
- end
245
-
246
- describe 'with a protected method and a private @api tag' do
247
- before do
248
- YARD.parse_string(<<-RUBY)
249
- protected
250
-
251
- # @api private
252
- def test(value)
253
- end
254
- RUBY
255
- end
256
-
257
- it_should_behave_like 'method is measured'
258
-
259
- it 'should have a correct measurement' do
260
- @measurements.detect { |measurement| measurement.description == 'A method with protected visibility must have an @api tag of semipublic or private' }.should be_ok
261
- end
262
- end
263
-
264
- describe 'with a protected method and a public @api tag' do
265
- before do
266
- YARD.parse_string(<<-RUBY)
267
- protected
268
-
269
- # @api public
270
- def test(value)
271
- end
272
- RUBY
273
- end
274
-
275
- it_should_behave_like 'method is measured'
276
-
277
- it 'should have an incorrect measurement' do
278
- @measurements.detect { |measurement| measurement.description == 'A method with protected visibility must have an @api tag of semipublic or private' }.should_not be_ok
279
- end
280
- end
281
-
282
- describe 'with a private method and a private @api tag' do
283
- before do
284
- YARD.parse_string(<<-RUBY)
285
- private
286
-
287
- # @api private
288
- def test(value)
289
- end
290
- RUBY
291
- end
292
-
293
- it_should_behave_like 'method is measured'
294
-
295
- it 'should have a correct measurement' do
296
- @measurements.detect { |measurement| measurement.description == 'A method with private visibility must have an @api tag of private' }.should be_ok
297
- end
298
- end
299
-
300
- describe 'with a private method and a public @api tag' do
301
- before do
302
- YARD.parse_string(<<-RUBY)
303
- private
304
-
305
- # @api public
306
- def test(value)
307
- end
308
- RUBY
309
- end
310
-
311
- it_should_behave_like 'method is measured'
312
-
313
- it 'should have an incorrect measurement' do
314
- @measurements.detect { |measurement| measurement.description == 'A method with private visibility must have an @api tag of private' }.should_not be_ok
315
- end
316
- end
317
-
318
- describe 'with a private method and a semipublic @api tag' do
319
- before do
320
- YARD.parse_string(<<-RUBY)
321
- private
322
-
323
- # @api semipublic
324
- def test(value)
325
- end
326
- RUBY
327
- end
328
-
329
- it_should_behave_like 'method is measured'
330
-
331
- it 'should have an incorrect measurement' do
332
- @measurements.detect { |measurement| measurement.description == 'A method with private visibility must have an @api tag of private' }.should_not be_ok
333
- end
334
- end
335
-
336
- describe 'with a method that has a @return tag' do
337
- it_should_behave_like 'a valid method'
338
- it_should_behave_like 'method is measured'
339
-
340
- it 'should have a correct measurement' do
341
- @measurements.detect { |measurement| measurement.description == 'The @return tag should be specified' }.should be_ok
342
- end
343
- end
344
-
345
- describe 'with a method that does not have a @return tag' do
346
- before do
347
- YARD.parse_string('def test(value); end')
348
- end
349
-
350
- it_should_behave_like 'method is measured'
351
-
352
- it 'should have an incorrect measurement' do
353
- @measurements.detect { |measurement| measurement.description == 'The @return tag should be specified' }.should_not be_ok
354
- end
355
- end
356
- end
357
- end