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,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Config, '#output=' do
|
6
|
+
subject { config.output = output }
|
7
|
+
|
8
|
+
let(:config) { described_class.new }
|
9
|
+
let(:path) { 'tmp/*.rb' }
|
10
|
+
|
11
|
+
before { config.output = path }
|
12
|
+
|
13
|
+
context 'output' do
|
14
|
+
subject { config.output }
|
15
|
+
|
16
|
+
it { should be_a(Yardstick::ReportOutput) }
|
17
|
+
|
18
|
+
its(:to_s) { should == 'tmp/*.rb' }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Config, '#require_exact_threshold?' do
|
6
|
+
subject { described_class.new(config).require_exact_threshold? }
|
7
|
+
|
8
|
+
context 'when set to true' do
|
9
|
+
let(:config) { { require_exact_threshold: true } }
|
10
|
+
|
11
|
+
it { should be(true) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when set to false' do
|
15
|
+
let(:config) { { require_exact_threshold: false } }
|
16
|
+
|
17
|
+
it { should be(false) }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Config, '#require_exact_threshold=' do
|
6
|
+
subject { described_class.new }
|
7
|
+
|
8
|
+
context 'when argument is true' do
|
9
|
+
before { subject.require_exact_threshold = true }
|
10
|
+
|
11
|
+
its(:require_exact_threshold?) { should be(true) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when argument is false' do
|
15
|
+
before { subject.require_exact_threshold = false }
|
16
|
+
|
17
|
+
its(:require_exact_threshold?) { should be(false) }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Config, '#set_defaults' do
|
6
|
+
subject { described_class.new(options) }
|
7
|
+
|
8
|
+
context 'when without options' do
|
9
|
+
let(:options) { {} }
|
10
|
+
|
11
|
+
its(:threshold) { should be(100) }
|
12
|
+
|
13
|
+
its(:verbose?) { should be(true) }
|
14
|
+
|
15
|
+
its(:path) { should eq('lib/**/*.rb') }
|
16
|
+
|
17
|
+
its(:require_exact_threshold?) { should be(true) }
|
18
|
+
|
19
|
+
it 'sets rules to empty hash' do
|
20
|
+
expect(subject.instance_variable_get(:@rules)).to eq({})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when with options' do
|
25
|
+
let(:options) do
|
26
|
+
{
|
27
|
+
threshold: 15,
|
28
|
+
verbose: false,
|
29
|
+
path: 'tmp/*.rb',
|
30
|
+
require_exact_threshold: false
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
its(:threshold) { should be(15) }
|
35
|
+
|
36
|
+
its(:verbose?) { should be(false) }
|
37
|
+
|
38
|
+
its(:path) { should eq('tmp/*.rb') }
|
39
|
+
|
40
|
+
its(:require_exact_threshold?) { should be(false) }
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Config, '#threshold=' do
|
6
|
+
subject { described_class.new }
|
7
|
+
|
8
|
+
let(:new_threshold) { 34 }
|
9
|
+
|
10
|
+
before do
|
11
|
+
subject.threshold = new_threshold
|
12
|
+
end
|
13
|
+
|
14
|
+
its(:threshold) { should be(new_threshold) }
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Config, '#verbose?' do
|
6
|
+
subject { described_class.new(config).verbose? }
|
7
|
+
|
8
|
+
context 'when set to true' do
|
9
|
+
let(:config) { { verbose: true } }
|
10
|
+
|
11
|
+
it { should be(true) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when set to false' do
|
15
|
+
let(:config) { { verbose: false } }
|
16
|
+
|
17
|
+
it { should be(false) }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Config, '#verbose=' do
|
6
|
+
subject { described_class.new }
|
7
|
+
|
8
|
+
context 'when argument is true' do
|
9
|
+
before { subject.verbose = true }
|
10
|
+
|
11
|
+
it { should be_verbose }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when argument is false' do
|
15
|
+
before { subject.verbose = false }
|
16
|
+
|
17
|
+
it { should_not be_verbose }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#api?' do
|
6
|
+
subject { described_class.new(docstring).api?(types) }
|
7
|
+
|
8
|
+
let(:docstring) { double('docstring') }
|
9
|
+
|
10
|
+
before do
|
11
|
+
docstring.stub(:tag).with('api') { double(text: 'private') }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when tag is equal' do
|
15
|
+
let(:types) { ['private'] }
|
16
|
+
|
17
|
+
it { should be(true) }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when tag is not equal' do
|
21
|
+
let(:types) { ['public'] }
|
22
|
+
|
23
|
+
it { should be(false) }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '.measure' do
|
6
|
+
subject { described_class.measure(document, config) }
|
7
|
+
|
8
|
+
let(:config) { Yardstick::Config.new }
|
9
|
+
let(:document) { double('document') }
|
10
|
+
|
11
|
+
let(:registered_rules) do
|
12
|
+
described_class.instance_variable_get(:@registered_rules)
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
registered_rules.each do |rule_class|
|
17
|
+
rule_class.should_receive(:coerce).with(document, config)
|
18
|
+
.and_return(ValidRule.new(document))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it { should be_a(Yardstick::MeasurementSet) }
|
23
|
+
|
24
|
+
its(:first) { should be_a(Yardstick::Measurement) }
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '.register_rule' do
|
6
|
+
subject { described_class.register_rule(rule_class) }
|
7
|
+
|
8
|
+
let(:rule_class) { Class.new }
|
9
|
+
let(:rule_classes) { described_class.registered_rules }
|
10
|
+
|
11
|
+
after do
|
12
|
+
rule_classes.delete(rule_class)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'adds rule_class to registered_rules' do
|
16
|
+
subject
|
17
|
+
expect(rule_classes).to include(rule_class)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#file' do
|
6
|
+
subject { described_class.new(docstring).file }
|
7
|
+
|
8
|
+
let(:docstring) { double('docstring', object: object) }
|
9
|
+
let(:object) { double('object', file: '/foo/bar.rb') }
|
10
|
+
|
11
|
+
it { should be_kind_of(Pathname) }
|
12
|
+
|
13
|
+
its(:to_s) { should == '/foo/bar.rb' }
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#has_tag?' do
|
6
|
+
subject { described_class.new(docstring).has_tag?(name) }
|
7
|
+
|
8
|
+
let(:docstring) { double('docstring') }
|
9
|
+
let(:name) { 'tag name' }
|
10
|
+
|
11
|
+
it 'delegates to docstring' do
|
12
|
+
docstring.should_receive(:has_tag?).with(name)
|
13
|
+
subject
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#line' do
|
6
|
+
subject { described_class.new(docstring).line }
|
7
|
+
|
8
|
+
let(:docstring) { double('docstring', object: object) }
|
9
|
+
let(:object) { double('object', line: 3) }
|
10
|
+
|
11
|
+
it { should be(3) }
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#path' do
|
6
|
+
subject { described_class.new(docstring).path }
|
7
|
+
|
8
|
+
let(:docstring) { double('docstring', object: object) }
|
9
|
+
let(:object) { double('object', path: 'Foo#bar') }
|
10
|
+
|
11
|
+
it { should eq('Foo#bar') }
|
12
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#summary_text' do
|
6
|
+
subject { described_class.new(docstring).summary_text }
|
7
|
+
|
8
|
+
context 'when with summary' do
|
9
|
+
let(:docstring) do
|
10
|
+
"This is a method summary\n\nThis is a method body"
|
11
|
+
end
|
12
|
+
|
13
|
+
it { should eq('This is a method summary') }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when without summary' do
|
17
|
+
let(:docstring) do
|
18
|
+
"\n\nThis is a method body"
|
19
|
+
end
|
20
|
+
|
21
|
+
it { should eq('') }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#tag_text' do
|
6
|
+
subject { described_class.new(docstring).tag_text(name) }
|
7
|
+
|
8
|
+
let(:name) { 'api' }
|
9
|
+
let(:docstring) { double('docstring') }
|
10
|
+
let(:yard_tag) { double(text: 'private') }
|
11
|
+
|
12
|
+
before do
|
13
|
+
docstring.stub(:tag).with(name) { yard_tag }
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should eq('private') }
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#tag_types' do
|
6
|
+
subject { described_class.new(docstring).tag_types(name) }
|
7
|
+
|
8
|
+
let(:name) { 'tag name' }
|
9
|
+
let(:docstring) { double('docstring') }
|
10
|
+
let(:yard_tag) { double(types: types) }
|
11
|
+
let(:types) { %w[type1 type2] }
|
12
|
+
|
13
|
+
before do
|
14
|
+
docstring.stub(:tag).with(name) { yard_tag }
|
15
|
+
end
|
16
|
+
|
17
|
+
it { should be(types) }
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Document, '#visibility' do
|
6
|
+
subject { described_class.new(docstring).visibility }
|
7
|
+
|
8
|
+
let(:docstring) { double('docstring', object: object) }
|
9
|
+
let(:object) { double('object', visibility: visibility) }
|
10
|
+
|
11
|
+
context 'when true' do
|
12
|
+
let(:visibility) { true }
|
13
|
+
|
14
|
+
it { should be(true) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when false' do
|
18
|
+
let(:visibility) { false }
|
19
|
+
|
20
|
+
it { should be(false) }
|
21
|
+
end
|
22
|
+
end
|