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,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::DocumentSet, '#measure' do
|
6
|
+
subject { described_class.new([document1, document2]).measure(config) }
|
7
|
+
|
8
|
+
let(:document1) { double('document1') }
|
9
|
+
let(:document2) { double('document2') }
|
10
|
+
let(:config) { double('config') }
|
11
|
+
|
12
|
+
let(:measurement1) { double('measurement') }
|
13
|
+
let(:measurement2) { double('measurement') }
|
14
|
+
|
15
|
+
before do
|
16
|
+
Yardstick::Document.should_receive(:measure).with(document1, config)
|
17
|
+
.and_return(Yardstick::MeasurementSet.new([measurement1]))
|
18
|
+
|
19
|
+
Yardstick::Document.should_receive(:measure).with(document2, config)
|
20
|
+
.and_return(Yardstick::MeasurementSet.new([measurement2]))
|
21
|
+
end
|
22
|
+
|
23
|
+
it { should be_a(Yardstick::MeasurementSet) }
|
24
|
+
|
25
|
+
it { should include(measurement1, measurement2) }
|
26
|
+
|
27
|
+
its(:length) { should be(2) }
|
28
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Measurement, '#description' do
|
6
|
+
subject { described_class.new(rule).description }
|
7
|
+
|
8
|
+
let(:rule) { ValidRule.new(document) }
|
9
|
+
let(:document) { DocumentMock.new }
|
10
|
+
|
11
|
+
it { should == ValidRule.description }
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Measurement, '#initialize' do
|
6
|
+
subject { described_class.new(rule) }
|
7
|
+
|
8
|
+
let(:rule) { ValidRule.new(document) }
|
9
|
+
let(:document) { DocumentMock.new }
|
10
|
+
|
11
|
+
it { should be_kind_of(described_class) }
|
12
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Measurement, 'ok?' do
|
6
|
+
subject { described_class.new(rule).ok? }
|
7
|
+
|
8
|
+
let(:document) { DocumentMock.new }
|
9
|
+
|
10
|
+
context 'when rule is valid' do
|
11
|
+
let(:rule) { ValidRule.new(document) }
|
12
|
+
|
13
|
+
it { should be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when rule is not valid' do
|
17
|
+
let(:rule) { InvalidRule.new(document) }
|
18
|
+
|
19
|
+
it { should be(false) }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Measurement, '#puts' do
|
6
|
+
let(:document) { DocumentMock.new }
|
7
|
+
|
8
|
+
describe 'with no arguments' do
|
9
|
+
subject { @output }
|
10
|
+
|
11
|
+
before do
|
12
|
+
capture_stdout { described_class.new(rule).puts }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'when the measurement is successful' do
|
16
|
+
let(:rule) { ValidRule.new(document) }
|
17
|
+
|
18
|
+
it { should == '' }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'when the measurement is skipped' do
|
22
|
+
let(:rule) { NotValidatableRule.new(document) }
|
23
|
+
|
24
|
+
it { should == '' }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'when the measurement is not successful' do
|
28
|
+
let(:rule) { InvalidRule.new(document) }
|
29
|
+
|
30
|
+
it { should == "(stdin):2: Foo#bar: not successful\n" }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'with an object implementing #puts' do
|
35
|
+
subject { io.read }
|
36
|
+
|
37
|
+
let(:io) { StringIO.new }
|
38
|
+
|
39
|
+
before do
|
40
|
+
described_class.new(rule).puts(io)
|
41
|
+
io.rewind
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'when the measurement is successful' do
|
45
|
+
let(:rule) { ValidRule.new(document) }
|
46
|
+
|
47
|
+
it { should == '' }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'when the measurement is skipped' do
|
51
|
+
let(:rule) { NotValidatableRule.new(document) }
|
52
|
+
|
53
|
+
it { should == '' }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'when the measurement is not successful' do
|
57
|
+
let(:rule) { InvalidRule.new(document) }
|
58
|
+
|
59
|
+
it { should == "(stdin):2: Foo#bar: not successful\n" }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::Measurement, 'skip?' do
|
6
|
+
subject { described_class.new(rule).skip? }
|
7
|
+
|
8
|
+
let(:document) { DocumentMock.new }
|
9
|
+
|
10
|
+
context 'when rule is enabled' do
|
11
|
+
let(:rule) { ValidRule.new(document) }
|
12
|
+
|
13
|
+
it { should be(false) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when rule is not validatable' do
|
17
|
+
let(:rule) { NotValidatableRule.new(document) }
|
18
|
+
|
19
|
+
it { should be(true) }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when rule is disabled' do
|
23
|
+
let(:rule) { DisabledRule.new(document) }
|
24
|
+
|
25
|
+
it { should be(true) }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::MeasurementSet, '#coverage' do
|
6
|
+
subject { set.coverage }
|
7
|
+
|
8
|
+
context 'when there are no measurements' do
|
9
|
+
let(:set) { described_class.new }
|
10
|
+
|
11
|
+
it { should be(1) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when there are measurements' do
|
15
|
+
let(:set) { described_class.new([measurement1, measurement2]) }
|
16
|
+
let(:measurement1) { double('measurement', :ok? => true) }
|
17
|
+
let(:measurement2) { double('measurement', :ok? => false) }
|
18
|
+
|
19
|
+
it { should be_a(Rational) }
|
20
|
+
|
21
|
+
it { should eq(0.5) }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::MeasurementSet, '#failed' do
|
6
|
+
subject { set.failed }
|
7
|
+
|
8
|
+
context 'when no failed measurements' do
|
9
|
+
let(:set) { described_class.new }
|
10
|
+
|
11
|
+
it { should be(0) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when a failed measurement' do
|
15
|
+
let(:set) { described_class.new([measurement]) }
|
16
|
+
let(:measurement) { double('measurement', :ok? => false) }
|
17
|
+
|
18
|
+
it { should be(1) }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when a failed measurement with a successful measurement' do
|
22
|
+
let(:set) { described_class.new([measurement1, measurement2]) }
|
23
|
+
let(:measurement1) { double('measurement', :ok? => false) }
|
24
|
+
let(:measurement2) { double('measurement', :ok? => true) }
|
25
|
+
|
26
|
+
it { should be(1) }
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::MeasurementSet, '#initialize' do
|
6
|
+
context 'with no arguments' do
|
7
|
+
subject { described_class.new }
|
8
|
+
|
9
|
+
it { should be_a(Yardstick::MeasurementSet) }
|
10
|
+
|
11
|
+
it { should be_a(Enumerable) }
|
12
|
+
|
13
|
+
it { should be_empty }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with measurements' do
|
17
|
+
subject { described_class.new([measurement]) }
|
18
|
+
|
19
|
+
let(:measurement) { double('measurement') }
|
20
|
+
|
21
|
+
it { should be_a(Yardstick::MeasurementSet) }
|
22
|
+
|
23
|
+
it { should be_a(Enumerable) }
|
24
|
+
|
25
|
+
it { should include(measurement) }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::MeasurementSet, '#puts' do
|
6
|
+
let(:set) { described_class.new([failed, successful]) }
|
7
|
+
let(:document) { DocumentMock.new }
|
8
|
+
|
9
|
+
let(:failed) do
|
10
|
+
Class.new do
|
11
|
+
def ok?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def puts(io)
|
16
|
+
io.puts('measurement info')
|
17
|
+
end
|
18
|
+
end.new
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:successful) do
|
22
|
+
Class.new do
|
23
|
+
def ok?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def puts(io)
|
28
|
+
io.puts('measurement info')
|
29
|
+
end
|
30
|
+
end.new
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'with no arguments' do
|
34
|
+
before do
|
35
|
+
capture_stdout { set.puts }
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should output the summary' do
|
39
|
+
expect(@output).to eql([
|
40
|
+
'measurement info',
|
41
|
+
'measurement info',
|
42
|
+
"\nYARD-Coverage: 50.0% Success: 1 Failed: 1 Total: 2\n"
|
43
|
+
].join("\n"))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'with an object implementing #puts' do
|
48
|
+
before do
|
49
|
+
io = StringIO.new
|
50
|
+
set.puts(io)
|
51
|
+
io.rewind
|
52
|
+
@output = io.read
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should output the summary' do
|
56
|
+
expect(@output).to eql([
|
57
|
+
'measurement info',
|
58
|
+
'measurement info',
|
59
|
+
"\nYARD-Coverage: 50.0% Success: 1 Failed: 1 Total: 2\n",
|
60
|
+
].join("\n"))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::MeasurementSet, '#successful' do
|
6
|
+
subject { set.successful }
|
7
|
+
|
8
|
+
let(:set) { described_class.new([measurement1, measurement2]) }
|
9
|
+
let(:measurement1) { double('measurement', :ok? => true) }
|
10
|
+
let(:measurement2) { double('measurement', :ok? => false) }
|
11
|
+
|
12
|
+
it { should be(1) }
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::OrderedSet, '#each' do
|
6
|
+
subject { set.each { |*args| yielded << args } }
|
7
|
+
|
8
|
+
let(:set) { described_class.new([item]) }
|
9
|
+
let(:item) { double('item') }
|
10
|
+
let(:yielded) { [] }
|
11
|
+
|
12
|
+
it { should be(set) }
|
13
|
+
|
14
|
+
it 'should yield items' do
|
15
|
+
subject
|
16
|
+
expect(yielded).to eql([[item]])
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::OrderedSet, '#empty?' do
|
6
|
+
subject { set.empty? }
|
7
|
+
|
8
|
+
context 'when there are no items' do
|
9
|
+
let(:set) { described_class.new }
|
10
|
+
|
11
|
+
it { should be(true) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when there are items' do
|
15
|
+
let(:set) { described_class.new([double('item')]) }
|
16
|
+
|
17
|
+
it { should be(false) }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::OrderedSet, '#include?' do
|
6
|
+
subject { set.include?(item) }
|
7
|
+
|
8
|
+
let(:item) { double('item') }
|
9
|
+
|
10
|
+
context 'when provided an included item' do
|
11
|
+
let(:set) { described_class.new([item]) }
|
12
|
+
|
13
|
+
it { should be(true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when provided an excluded item' do
|
17
|
+
let(:set) { described_class.new }
|
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::OrderedSet, '#index' do
|
6
|
+
subject { set.index(item) }
|
7
|
+
|
8
|
+
let(:item) { double('item') }
|
9
|
+
|
10
|
+
context 'when provided an included item' do
|
11
|
+
let(:set) { described_class.new([item]) }
|
12
|
+
|
13
|
+
it { should be(0) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when provided an excluded item' do
|
17
|
+
let(:set) { described_class.new }
|
18
|
+
|
19
|
+
it { should be_nil }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Yardstick::OrderedSet, '#<<' do
|
6
|
+
subject { set << item }
|
7
|
+
|
8
|
+
let(:set) { described_class.new }
|
9
|
+
let(:item) { double('item') }
|
10
|
+
|
11
|
+
it { should be(set) }
|
12
|
+
|
13
|
+
it { should include(item) }
|
14
|
+
|
15
|
+
its(:length) { should be(1) }
|
16
|
+
end
|