dkubb-yardstick 0.0.1 → 0.1.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.
- data/.document +1 -1
- data/.gitignore +1 -0
- data/README.markdown +69 -0
- data/VERSION +1 -1
- data/lib/yardstick.rb +7 -7
- data/lib/yardstick/autoload.rb +9 -5
- data/lib/yardstick/cli.rb +8 -10
- data/lib/yardstick/measurable.rb +14 -31
- data/lib/yardstick/measurement.rb +38 -0
- data/lib/yardstick/measurement_set.rb +123 -0
- data/lib/yardstick/method.rb +25 -20
- data/lib/yardstick/ordered_set.rb +112 -0
- data/lib/yardstick/processor.rb +22 -24
- data/lib/yardstick/rule.rb +61 -0
- data/lib/yardstick/rule_set.rb +18 -0
- data/spec/public/yardstick/cli_spec.rb +108 -0
- data/spec/public/yardstick/measurement_set_spec.rb +247 -0
- data/spec/public/yardstick/measurement_spec.rb +23 -17
- data/spec/public/yardstick/method_spec.rb +351 -1
- data/spec/public/yardstick_spec.rb +65 -1
- data/spec/rcov.opts +4 -0
- data/spec/semipublic/yardstick/rule_spec.rb +28 -0
- data/spec/spec_helper.rb +45 -7
- data/tasks/ci.rake +1 -0
- data/tasks/heckle.rake +52 -0
- data/tasks/metrics.rake +5 -1
- data/tasks/spec.rake +3 -56
- data/yardstick.gemspec +82 -0
- metadata +17 -4
- data/README.rdoc +0 -16
@@ -2,5 +2,69 @@ require 'pathname'
|
|
2
2
|
require Pathname(__FILE__).dirname.expand_path.join('..', 'spec_helper')
|
3
3
|
|
4
4
|
describe Yardstick do
|
5
|
-
|
5
|
+
describe '.measure' do
|
6
|
+
describe 'with no arguments' do
|
7
|
+
before :all do
|
8
|
+
@measurements = Yardstick.measure
|
9
|
+
end
|
10
|
+
|
11
|
+
it_should_behave_like 'measured itself'
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'with a String path' do
|
15
|
+
before :all do
|
16
|
+
@measurements = Yardstick.measure(Yardstick::ROOT.join('lib', 'yardstick.rb').to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
it_should_behave_like 'measured itself'
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'with a Pathname' do
|
23
|
+
before :all do
|
24
|
+
@measurements = Yardstick.measure(Yardstick::ROOT.join('lib', 'yardstick.rb'))
|
25
|
+
end
|
26
|
+
|
27
|
+
it_should_behave_like 'measured itself'
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'with an Array of String objects' do
|
31
|
+
before :all do
|
32
|
+
@measurements = Yardstick.measure([ Yardstick::ROOT.join('lib', 'yardstick.rb').to_s ])
|
33
|
+
end
|
34
|
+
|
35
|
+
it_should_behave_like 'measured itself'
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'with an Array of Pathname objects' do
|
39
|
+
before :all do
|
40
|
+
@measurements = Yardstick.measure([ Yardstick::ROOT.join('lib', 'yardstick.rb') ])
|
41
|
+
end
|
42
|
+
|
43
|
+
it_should_behave_like 'measured itself'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.measure_string' do
|
48
|
+
describe 'with a String' do
|
49
|
+
before do
|
50
|
+
@measurements = Yardstick.measure_string('def test; end')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should return a MeasurementSet' do
|
54
|
+
@measurements.should be_kind_of(Yardstick::MeasurementSet)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should be non-empty' do
|
58
|
+
@measurements.should_not be_empty
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'with no arguments' do
|
63
|
+
it 'should raise an exception' do
|
64
|
+
lambda {
|
65
|
+
Yardstick.measure_string
|
66
|
+
}.should raise_error(ArgumentError, 'wrong number of arguments (0 for 1)')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
6
70
|
end
|
data/spec/rcov.opts
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require Pathname(__FILE__).dirname.expand_path.join('..', '..', 'spec_helper')
|
3
|
+
|
4
|
+
describe Yardstick::Rule do
|
5
|
+
describe '#eql?' do
|
6
|
+
describe 'when rules are equal' do
|
7
|
+
before do
|
8
|
+
@rule = Yardstick::Rule.new('test rule') { true }
|
9
|
+
@other = Yardstick::Rule.new('test rule') { true }
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should return true' do
|
13
|
+
@rule.eql?(@other).should be_true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'when rules are not equal' do
|
18
|
+
before do
|
19
|
+
@rule = Yardstick::Rule.new('test rule') { true }
|
20
|
+
@other = Yardstick::Rule.new('other rule') { true }
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return false' do
|
24
|
+
@rule.eql?(@other).should be_false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,51 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'spec'
|
3
1
|
require 'pathname'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'spec/autorun'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift(dir)
|
8
|
-
$LOAD_PATH.unshift(dir.parent + 'lib')
|
5
|
+
require Pathname(__FILE__).dirname.expand_path.join('..', 'lib', 'yardstick')
|
9
6
|
|
10
|
-
|
7
|
+
Pathname.glob(Yardstick::ROOT.join('lib', '**', '*.rb').to_s).sort.each do |file|
|
8
|
+
require file.to_s.chomp('.rb')
|
9
|
+
end
|
11
10
|
|
12
11
|
Spec::Runner.configure do |config|
|
12
|
+
config.before :all do
|
13
|
+
YARD::Registry.clear
|
14
|
+
end
|
15
|
+
|
16
|
+
config.before do
|
17
|
+
YARD::Registry.clear
|
18
|
+
end
|
19
|
+
|
20
|
+
def capture_stdout
|
21
|
+
$stdout = StringIO.new
|
22
|
+
yield
|
23
|
+
ensure
|
24
|
+
$stdout.rewind
|
25
|
+
@output = $stdout.read
|
26
|
+
$stdout = STDOUT
|
27
|
+
end
|
28
|
+
|
29
|
+
def capture_stderr
|
30
|
+
$stderr = StringIO.new
|
31
|
+
yield
|
32
|
+
ensure
|
33
|
+
$stderr.rewind
|
34
|
+
@output = $stderr.read
|
35
|
+
$stderr = STDERR
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
shared_examples_for 'measured itself' do
|
40
|
+
it 'should return a MeasurementSet' do
|
41
|
+
@measurements.should be_kind_of(Yardstick::MeasurementSet)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should be non-empty' do
|
45
|
+
@measurements.should_not be_empty
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should all be correct' do
|
49
|
+
@measurements.each { |measurement| measurement.should be_ok }
|
50
|
+
end
|
13
51
|
end
|
data/tasks/ci.rake
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
task :ci => [ :heckle, 'metrics:all' ]
|
data/tasks/heckle.rake
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# original code by Ashley Moran:
|
2
|
+
# http://aviewfromafar.net/2007/11/1/rake-task-for-heckling-your-specs
|
3
|
+
desc 'Heckle each module and class'
|
4
|
+
task :heckle => :verify_rcov do
|
5
|
+
root_module = 'Yardstick'
|
6
|
+
spec_files = FileList['spec/**/*_spec.rb']
|
7
|
+
|
8
|
+
current_module = nil
|
9
|
+
current_method = nil
|
10
|
+
|
11
|
+
heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] }
|
12
|
+
unhandled_mutations = 0
|
13
|
+
|
14
|
+
IO.popen("spec --heckle #{root_module} #{spec_files} 2>/dev/null") do |pipe|
|
15
|
+
while line = pipe.gets
|
16
|
+
case line = line.chomp
|
17
|
+
when /\A\*\*\*\s+(#{root_module}(?:::)?(?:\w+(?:::)?)*)#(\S+)/
|
18
|
+
current_module, current_method = $1, $2
|
19
|
+
when "The following mutations didn't cause test failures:"
|
20
|
+
heckle_caught_modules[current_module] << current_method
|
21
|
+
when '+++ mutation'
|
22
|
+
unhandled_mutations += 1
|
23
|
+
end
|
24
|
+
|
25
|
+
puts line
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if unhandled_mutations > 0
|
30
|
+
error_message_lines = [ "*************\n" ]
|
31
|
+
|
32
|
+
error_message_lines << "Heckle found #{unhandled_mutations} " \
|
33
|
+
"mutation#{"s" unless unhandled_mutations == 1} " \
|
34
|
+
"that didn't cause spec violations\n"
|
35
|
+
|
36
|
+
heckle_caught_modules.each do |mod, methods|
|
37
|
+
error_message_lines << "#{mod} contains the following " \
|
38
|
+
'poorly-specified methods:'
|
39
|
+
methods.each do |method|
|
40
|
+
error_message_lines << " - #{method}"
|
41
|
+
end
|
42
|
+
error_message_lines << ''
|
43
|
+
end
|
44
|
+
|
45
|
+
error_message_lines << 'Get your act together and come back ' \
|
46
|
+
'when your specs are doing their job!'
|
47
|
+
|
48
|
+
raise error_message_lines.join("\n")
|
49
|
+
else
|
50
|
+
puts 'Well done! Your code withstood a heckling.'
|
51
|
+
end
|
52
|
+
end
|
data/tasks/metrics.rake
CHANGED
data/tasks/spec.rake
CHANGED
@@ -11,65 +11,12 @@ Spec::Rake::SpecTask.new(:spec, &spec_defaults)
|
|
11
11
|
|
12
12
|
Spec::Rake::SpecTask.new(:rcov) do |rcov|
|
13
13
|
spec_defaults.call(rcov)
|
14
|
-
rcov.rcov
|
15
|
-
rcov.rcov_opts
|
14
|
+
rcov.rcov = true
|
15
|
+
rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
|
16
16
|
end
|
17
17
|
|
18
18
|
RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
|
19
|
-
rcov.threshold =
|
20
|
-
end
|
21
|
-
|
22
|
-
# original code by Ashley Moran:
|
23
|
-
# http://aviewfromafar.net/2007/11/1/rake-task-for-heckling-your-specs
|
24
|
-
desc 'Heckle each module and class'
|
25
|
-
task :heckle => :verify_rcov do
|
26
|
-
root_module = 'Yardstick'
|
27
|
-
spec_files = FileList['spec/**/*_spec.rb']
|
28
|
-
|
29
|
-
current_module = nil
|
30
|
-
current_method = nil
|
31
|
-
|
32
|
-
heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] }
|
33
|
-
unhandled_mutations = 0
|
34
|
-
|
35
|
-
IO.popen("spec --heckle #{root_module} #{spec_files}") do |pipe|
|
36
|
-
while line = pipe.gets
|
37
|
-
case line = line.chomp
|
38
|
-
when /\A\*\*\*\s+(#{root_module}(?:::)?(?:\w+(?:::)?)*)#(\w+)\b/
|
39
|
-
current_module, current_method = $1, $2
|
40
|
-
when "The following mutations didn't cause test failures:"
|
41
|
-
heckle_caught_modules[current_module] << current_method
|
42
|
-
when '+++ mutation'
|
43
|
-
unhandled_mutations += 1
|
44
|
-
end
|
45
|
-
|
46
|
-
puts line
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
if unhandled_mutations > 0
|
51
|
-
error_message_lines = [ "*************\n" ]
|
52
|
-
|
53
|
-
error_message_lines << "Heckle found #{unhandled_mutations} " \
|
54
|
-
"mutation#{"s" unless unhandled_mutations == 1} " \
|
55
|
-
"that didn't cause spec violations\n"
|
56
|
-
|
57
|
-
heckle_caught_modules.each do |mod, methods|
|
58
|
-
error_message_lines << "#{mod} contains the following " \
|
59
|
-
'poorly-specified methods:'
|
60
|
-
methods.each do |method|
|
61
|
-
error_message_lines << " - #{method}"
|
62
|
-
end
|
63
|
-
error_message_lines << ''
|
64
|
-
end
|
65
|
-
|
66
|
-
error_message_lines << 'Get your act together and come back ' \
|
67
|
-
'when your specs are doing their job!'
|
68
|
-
|
69
|
-
raise error_message_lines.join("\n")
|
70
|
-
else
|
71
|
-
puts 'Well done! Your code withstood a heckling.'
|
72
|
-
end
|
19
|
+
rcov.threshold = 100
|
73
20
|
end
|
74
21
|
|
75
22
|
task :default => :spec
|
data/yardstick.gemspec
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{yardstick}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Dan Kubb"]
|
9
|
+
s.date = %q{2009-07-25}
|
10
|
+
s.default_executable = %q{yardstick}
|
11
|
+
s.email = %q{dan.kubb@gmail.com}
|
12
|
+
s.executables = ["yardstick"]
|
13
|
+
s.extra_rdoc_files = [
|
14
|
+
"LICENSE",
|
15
|
+
"README.markdown"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
".document",
|
19
|
+
".gitignore",
|
20
|
+
"LICENSE",
|
21
|
+
"README.markdown",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"bin/yardstick",
|
25
|
+
"lib/yardstick.rb",
|
26
|
+
"lib/yardstick/autoload.rb",
|
27
|
+
"lib/yardstick/cli.rb",
|
28
|
+
"lib/yardstick/core_ext/object.rb",
|
29
|
+
"lib/yardstick/measurable.rb",
|
30
|
+
"lib/yardstick/measurement.rb",
|
31
|
+
"lib/yardstick/measurement_set.rb",
|
32
|
+
"lib/yardstick/method.rb",
|
33
|
+
"lib/yardstick/ordered_set.rb",
|
34
|
+
"lib/yardstick/processor.rb",
|
35
|
+
"lib/yardstick/rule.rb",
|
36
|
+
"lib/yardstick/rule_set.rb",
|
37
|
+
"lib/yardstick/yard_ext.rb",
|
38
|
+
"spec/public/yardstick/cli_spec.rb",
|
39
|
+
"spec/public/yardstick/measurement_set_spec.rb",
|
40
|
+
"spec/public/yardstick/measurement_spec.rb",
|
41
|
+
"spec/public/yardstick/method_spec.rb",
|
42
|
+
"spec/public/yardstick_spec.rb",
|
43
|
+
"spec/rcov.opts",
|
44
|
+
"spec/semipublic/yardstick/rule_spec.rb",
|
45
|
+
"spec/spec.opts",
|
46
|
+
"spec/spec_helper.rb",
|
47
|
+
"tasks/ci.rake",
|
48
|
+
"tasks/heckle.rake",
|
49
|
+
"tasks/metrics.rake",
|
50
|
+
"tasks/rdoc.rake",
|
51
|
+
"tasks/spec.rake",
|
52
|
+
"yardstick.gemspec"
|
53
|
+
]
|
54
|
+
s.homepage = %q{http://github.com/dkubb/yardstick}
|
55
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
56
|
+
s.require_paths = ["lib"]
|
57
|
+
s.rubyforge_project = %q{yardstick}
|
58
|
+
s.rubygems_version = %q{1.3.5}
|
59
|
+
s.summary = %q{A tool for verifying YARD documentation coverage}
|
60
|
+
s.test_files = [
|
61
|
+
"spec/public/yardstick/cli_spec.rb",
|
62
|
+
"spec/public/yardstick/measurement_set_spec.rb",
|
63
|
+
"spec/public/yardstick/measurement_spec.rb",
|
64
|
+
"spec/public/yardstick/method_spec.rb",
|
65
|
+
"spec/public/yardstick_spec.rb",
|
66
|
+
"spec/semipublic/yardstick/rule_spec.rb",
|
67
|
+
"spec/spec_helper.rb"
|
68
|
+
]
|
69
|
+
|
70
|
+
if s.respond_to? :specification_version then
|
71
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
72
|
+
s.specification_version = 3
|
73
|
+
|
74
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
75
|
+
s.add_runtime_dependency(%q<yard>, ["~> 0.2"])
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<yard>, ["~> 0.2"])
|
78
|
+
end
|
79
|
+
else
|
80
|
+
s.add_dependency(%q<yard>, ["~> 0.2"])
|
81
|
+
end
|
82
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dkubb-yardstick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kubb
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-25 00:00:00 -07:00
|
13
13
|
default_executable: yardstick
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,12 +30,12 @@ extensions: []
|
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
32
|
- LICENSE
|
33
|
-
- README.
|
33
|
+
- README.markdown
|
34
34
|
files:
|
35
35
|
- .document
|
36
36
|
- .gitignore
|
37
37
|
- LICENSE
|
38
|
-
- README.
|
38
|
+
- README.markdown
|
39
39
|
- Rakefile
|
40
40
|
- VERSION
|
41
41
|
- bin/yardstick
|
@@ -45,18 +45,28 @@ files:
|
|
45
45
|
- lib/yardstick/core_ext/object.rb
|
46
46
|
- lib/yardstick/measurable.rb
|
47
47
|
- lib/yardstick/measurement.rb
|
48
|
+
- lib/yardstick/measurement_set.rb
|
48
49
|
- lib/yardstick/method.rb
|
50
|
+
- lib/yardstick/ordered_set.rb
|
49
51
|
- lib/yardstick/processor.rb
|
52
|
+
- lib/yardstick/rule.rb
|
53
|
+
- lib/yardstick/rule_set.rb
|
50
54
|
- lib/yardstick/yard_ext.rb
|
55
|
+
- spec/public/yardstick/cli_spec.rb
|
56
|
+
- spec/public/yardstick/measurement_set_spec.rb
|
51
57
|
- spec/public/yardstick/measurement_spec.rb
|
52
58
|
- spec/public/yardstick/method_spec.rb
|
53
59
|
- spec/public/yardstick_spec.rb
|
54
60
|
- spec/rcov.opts
|
61
|
+
- spec/semipublic/yardstick/rule_spec.rb
|
55
62
|
- spec/spec.opts
|
56
63
|
- spec/spec_helper.rb
|
64
|
+
- tasks/ci.rake
|
65
|
+
- tasks/heckle.rake
|
57
66
|
- tasks/metrics.rake
|
58
67
|
- tasks/rdoc.rake
|
59
68
|
- tasks/spec.rake
|
69
|
+
- yardstick.gemspec
|
60
70
|
has_rdoc: false
|
61
71
|
homepage: http://github.com/dkubb/yardstick
|
62
72
|
post_install_message:
|
@@ -84,7 +94,10 @@ signing_key:
|
|
84
94
|
specification_version: 3
|
85
95
|
summary: A tool for verifying YARD documentation coverage
|
86
96
|
test_files:
|
97
|
+
- spec/public/yardstick/cli_spec.rb
|
98
|
+
- spec/public/yardstick/measurement_set_spec.rb
|
87
99
|
- spec/public/yardstick/measurement_spec.rb
|
88
100
|
- spec/public/yardstick/method_spec.rb
|
89
101
|
- spec/public/yardstick_spec.rb
|
102
|
+
- spec/semipublic/yardstick/rule_spec.rb
|
90
103
|
- spec/spec_helper.rb
|