yardstick 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +4 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +11 -16
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +3 -59
- data/Gemfile.devtools +54 -0
- data/Guardfile +32 -0
- data/LICENSE +1 -1
- data/README.md +71 -55
- data/Rakefile +2 -7
- data/TODO +12 -0
- data/bin/yardstick +1 -0
- data/config/devtools.yml +2 -0
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/mutant.yml +3 -0
- data/config/{site.reek → reek.yml} +31 -25
- data/config/rubocop.yml +49 -0
- data/config/yardstick.yml +31 -0
- data/lib/yardstick.rb +35 -15
- data/lib/yardstick/cli.rb +7 -7
- data/lib/yardstick/config.rb +176 -0
- data/lib/yardstick/document.rb +215 -0
- data/lib/yardstick/document_set.rb +21 -0
- data/lib/yardstick/measurement.rb +18 -145
- data/lib/yardstick/measurement_set.rb +2 -2
- data/lib/yardstick/parser.rb +61 -0
- data/lib/yardstick/processor.rb +21 -35
- data/lib/yardstick/rake/measurement.rb +7 -49
- data/lib/yardstick/rake/verify.rb +28 -55
- data/lib/yardstick/report_output.rb +57 -0
- data/lib/yardstick/rule.rb +64 -37
- data/lib/yardstick/rule_config.rb +56 -0
- data/lib/yardstick/rules/api_tag.rb +95 -0
- data/lib/yardstick/rules/example_tag.rb +33 -0
- data/lib/yardstick/rules/return_tag.rb +21 -0
- data/lib/yardstick/rules/summary.rb +87 -0
- data/lib/yardstick/version.rb +1 -1
- data/lib/yardstick/yard_ext.rb +1 -6
- data/spec/integration/yardstick/class_methods/measure_spec.rb +22 -0
- data/spec/integration/yardstick/class_methods/measure_string_spec.rb +20 -0
- data/spec/integration/yardstick/document/file_spec.rb +16 -0
- data/spec/integration/yardstick/document/line_spec.rb +25 -0
- data/spec/integration/yardstick/document/path_spec.rb +45 -0
- data/spec/integration/yardstick/processor/process_string_spec.rb +401 -0
- data/spec/integration/yardstick/rake/measurement_spec.rb +22 -0
- data/spec/integration/yardstick/rake/verify_spec.rb +19 -0
- data/spec/shared/measured_itself_behavior.rb +15 -0
- data/spec/spec_helper.rb +13 -26
- data/spec/support/document_mock.rb +16 -0
- data/spec/support/rules.rb +51 -0
- data/spec/unit/yardstick/class_methods/measure_spec.rb +31 -0
- data/spec/unit/yardstick/class_methods/measure_string_spec.rb +33 -0
- data/spec/unit/yardstick/cli_spec.rb +11 -8
- data/spec/unit/yardstick/config/class_methods/coerce_spec.rb +32 -0
- data/spec/unit/yardstick/config/for_rule_spec.rb +47 -0
- data/spec/unit/yardstick/config/initialize_spec.rb +21 -0
- data/spec/unit/yardstick/config/output_spec.rb +15 -0
- data/spec/unit/yardstick/config/output_writer_spec.rb +20 -0
- data/spec/unit/yardstick/config/path_spec.rb +13 -0
- data/spec/unit/yardstick/config/path_writer_spec.rb +11 -0
- data/spec/unit/yardstick/config/require_exact_threshold_predicate_spec.rb +19 -0
- data/spec/unit/yardstick/config/require_exact_threshold_writer_spec.rb +19 -0
- data/spec/unit/yardstick/config/set_defaults_spec.rb +42 -0
- data/spec/unit/yardstick/config/threshold_writer_spec.rb +15 -0
- data/spec/unit/yardstick/config/verbose_predicate_spec.rb +19 -0
- data/spec/unit/yardstick/config/verbose_writer_spec.rb +19 -0
- data/spec/unit/yardstick/document/api_predicate_spec.rb +25 -0
- data/spec/unit/yardstick/document/class_methods/measure_spec.rb +25 -0
- data/spec/unit/yardstick/document/class_methods/register_rule_spec.rb +19 -0
- data/spec/unit/yardstick/document/class_methods/registered_rules_spec.rb +9 -0
- data/spec/unit/yardstick/document/docstring_spec.rb +11 -0
- data/spec/unit/yardstick/document/file_spec.rb +14 -0
- data/spec/unit/yardstick/document/has_tag_predicate_spec.rb +15 -0
- data/spec/unit/yardstick/document/line_spec.rb +12 -0
- data/spec/unit/yardstick/document/null_tag/text_spec.rb +9 -0
- data/spec/unit/yardstick/document/null_tag/types_spec.rb +9 -0
- data/spec/unit/yardstick/document/path_spec.rb +12 -0
- data/spec/unit/yardstick/document/summary_text_spec.rb +23 -0
- data/spec/unit/yardstick/document/tag_text_spec.rb +17 -0
- data/spec/unit/yardstick/document/tag_types_spec.rb +18 -0
- data/spec/unit/yardstick/document/visibility_spec.rb +22 -0
- data/spec/unit/yardstick/document_set/measure_spec.rb +28 -0
- data/spec/unit/yardstick/measurement/description_spec.rb +12 -0
- data/spec/unit/yardstick/measurement/initialize_spec.rb +12 -0
- data/spec/unit/yardstick/measurement/ok_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/measurement/puts_spec.rb +62 -0
- data/spec/unit/yardstick/measurement/skip_predicate_spec.rb +27 -0
- data/spec/unit/yardstick/measurement_set/coverage_spec.rb +23 -0
- data/spec/unit/yardstick/measurement_set/failed_spec.rb +28 -0
- data/spec/unit/yardstick/measurement_set/initialize_spec.rb +27 -0
- data/spec/unit/yardstick/measurement_set/puts_spec.rb +63 -0
- data/spec/unit/yardstick/measurement_set/successful_spec.rb +13 -0
- data/spec/unit/yardstick/measurement_set/total_spec.rb +12 -0
- data/spec/unit/yardstick/ordered_set/each_spec.rb +18 -0
- data/spec/unit/yardstick/ordered_set/empty_predicate_spec.rb +19 -0
- data/spec/unit/yardstick/ordered_set/include_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/ordered_set/index_spec.rb +21 -0
- data/spec/unit/yardstick/ordered_set/left_shift_operator_spec.rb +16 -0
- data/spec/unit/yardstick/ordered_set/length_spec.rb +11 -0
- data/spec/unit/yardstick/ordered_set/merge_spec.rb +16 -0
- data/spec/unit/yardstick/parser/class_methods/parse_paths_spec.rb +28 -0
- data/spec/unit/yardstick/parser/class_methods/parse_string_spec.rb +28 -0
- data/spec/unit/yardstick/processor/process_spec.rb +17 -0
- data/spec/unit/yardstick/processor/process_string_spec.rb +17 -0
- data/spec/unit/yardstick/rake/measurement/initialize_spec.rb +64 -0
- data/spec/unit/yardstick/rake/measurement/yardstick_measure_spec.rb +22 -0
- data/spec/unit/yardstick/rake/verify/initialize_spec.rb +72 -0
- data/spec/unit/yardstick/rake/verify/verify_measurements_spec.rb +85 -0
- data/spec/unit/yardstick/report_output/class_methods/coerce_spec.rb +18 -0
- data/spec/unit/yardstick/report_output/initialize_spec.rb +11 -0
- data/spec/unit/yardstick/report_output/to_s_spec.rb +12 -0
- data/spec/unit/yardstick/report_output/write_spec.rb +31 -0
- data/spec/unit/yardstick/round_percentage_spec.rb +9 -0
- data/spec/unit/yardstick/rule/class_methods/coerce_spec.rb +21 -0
- data/spec/unit/yardstick/rule/class_methods/inherited_spec.rb +15 -0
- data/spec/unit/yardstick/rule/enabled_predicate_spec.rb +18 -0
- data/spec/unit/yardstick/rule/initialize_spec.rb +25 -0
- data/spec/unit/yardstick/rule/validatable_predicate_spec.rb +11 -0
- data/spec/unit/yardstick/rule_config/enabled_for_path_predicate_spec.rb +41 -0
- data/spec/unit/yardstick/rule_config/initialize_spec.rb +16 -0
- data/spec/unit/yardstick/rules/api_tag/inclusion/valid_predicate_spec.rb +27 -0
- data/spec/unit/yardstick/rules/api_tag/presence/valid_predicate_spec.rb +25 -0
- data/spec/unit/yardstick/rules/api_tag/private_method/valid_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/rules/api_tag/private_method/validatable_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/rules/api_tag/protected_method/valid_predicate_spec.rb +25 -0
- data/spec/unit/yardstick/rules/api_tag/protected_method/validatable_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/rules/example_tag/valid_predicate_spec.rb +25 -0
- data/spec/unit/yardstick/rules/example_tag/validatable_predicate_spec.rb +32 -0
- data/spec/unit/yardstick/rules/return_tag/valid_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/rules/summary/delimiter/valid_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/rules/summary/length/valid_predicate_spec.rb +27 -0
- data/spec/unit/yardstick/rules/summary/presence/valid_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/rules/summary/presence/validatable_predicate_spec.rb +21 -0
- data/spec/unit/yardstick/rules/summary/single_line/valid_predicate_spec.rb +21 -0
- data/yardstick.gemspec +7 -11
- metadata +222 -65
- data/.rvmrc +0 -1
- data/lib/yardstick/measurable.rb +0 -67
- data/lib/yardstick/method.rb +0 -113
- data/lib/yardstick/rule_set.rb +0 -22
- data/spec/support/config_alias.rb +0 -5
- data/spec/unit/yardstick/measurement_set_spec.rb +0 -266
- data/spec/unit/yardstick/measurement_spec.rb +0 -257
- data/spec/unit/yardstick/method_spec.rb +0 -357
- data/spec/unit/yardstick/rake/measurement_spec.rb +0 -175
- data/spec/unit/yardstick/rake/verify_spec.rb +0 -231
- data/spec/unit/yardstick/rule_spec.rb +0 -36
- data/spec/unit/yardstick_spec.rb +0 -71
- data/tasks/metrics/ci.rake +0 -9
- data/tasks/metrics/flay.rake +0 -53
- data/tasks/metrics/flog.rake +0 -44
- data/tasks/metrics/heckle.rake +0 -52
- data/tasks/metrics/metric_fu.rake +0 -31
- data/tasks/metrics/reek.rake +0 -21
- data/tasks/metrics/roodi.rake +0 -19
- data/tasks/metrics/yardstick.rake +0 -27
- data/tasks/spec.rake +0 -64
- data/tasks/yard.rake +0 -11
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rule, '.coerce' do
|
6
|
+
subject { described_class.coerce(document, config) }
|
7
|
+
|
8
|
+
let(:document) { DocumentMock.new }
|
9
|
+
let(:config) { double('config') }
|
10
|
+
let(:rule_config) { Yardstick::RuleConfig.new(enabled: false) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
config.stub(:for_rule).with(described_class) { rule_config }
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should be_a(described_class) }
|
17
|
+
|
18
|
+
it { should_not be_enabled }
|
19
|
+
|
20
|
+
its(:document) { should be(document) }
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rule, '.inherited' do
|
6
|
+
let(:subclass) { Class.new(Yardstick::Rule) }
|
7
|
+
|
8
|
+
after do
|
9
|
+
Yardstick::Document.registered_rules.delete(subclass)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'registers rule' do
|
13
|
+
expect(Yardstick::Document.registered_rules).to include(subclass)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rule, '#enabled?' do
|
6
|
+
subject { described_class.new(document, config).enabled? }
|
7
|
+
|
8
|
+
let(:document) { double('document', path: 'Foo#bar') }
|
9
|
+
let(:config) { double('RuleConfig') }
|
10
|
+
let(:return_value) { double('Boolean') }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(config).to receive(:enabled_for_path?).with('Foo#bar')
|
14
|
+
.and_return(return_value)
|
15
|
+
end
|
16
|
+
|
17
|
+
it { should eq(return_value) }
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rule, '#initialize' do
|
6
|
+
let(:document) { DocumentMock.new }
|
7
|
+
|
8
|
+
context 'when rule config not given' do
|
9
|
+
subject { described_class.new(document) }
|
10
|
+
|
11
|
+
it { should be_a(described_class) }
|
12
|
+
|
13
|
+
it { should be_enabled }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when rule config is given' do
|
17
|
+
subject { described_class.new(document, config) }
|
18
|
+
|
19
|
+
let(:config) { Yardstick::RuleConfig.new(enabled: false) }
|
20
|
+
|
21
|
+
it { should be_a(described_class) }
|
22
|
+
|
23
|
+
it { should_not be_enabled }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::RuleConfig, '#enabled_for_path?' do
|
6
|
+
subject { described_class.new(options).enabled_for_path?(path) }
|
7
|
+
|
8
|
+
let(:options) { {} }
|
9
|
+
|
10
|
+
%w[ Foo::Bar#baz Foo::Bar.baz ].each do |method|
|
11
|
+
let(:path) { method }
|
12
|
+
|
13
|
+
context 'when no restrictions' do
|
14
|
+
it { should be(true) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when disabled' do
|
18
|
+
before { options[:enabled] = false }
|
19
|
+
|
20
|
+
it { should be(false) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when excluded by exact path' do
|
24
|
+
before { options[:exclude] = [path] }
|
25
|
+
|
26
|
+
it { should be(false) }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when excluded by class or module' do
|
30
|
+
before { options[:exclude] = ['Foo::Bar'] }
|
31
|
+
|
32
|
+
it { should be(false) }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when excluded by superclass or subclass' do
|
36
|
+
before { options[:exclude] = ['Foo', 'Foo::Bar::Sub'] }
|
37
|
+
|
38
|
+
it { should be(true) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::RuleConfig, '#initialize' do
|
6
|
+
context 'when no options given' do
|
7
|
+
subject { described_class.new }
|
8
|
+
|
9
|
+
it 'does not apply restrictions' do
|
10
|
+
expect(subject.enabled_for_path?('Foo#bar')).to be(true)
|
11
|
+
|
12
|
+
# Satisfy mutant
|
13
|
+
expect(subject.instance_variable_get(:@exclude)).to eq([])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ApiTag::Inclusion, '#valid?' do
|
6
|
+
subject { described_class.new(document).valid? }
|
7
|
+
|
8
|
+
let(:document) { double('document') }
|
9
|
+
|
10
|
+
%w[public semipublic private].each do |method_visibility|
|
11
|
+
context "with #{method_visibility} method" do
|
12
|
+
before do
|
13
|
+
document.stub(:tag_text).with('api').and_return(method_visibility)
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should be(true) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with unknown method visibility' do
|
21
|
+
before do
|
22
|
+
document.stub(:tag_text).with('api').and_return('unknown')
|
23
|
+
end
|
24
|
+
|
25
|
+
it { should be(false) }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ApiTag::Presence, '#valid?' do
|
6
|
+
subject { described_class.new(document).valid? }
|
7
|
+
|
8
|
+
let(:document) { double('document') }
|
9
|
+
|
10
|
+
context 'with api tag' do
|
11
|
+
before do
|
12
|
+
document.stub(:has_tag?).with('api').and_return(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it { should be(true) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'without api tag' do
|
19
|
+
before do
|
20
|
+
document.stub(:has_tag?).with('api').and_return(false)
|
21
|
+
end
|
22
|
+
|
23
|
+
it { should be(false) }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ApiTag::PrivateMethod, '#valid?' do
|
6
|
+
subject { described_class.new(document).valid? }
|
7
|
+
|
8
|
+
let(:document) { double('document') }
|
9
|
+
|
10
|
+
context 'when with protected api tag' do
|
11
|
+
before { document.stub(:api?).with(%w[ private ]).and_return(true) }
|
12
|
+
|
13
|
+
it { should be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when not protected visibility' do
|
17
|
+
before { document.stub(:api?).with(%w[ private ]).and_return(false) }
|
18
|
+
|
19
|
+
it { should be(false) }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ApiTag::PrivateMethod, '#validatable?' do
|
6
|
+
subject { described_class.new(document).validatable? }
|
7
|
+
|
8
|
+
let(:document) { double('document', visibility: visibility) }
|
9
|
+
|
10
|
+
context 'when protected visibility' do
|
11
|
+
let(:visibility) { :private }
|
12
|
+
|
13
|
+
it { should be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when not protected visibility' do
|
17
|
+
let(:visibility) { :something }
|
18
|
+
|
19
|
+
it { should be(false) }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ApiTag::ProtectedMethod, '#valid?' do
|
6
|
+
subject { described_class.new(document).valid? }
|
7
|
+
|
8
|
+
let(:document) { double('document') }
|
9
|
+
|
10
|
+
context 'when with protected api tag' do
|
11
|
+
before do
|
12
|
+
document.stub(:api?).with(%w[ semipublic private ]).and_return(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it { should be(true) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when not protected visibility' do
|
19
|
+
before do
|
20
|
+
document.stub(:api?).with(%w[semipublic private]).and_return(false)
|
21
|
+
end
|
22
|
+
|
23
|
+
it { should be(false) }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ApiTag::ProtectedMethod, '#validatable?' do
|
6
|
+
subject { described_class.new(document).validatable? }
|
7
|
+
|
8
|
+
let(:document) { double('document', visibility: visibility) }
|
9
|
+
|
10
|
+
context 'when protected visibility' do
|
11
|
+
let(:visibility) { :protected }
|
12
|
+
|
13
|
+
it { should be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when not protected visibility' do
|
17
|
+
let(:visibility) { :something }
|
18
|
+
|
19
|
+
it { should be(false) }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ExampleTag, '#valid?' do
|
6
|
+
subject { described_class.new(document).valid? }
|
7
|
+
|
8
|
+
let(:document) { double('document') }
|
9
|
+
|
10
|
+
context 'with example tag' do
|
11
|
+
before do
|
12
|
+
document.stub(:has_tag?).with('example').and_return(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it { should be(true) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'without example tag' do
|
19
|
+
before do
|
20
|
+
document.stub(:has_tag?).with('example').and_return(false)
|
21
|
+
end
|
22
|
+
|
23
|
+
it { should be(false) }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ExampleTag, '#validatable?' do
|
6
|
+
subject { described_class.new(document).validatable? }
|
7
|
+
|
8
|
+
let(:document) { double('document') }
|
9
|
+
|
10
|
+
before do
|
11
|
+
document.stub(:api?).with(['private']) { false }
|
12
|
+
document.stub(:tag_types).with('return') { %w[Object] }
|
13
|
+
end
|
14
|
+
|
15
|
+
it { should be(true) }
|
16
|
+
|
17
|
+
context 'with private api' do
|
18
|
+
before do
|
19
|
+
document.stub(:api?).with(['private']).and_return(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
it { should be(false) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with undefined return' do
|
26
|
+
before do
|
27
|
+
document.stub(:tag_types).with('return').and_return(['undefined'])
|
28
|
+
end
|
29
|
+
|
30
|
+
it { should be(false) }
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::ReturnTag, '#valid?' do
|
6
|
+
subject { described_class.new(document).valid? }
|
7
|
+
|
8
|
+
let(:document) { double('document') }
|
9
|
+
|
10
|
+
context 'when with protected api tag' do
|
11
|
+
before { document.stub(:has_tag?).with('return').and_return(true) }
|
12
|
+
|
13
|
+
it { should be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when not protected visibility' do
|
17
|
+
before { document.stub(:has_tag?).with('return').and_return(false) }
|
18
|
+
|
19
|
+
it { should be(false) }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::Summary::Delimiter, '#valid?' do
|
6
|
+
subject { described_class.new(document).valid? }
|
7
|
+
|
8
|
+
let(:document) { double('document', summary_text: text) }
|
9
|
+
|
10
|
+
context 'without a dot' do
|
11
|
+
let(:text) { 'A summary' }
|
12
|
+
|
13
|
+
it { should be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with a dot' do
|
17
|
+
let(:text) { 'A summary.' }
|
18
|
+
|
19
|
+
it { should be(false) }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Rules::Summary::Length, '#valid?' do
|
6
|
+
subject { described_class.new(document).valid? }
|
7
|
+
|
8
|
+
let(:document) { double('document', summary_text: text) }
|
9
|
+
|
10
|
+
context 'with short summary' do
|
11
|
+
let(:text) { 'A summary' }
|
12
|
+
|
13
|
+
it { should be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with short summary that includes umlauts' do
|
17
|
+
let(:text) { 'ö' * 79 }
|
18
|
+
|
19
|
+
it { should be(true) }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with too long summary' do
|
23
|
+
let(:text) { 'a' * 81 }
|
24
|
+
|
25
|
+
it { should be(false) }
|
26
|
+
end
|
27
|
+
end
|