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
data/tasks/metrics/ci.rake
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
desc 'Run metrics with Heckle'
|
4
|
-
task :ci => %w[ ci:metrics metrics:heckle ]
|
5
|
-
|
6
|
-
namespace :ci do
|
7
|
-
desc 'Run metrics (except heckle) and spec'
|
8
|
-
task :metrics => %w[ spec metrics:verify_measurements metrics:flog metrics:flay metrics:reek metrics:roodi metrics:all ]
|
9
|
-
end
|
data/tasks/metrics/flay.rake
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
PLATFORM = defined?(RUBY_ENGINE) && RUBY_ENGINE || 'ruby'
|
4
|
-
|
5
|
-
namespace :metrics do
|
6
|
-
if RUBY_VERSION >= '1.9.3' && PLATFORM == 'ruby'
|
7
|
-
begin
|
8
|
-
require 'flay'
|
9
|
-
require 'yaml'
|
10
|
-
|
11
|
-
config = YAML.load_file(File.expand_path('../../../config/flay.yml', __FILE__)).freeze
|
12
|
-
threshold = config.fetch('threshold').to_i
|
13
|
-
total_score = config.fetch('total_score').to_f
|
14
|
-
files = Flay.expand_dirs_to_files(config.fetch('path', 'lib')).sort
|
15
|
-
|
16
|
-
# original code by Marty Andrews:
|
17
|
-
# http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
|
18
|
-
desc 'Analyze for code duplication'
|
19
|
-
task :flay do
|
20
|
-
# run flay once without a threshold to ensure the max mass matches the threshold
|
21
|
-
flay = Flay.new(:fuzzy => false, :verbose => false, :mass => 0)
|
22
|
-
flay.process(*files)
|
23
|
-
|
24
|
-
max = (flay.masses.map { |hash, mass| mass.to_f / flay.hashes[hash].size }.max) || 0
|
25
|
-
unless max >= threshold
|
26
|
-
raise "Adjust flay threshold down to #{max}"
|
27
|
-
end
|
28
|
-
|
29
|
-
total = flay.masses.reduce(0.0) { |total, (hash, mass)| total + (mass.to_f / flay.hashes[hash].size) }
|
30
|
-
unless total == total_score
|
31
|
-
raise "Flay total is now #{total}, but expected #{total_score}"
|
32
|
-
end
|
33
|
-
|
34
|
-
# run flay a second time with the threshold set
|
35
|
-
flay = Flay.new(:fuzzy => false, :verbose => false, :mass => threshold.succ)
|
36
|
-
flay.process(*files)
|
37
|
-
|
38
|
-
if flay.masses.any?
|
39
|
-
flay.report
|
40
|
-
raise "#{flay.masses.size} chunks of code have a duplicate mass > #{threshold}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
rescue LoadError
|
44
|
-
task :flay do
|
45
|
-
$stderr.puts 'Flay is not available. In order to run flay, you must: gem install flay'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
else
|
49
|
-
task :flay do
|
50
|
-
$stderr.puts "Flay is disabled under #{PLATFORM}-#{RUBY_VERSION} since it is not score compatible with other implementations"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/tasks/metrics/flog.rake
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
namespace :metrics do
|
4
|
-
begin
|
5
|
-
require 'backports'
|
6
|
-
require 'flog'
|
7
|
-
require 'yaml'
|
8
|
-
|
9
|
-
config = YAML.load_file(File.expand_path('../../../config/flog.yml', __FILE__)).freeze
|
10
|
-
threshold = config.fetch('threshold').to_f.round(1)
|
11
|
-
|
12
|
-
# original code by Marty Andrews:
|
13
|
-
# http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
|
14
|
-
desc 'Analyze for code complexity'
|
15
|
-
task :flog do
|
16
|
-
flog = Flog.new
|
17
|
-
flog.flog Array(config.fetch('path', 'lib'))
|
18
|
-
|
19
|
-
totals = flog.totals.select { |name, score| name[-5, 5] != '#none' }.
|
20
|
-
map { |name, score| [ name, score.round(1) ] }.
|
21
|
-
sort_by { |name, score| score }
|
22
|
-
|
23
|
-
if totals.any?
|
24
|
-
max = totals.last[1]
|
25
|
-
unless max >= threshold
|
26
|
-
raise "Adjust flog score down to #{max}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
bad_methods = totals.select { |name, score| score > threshold }
|
31
|
-
if bad_methods.any?
|
32
|
-
bad_methods.reverse_each do |name, score|
|
33
|
-
puts '%8.1f: %s' % [ score, name ]
|
34
|
-
end
|
35
|
-
|
36
|
-
raise "#{bad_methods.size} methods have a flog complexity > #{threshold}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
rescue LoadError
|
40
|
-
task :flog do
|
41
|
-
$stderr.puts 'Flog is not available. In order to run flog, you must: gem install flog'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/tasks/metrics/heckle.rake
DELETED
@@ -1,52 +0,0 @@
|
|
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 'metrics:heckle' => 'metrics:coverage' do
|
5
|
-
root_module = 'Yardstick'
|
6
|
-
spec_files = FileList['spec/uni/**/*_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
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'metric_fu'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
# XXX: temporary hack until metric_fu is fixed
|
8
|
-
MetricFu::Saikuro.class_eval { include FileUtils }
|
9
|
-
|
10
|
-
MetricFu::Configuration.run do |config|
|
11
|
-
config.rcov = {
|
12
|
-
:environment => 'test',
|
13
|
-
:test_files => %w[ spec/**/*_spec.rb ],
|
14
|
-
:rcov_opts => %w[
|
15
|
-
--sort coverage
|
16
|
-
--no-html
|
17
|
-
--text-coverage
|
18
|
-
--no-color
|
19
|
-
--profile
|
20
|
-
--exclude spec/,^/
|
21
|
-
--include lib:spec
|
22
|
-
],
|
23
|
-
}
|
24
|
-
end
|
25
|
-
rescue LoadError
|
26
|
-
namespace :metrics do
|
27
|
-
task :all do
|
28
|
-
$stderr.puts 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/tasks/metrics/reek.rake
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
namespace :metrics do
|
4
|
-
begin
|
5
|
-
require 'reek/rake/task'
|
6
|
-
|
7
|
-
RBX_18_MODE = RUBY_VERSION < '1.9' && defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
8
|
-
|
9
|
-
Reek::Rake::Task.new do |t|
|
10
|
-
# reek has some problems under rbx in 1.8 mode that cause the underlying
|
11
|
-
# script to raise an exception. Rather than halt the "rake ci" process due
|
12
|
-
# to one bug, we choose to ignore it in this specific case until reek can be
|
13
|
-
# fixed.
|
14
|
-
t.fail_on_error = ! RBX_18_MODE # always true, except under rbx 18 mode
|
15
|
-
end
|
16
|
-
rescue LoadError
|
17
|
-
task :reek do
|
18
|
-
$stderr.puts 'Reek is not available. In order to run reek, you must: gem install reek'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/tasks/metrics/roodi.rake
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
namespace :metrics do
|
4
|
-
begin
|
5
|
-
require 'roodi'
|
6
|
-
require 'rake/tasklib'
|
7
|
-
require 'roodi_task'
|
8
|
-
|
9
|
-
RoodiTask.new do |t|
|
10
|
-
t.verbose = false
|
11
|
-
t.config = File.expand_path('../../../config/roodi.yml', __FILE__)
|
12
|
-
t.patterns = %w[ lib/**/*.rb ]
|
13
|
-
end
|
14
|
-
rescue LoadError
|
15
|
-
task :roodi do
|
16
|
-
$stderr.puts 'Roodi is not available. In order to run roodi, you must: gem install roodi'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
namespace :metrics do
|
4
|
-
begin
|
5
|
-
$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
|
6
|
-
|
7
|
-
require 'yardstick/rake/measurement'
|
8
|
-
require 'yardstick/rake/verify'
|
9
|
-
require 'yaml'
|
10
|
-
|
11
|
-
config = YAML.load_file(File.expand_path('../../../config/yardstick.yml', __FILE__))
|
12
|
-
|
13
|
-
# yardstick_measure task
|
14
|
-
Yardstick::Rake::Measurement.new
|
15
|
-
|
16
|
-
# verify_measurements task
|
17
|
-
Yardstick::Rake::Verify.new do |verify|
|
18
|
-
verify.threshold = config.fetch('threshold')
|
19
|
-
end
|
20
|
-
rescue LoadError
|
21
|
-
%w[ yardstick_measure verify_measurements ].each do |name|
|
22
|
-
task name.to_s do
|
23
|
-
$stderr.puts "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/tasks/spec.rake
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
spec_defaults = lambda do |spec|
|
4
|
-
spec.ruby_opts = %w[ -r./spec/support/config_alias ]
|
5
|
-
spec.spec_opts << '--options' << 'spec/spec.opts'
|
6
|
-
end
|
7
|
-
|
8
|
-
begin
|
9
|
-
require 'spec/rake/spectask'
|
10
|
-
|
11
|
-
desc 'Run all specs'
|
12
|
-
task :spec => %w[ spec:unit spec:integration ]
|
13
|
-
|
14
|
-
namespace :spec do
|
15
|
-
desc 'Run unit specs'
|
16
|
-
Spec::Rake::SpecTask.new(:unit) do |unit|
|
17
|
-
spec_defaults.call(unit)
|
18
|
-
unit.pattern = 'spec/unit/**/*_spec.rb'
|
19
|
-
end
|
20
|
-
|
21
|
-
desc 'Run integration specs'
|
22
|
-
Spec::Rake::SpecTask.new(:integration) do |integration|
|
23
|
-
spec_defaults.call(integration)
|
24
|
-
integration.pattern = 'spec/integration/**/*_spec.rb'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
rescue LoadError
|
28
|
-
%w[ spec spec:unit spec:integration ].each do |name|
|
29
|
-
task name do
|
30
|
-
$stderr.puts "rspec is not available. In order to run #{name}, you must: gem install rspec"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
namespace :metrics do
|
36
|
-
lib = RUBY_VERSION < '1.9' ? 'rcov' : 'simplecov'
|
37
|
-
begin
|
38
|
-
require lib
|
39
|
-
|
40
|
-
if lib == 'rcov'
|
41
|
-
require 'spec/rake/spectask'
|
42
|
-
|
43
|
-
desc 'Generate code coverage'
|
44
|
-
Spec::Rake::SpecTask.new(:coverage) do |rcov|
|
45
|
-
spec_defaults.call(rcov)
|
46
|
-
rcov.rcov = true
|
47
|
-
rcov.pattern = 'spec/unit/**/*_spec.rb'
|
48
|
-
rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
|
49
|
-
end
|
50
|
-
else
|
51
|
-
desc 'Generate code coverage'
|
52
|
-
task :coverage do
|
53
|
-
ENV['COVERAGE'] = 'true'
|
54
|
-
Rake::Task['spec:unit'].execute
|
55
|
-
end
|
56
|
-
end
|
57
|
-
rescue LoadError
|
58
|
-
task :coverage do
|
59
|
-
$stderr.puts "coverage is not available. In order to run #{lib}, you must: gem install #{lib}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
task :test => :spec
|