From 067480daee7d572a95d0e4ce22882cd38f03e28b Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Tue, 21 May 2013 11:36:28 +0200 Subject: [PATCH] Initial conversation to devtools --- .rspec | 5 + Gemfile | 58 +----- Gemfile.devtools | 60 ++++++ Rakefile | 11 +- config/{site.reek => reek.yml} | 10 +- spec/rcov.opts | 7 - spec/shared/command_method_behavior.rb | 7 - spec/shared/each_method_behaviour.rb | 15 -- spec/shared/hash_method_behavior.rb | 17 -- spec/shared/idempotent_method_behavior.rb | 7 - spec/shared/invertible_method_behaviour.rb | 9 - spec/spec.opts | 3 - spec/spec_helper.rb | 9 +- tasks/metrics/ci.rake | 9 - tasks/metrics/flay.rake | 45 ----- tasks/metrics/flog.rake | 49 ----- tasks/metrics/heckle.rake | 208 --------------------- tasks/metrics/metric_fu.rake | 31 --- tasks/metrics/roodi.rake | 19 -- tasks/metrics/yardstick.rake | 25 --- tasks/spec.rake | 60 ------ tasks/yard.rake | 11 -- 22 files changed, 75 insertions(+), 600 deletions(-) create mode 100644 .rspec create mode 100644 Gemfile.devtools rename config/{site.reek => reek.yml} (94%) delete mode 100644 spec/rcov.opts delete mode 100644 spec/shared/command_method_behavior.rb delete mode 100644 spec/shared/each_method_behaviour.rb delete mode 100644 spec/shared/hash_method_behavior.rb delete mode 100644 spec/shared/idempotent_method_behavior.rb delete mode 100644 spec/shared/invertible_method_behaviour.rb delete mode 100644 spec/spec.opts delete mode 100644 tasks/metrics/ci.rake delete mode 100644 tasks/metrics/flay.rake delete mode 100644 tasks/metrics/flog.rake delete mode 100644 tasks/metrics/heckle.rake delete mode 100644 tasks/metrics/metric_fu.rake delete mode 100644 tasks/metrics/roodi.rake delete mode 100644 tasks/metrics/yardstick.rake delete mode 100644 tasks/spec.rake delete mode 100644 tasks/yard.rake diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..d8fbb23 --- /dev/null +++ b/.rspec @@ -0,0 +1,5 @@ +--color +--format progress +--profile +--order random +--fail-fast diff --git a/Gemfile b/Gemfile index 4ecc0e9..dbded84 100644 --- a/Gemfile +++ b/Gemfile @@ -6,59 +6,5 @@ gemspec gem 'adamantium', '~> 0.0.8', :git => 'https://github.com/dkubb/adamantium.git' -group :yard do - gem 'kramdown', '~> 1.0.1' -end - -group :guard do - gem 'guard', '~> 1.7.0' - gem 'guard-bundler', '~> 1.0.0' - gem 'guard-rspec', '~> 1.2.1' - - # file system change event handling - gem 'listen', '~> 0.7.3' - gem 'rb-fchange', '~> 0.0.6', :require => false - gem 'rb-fsevent', '~> 0.9.3', :require => false - gem 'rb-inotify', '~> 0.9.0', :require => false - - # notification handling - gem 'libnotify', '~> 0.8.0', :require => false - gem 'rb-notifu', '~> 0.0.4', :require => false - gem 'terminal-notifier-guard', '~> 1.5.3', :require => false -end - -group :metrics do - gem 'flay', '~> 1.4.3' - gem 'flog', '~> 2.5.3' - gem 'roodi', '~> 2.2.0' - gem 'simplecov', '~> 0.7.1' - gem 'yard-spellcheck', '~> 0.1.5' - gem 'yardstick', '~> 0.9.5' - - platforms :mri_18 do - gem 'arrayfields', '~> 4.9.0' # for metric_fu - gem 'fattr', '~> 2.2.0' # for metric_fu - gem 'heckle', '~> 1.4.3' - gem 'json', '~> 1.7.7' # for metric_fu rake task - gem 'map', '~> 6.3.0' # for metric_fu - gem 'metric_fu', '~> 2.1.1' - gem 'mspec', '~> 1.5.17' - gem 'rails_best_practices', '= 1.13.3' # for metric_fu - gem 'rcov', '~> 1.0.0' - gem 'ruby2ruby', '= 1.2.2' # for heckle - end - - platforms :rbx do - gem 'pelusa', '~> 0.2.2' - end -end - -group :benchmarks do - gem 'rbench', '~> 0.2.3' -end - -platform :jruby do - group :jruby do - gem 'jruby-openssl', '~> 0.8.5' - end -end +gem 'devtools', :git => 'https://github.com/datamapper/devtools.git' +eval File.read('Gemfile.devtools') diff --git a/Gemfile.devtools b/Gemfile.devtools new file mode 100644 index 0000000..5bd2529 --- /dev/null +++ b/Gemfile.devtools @@ -0,0 +1,60 @@ +# encoding: utf-8 + +group :development do + gem 'rake', '~> 10.0.4' + gem 'rspec', '~> 2.13.0' + gem 'yard', '~> 0.8.6.1' +end + +group :yard do + gem 'kramdown', '~> 1.0.1' +end + +group :guard do + gem 'guard', '~> 1.8.0' + gem 'guard-bundler', '~> 1.0.0' + gem 'guard-rspec', '~> 2.5.4' + + # file system change event handling + gem 'listen', '~> 1.0.2' + gem 'rb-fchange', '~> 0.0.6', :require => false + gem 'rb-fsevent', '~> 0.9.3', :require => false + gem 'rb-inotify', '~> 0.9.0', :require => false + + # notification handling + gem 'libnotify', '~> 0.8.0', :require => false + gem 'rb-notifu', '~> 0.0.4', :require => false + gem 'terminal-notifier-guard', '~> 1.5.3', :require => false +end + +group :metrics do + gem 'backports', '~> 3.3', '>= 3.3.0' + gem 'coveralls', '~> 0.6.6' + gem 'flay', '~> 2.2.0' + gem 'flog', '~> 4.0.0' + gem 'reek', '~> 1.3.1', :git => 'https://github.com/troessner/reek.git' + gem 'simplecov', '~> 0.7.1' + gem 'yardstick', '~> 0.9.6' + + platforms :ruby_19 do + gem 'yard-spellcheck', '~> 0.1.5' + end + + platforms :mri_19, :rbx do + gem 'mutant', '~> 0.2.20' + end + + platforms :rbx do + gem 'pelusa', '~> 0.2.2' + end +end + +group :benchmarks do + gem 'rbench', '~> 0.2.3' +end + +platform :jruby do + group :jruby do + gem 'jruby-openssl', '~> 0.8.5' + end +end diff --git a/Rakefile b/Rakefile index 397f2b0..d408668 100644 --- a/Rakefile +++ b/Rakefile @@ -1,9 +1,2 @@ -# encoding: utf-8 - -require 'rake' - -require File.expand_path('../lib/equalizer/version', __FILE__) - -FileList['tasks/**/*.rake'].each { |task| import task } - -task :default => :spec +require 'devtools' +Devtools.init_rake_tasks diff --git a/config/site.reek b/config/reek.yml similarity index 94% rename from config/site.reek rename to config/reek.yml index 4374a83..159de44 100644 --- a/config/site.reek +++ b/config/reek.yml @@ -7,7 +7,7 @@ UncommunicativeParameterName: - !ruby/regexp /^.$/ - !ruby/regexp /[0-9]$/ - !ruby/regexp /[A-Z]/ -LargeClass: +TooManyMethods: max_methods: 10 exclude: [] enabled: true @@ -49,11 +49,11 @@ NestedIterators: exclude: [] enabled: true max_allowed_nesting: 2 -LongMethod: +TooManyStatements: max_statements: 7 # TODO: decrease max_statements to 5 or less exclude: [] enabled: true -Duplication: +DuplicateMethodCall: allow_calls: [] exclude: [] enabled: true @@ -73,7 +73,7 @@ UncommunicativeVariableName: - !ruby/regexp /^.$/ - !ruby/regexp /[0-9]$/ - !ruby/regexp /[A-Z]/ -SimulatedPolymorphism: +RepeatedConditional: exclude: [] enabled: true max_ifs: 1 @@ -82,7 +82,7 @@ DataClump: enabled: true max_copies: 1 min_clump_size: 3 -ControlCouple: +ControlParameter: exclude: [] enabled: true LongYieldList: diff --git a/spec/rcov.opts b/spec/rcov.opts deleted file mode 100644 index fb8e0e0..0000000 --- a/spec/rcov.opts +++ /dev/null @@ -1,7 +0,0 @@ ---exclude-only "spec/,^/" ---sort coverage ---callsites ---xrefs ---profile ---text-summary ---failure-threshold 100 diff --git a/spec/shared/command_method_behavior.rb b/spec/shared/command_method_behavior.rb deleted file mode 100644 index c62854d..0000000 --- a/spec/shared/command_method_behavior.rb +++ /dev/null @@ -1,7 +0,0 @@ -# encoding: utf-8 - -shared_examples_for 'a command method' do - it 'returns self' do - should equal(object) - end -end diff --git a/spec/shared/each_method_behaviour.rb b/spec/shared/each_method_behaviour.rb deleted file mode 100644 index d9b29d7..0000000 --- a/spec/shared/each_method_behaviour.rb +++ /dev/null @@ -1,15 +0,0 @@ -# encoding: utf-8 - -shared_examples_for 'an #each method' do - it_should_behave_like 'a command method' - - context 'with no block' do - subject { object.each } - - it { should be_instance_of(to_enum.class) } - - it 'yields the expected values' do - subject.to_a.should eql(object.to_a) - end - end -end diff --git a/spec/shared/hash_method_behavior.rb b/spec/shared/hash_method_behavior.rb deleted file mode 100644 index 7b20c7d..0000000 --- a/spec/shared/hash_method_behavior.rb +++ /dev/null @@ -1,17 +0,0 @@ -# encoding: utf-8 - -shared_examples_for 'a hash method' do - it_should_behave_like 'an idempotent method' - - specification = proc do - should be_instance_of(Fixnum) - end - - it 'is a fixnum' do - instance_eval(&specification) - end - - it 'memoizes the hash code' do - subject.should eql(object.memoized(:hash)) - end -end diff --git a/spec/shared/idempotent_method_behavior.rb b/spec/shared/idempotent_method_behavior.rb deleted file mode 100644 index 220d792..0000000 --- a/spec/shared/idempotent_method_behavior.rb +++ /dev/null @@ -1,7 +0,0 @@ -# encoding: utf-8 - -shared_examples_for 'an idempotent method' do - it 'is idempotent' do - should equal(instance_eval(&self.class.subject)) - end -end diff --git a/spec/shared/invertible_method_behaviour.rb b/spec/shared/invertible_method_behaviour.rb deleted file mode 100644 index 936d65d..0000000 --- a/spec/shared/invertible_method_behaviour.rb +++ /dev/null @@ -1,9 +0,0 @@ -# encoding: utf-8 - -shared_examples_for 'an invertible method' do - it_should_behave_like 'an idempotent method' - - it 'is invertible' do - subject.inverse.should equal(object) - end -end diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 80d5b32..0000000 --- a/spec/spec.opts +++ /dev/null @@ -1,3 +0,0 @@ ---color ---loadby random ---format profile diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bf7c523..e038ef2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,11 +1,4 @@ # encoding: utf-8 require 'equalizer' -require 'spec' -require 'spec/autorun' - -# require spec support files and shared behavior -Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each { |f| require f } - -Spec::Runner.configure do |config| -end +require 'devtools/spec_helper' diff --git a/tasks/metrics/ci.rake b/tasks/metrics/ci.rake deleted file mode 100644 index 191096e..0000000 --- a/tasks/metrics/ci.rake +++ /dev/null @@ -1,9 +0,0 @@ -# encoding: utf-8 - -desc 'Run metrics with Heckle' -task :ci => %w[ ci:metrics metrics:heckle ] - -namespace :ci do - desc 'Run metrics (except heckle) and spec' - task :metrics => %w[ spec metrics:verify_measurements metrics:flog metrics:flay metrics:roodi metrics:all ] -end diff --git a/tasks/metrics/flay.rake b/tasks/metrics/flay.rake deleted file mode 100644 index 89dc402..0000000 --- a/tasks/metrics/flay.rake +++ /dev/null @@ -1,45 +0,0 @@ -# encoding: utf-8 - -begin - require 'flay' - require 'yaml' - - config = YAML.load_file(File.expand_path('../../../config/flay.yml', __FILE__)).freeze - threshold = config.fetch('threshold').to_i - total_score = config.fetch('total_score').to_f - files = Flay.expand_dirs_to_files(config.fetch('path', 'lib')).sort - - namespace :metrics do - # original code by Marty Andrews: - # http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html - desc 'Analyze for code duplication' - task :flay do - # run flay once without a threshold to ensure the max mass matches the threshold - flay = Flay.new(:fuzzy => false, :verbose => false, :mass => 0) - flay.process(*files) - - max = (flay.masses.map { |hash, mass| mass.to_f / flay.hashes[hash].size }.max) || 0 - unless max >= threshold - raise "Adjust flay threshold down to #{max}" - end - - total = flay.masses.reduce(0.0) { |total, (hash, mass)| total + (mass.to_f / flay.hashes[hash].size) } - unless total == total_score - raise "Flay total is now #{total}, but expected #{total_score}" - end - - # run flay a second time with the threshold set - flay = Flay.new(:fuzzy => false, :verbose => false, :mass => threshold.succ) - flay.process(*files) - - if flay.masses.any? - flay.report - raise "#{flay.masses.size} chunks of code have a duplicate mass > #{threshold}" - end - end - end -rescue LoadError - task :flay do - $stderr.puts 'Flay is not available. In order to run flay, you must: gem install flay' - end -end diff --git a/tasks/metrics/flog.rake b/tasks/metrics/flog.rake deleted file mode 100644 index b693464..0000000 --- a/tasks/metrics/flog.rake +++ /dev/null @@ -1,49 +0,0 @@ -# encoding: utf-8 - -begin - require 'flog' - require 'yaml' - - class Float - def round_to(n) - (self * 10**n).round.to_f * 10**-n - end - end - - config = YAML.load_file(File.expand_path('../../../config/flog.yml', __FILE__)).freeze - threshold = config.fetch('threshold').to_f.round_to(1) - - namespace :metrics do - # original code by Marty Andrews: - # http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html - desc 'Analyze for code complexity' - task :flog do - flog = Flog.new - flog.flog Array(config.fetch('path', 'lib')) - - totals = flog.totals.select { |name, score| name[-5, 5] != '#none' }. - map { |name, score| [ name, score.round_to(1) ] }. - sort_by { |name, score| score } - - if totals.any? - max = totals.last[1] - unless max >= threshold - raise "Adjust flog score down to #{max}" - end - end - - bad_methods = totals.select { |name, score| score > threshold } - if bad_methods.any? - bad_methods.reverse_each do |name, score| - puts '%8.1f: %s' % [ score, name ] - end - - raise "#{bad_methods.size} methods have a flog complexity > #{threshold}" - end - end - end -rescue LoadError - task :flog do - $stderr.puts 'Flog is not available. In order to run flog, you must: gem install flog' - end -end diff --git a/tasks/metrics/heckle.rake b/tasks/metrics/heckle.rake deleted file mode 100644 index 9406e77..0000000 --- a/tasks/metrics/heckle.rake +++ /dev/null @@ -1,208 +0,0 @@ -# encoding: utf-8 - -$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__)) - -# original code by Ashley Moran: -# http://aviewfromafar.net/2007/11/1/rake-task-for-heckling-your-specs - -begin - require 'pathname' - require 'heckle' - require 'mspec' - require 'mspec/utils/name_map' - - SKIP_METHODS = %w[ blank_slate_method_added ].freeze - - class NameMap - def file_name(method, constant) - map = MAP[method] - name = if map - map[constant] || map[:default] - else - method.gsub(/[?!=]\z/, '') - end - "#{name}_spec.rb" - end - end - - namespace :metrics do - desc 'Heckle each module and class' - task :heckle => :coverage do - unless Ruby2Ruby::VERSION == '1.2.2' - raise "ruby2ruby version #{Ruby2Ruby::VERSION} may not work properly, 1.2.2 *only* is recommended for use with heckle" - end - - require 'equalizer' - - root_module_regexp = Regexp.union('Equalizer') - - spec_dir = Pathname('spec/unit') - - NameMap::MAP.each do |op, method| - next if method.kind_of?(Hash) - NameMap::MAP[op] = { :default => method } - end - - aliases = Hash.new { |h,mod| h[mod] = Hash.new { |h,method| h[method] = method } } - map = NameMap.new - - heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] } - uncovered_methods = 0 - - ObjectSpace.each_object(Module) do |mod| - next unless mod.name =~ /\A#{root_module_regexp}(?::|\z)/ - - spec_prefix = spec_dir.join(mod.name.underscore) - - specs = [] - - # get the public class methods - metaclass = class << mod; self end - ancestors = metaclass.ancestors - - spec_class_methods = mod.singleton_methods(false) - - spec_class_methods.reject! do |method| - %w[ yaml_new yaml_tag_subclasses? included nesting constants ].include?(method.to_s) - end - - if mod.ancestors.include?(Singleton) - spec_class_methods.reject! { |method| method.to_s == 'instance' } - end - - # get the protected and private class methods - other_class_methods = metaclass.protected_instance_methods(false) | - metaclass.private_instance_methods(false) - - ancestors.each do |ancestor| - other_class_methods -= ancestor.protected_instance_methods(false) | - ancestor.private_instance_methods(false) - end - - other_class_methods.reject! do |method| - method.to_s == 'allocate' || SKIP_METHODS.include?(method.to_s) - end - - other_class_methods.reject! do |method| - next unless spec_class_methods.any? { |specced| specced.to_s == $1 } - - spec_class_methods << method - end - - spec_class_methods -= other_class_methods - - # get the instances methods - spec_methods = mod.public_instance_methods(false) - - other_methods = mod.protected_instance_methods(false) | - mod.private_instance_methods(false) - - other_methods.reject! do |method| - next unless spec_methods.any? { |specced| specced.to_s == $1 } - - spec_methods << method - end - - # map the class methods to spec files - spec_class_methods.each do |method| - method = aliases[mod.name][method] - next if SKIP_METHODS.include?(method.to_s) - - spec_file = spec_prefix.join('class_methods').join(map.file_name(method, mod.name)) - - unless spec_file.file? - raise "No spec file #{spec_file} for #{mod}.#{method}" - end - - specs << [ ".#{method}", [ spec_file ] ] - end - - # map the instance methods to spec files - spec_methods.each do |method| - method = aliases[mod.name][method] - next if SKIP_METHODS.include?(method.to_s) - - spec_file = spec_prefix.join(map.file_name(method, mod.name)) - - unless spec_file.file? - raise "No spec file #{spec_file} for #{mod}##{method}" - end - - specs << [ "##{method}", [ spec_file ] ] - end - - # non-public methods are considered covered if they can be mutated - # and any spec fails for the current or descendant modules - other_methods.each do |method| - descedant_specs = [] - - ObjectSpace.each_object(Module) do |descedant| - next unless descedant.name =~ /\A#{root_module_regexp}(?::|\z)/ && mod >= descedant - descedant_spec_prefix = spec_dir.join(descedant.name.underscore) - descedant_specs << descedant_spec_prefix - - if method.to_s == 'initialize' - descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('class_methods/new_spec.rb'))) - end - end - - specs << [ "##{method}", descedant_specs ] - end - - other_class_methods.each do |method| - descedant_specs = [] - - ObjectSpace.each_object(Module) do |descedant| - next unless descedant.name =~ /\A#{root_module_regexp}(?::|\z)/ && mod >= descedant - descedant_specs << spec_dir.join(descedant.name.underscore).join('class_methods') - end - - specs << [ ".#{method}", descedant_specs ] - end - - specs.sort.each do |(method, spec_files)| - puts "Heckling #{mod}#{method}" - IO.popen("spec #{spec_files.join(' ')} --heckle '#{mod}#{method}'") do |pipe| - while line = pipe.gets - case line = line.chomp - when "The following mutations didn't cause test failures:" - heckle_caught_modules[mod.name] << method - uncovered_methods += 1 - end - end - end - end - end - - if uncovered_methods > 0 - error_message_lines = [ "*************\n" ] - - error_message_lines << "Heckle found #{uncovered_methods} " \ - "method#{"s" unless uncovered_methods == 1} " \ - "where mutations didn't cause spec violations\n" - - heckle_caught_modules.each do |mod, methods| - error_message_lines << "#{mod} contains the following " \ - 'poorly-specified methods:' - methods.each do |method| - error_message_lines << " - #{method}" - end - error_message_lines << '' - end - - error_message_lines << 'Get your act together and come back ' \ - 'when your specs are doing their job!' - - raise error_message_lines.join("\n") - else - puts 'Well done! Your code withstood a heckling.' - end - end - end -rescue LoadError - namespace :metrics do - task :heckle => :coverage do - $stderr.puts 'Heckle or mspec is not available. In order to run heckle, you must: gem install heckle mspec' - end - end -end diff --git a/tasks/metrics/metric_fu.rake b/tasks/metrics/metric_fu.rake deleted file mode 100644 index cb1ee1a..0000000 --- a/tasks/metrics/metric_fu.rake +++ /dev/null @@ -1,31 +0,0 @@ -# encoding: utf-8 - -begin - require 'metric_fu' - require 'json' - - # XXX: temporary hack until metric_fu is fixed - MetricFu::Saikuro.class_eval { include FileUtils } - - MetricFu::Configuration.run do |config| - config.rcov = { - :environment => 'test', - :test_files => %w[ spec/**/*_spec.rb ], - :rcov_opts => %w[ - --sort coverage - --no-html - --text-coverage - --no-color - --profile - --exclude spec/,^/ - --include lib:spec - ], - } - end -rescue LoadError - namespace :metrics do - task :all do - $stderr.puts 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu' - end - end -end diff --git a/tasks/metrics/roodi.rake b/tasks/metrics/roodi.rake deleted file mode 100644 index a5f5c6b..0000000 --- a/tasks/metrics/roodi.rake +++ /dev/null @@ -1,19 +0,0 @@ -# encoding: utf-8 - -begin - require 'roodi' - require 'rake/tasklib' - require 'roodi_task' - - namespace :metrics do - RoodiTask.new do |t| - t.verbose = false - t.config = File.expand_path('../../../config/roodi.yml', __FILE__) - t.patterns = %w[ lib/**/*.rb ] - end - end -rescue LoadError - task :roodi do - $stderr.puts 'Roodi is not available. In order to run roodi, you must: gem install roodi' - end -end diff --git a/tasks/metrics/yardstick.rake b/tasks/metrics/yardstick.rake deleted file mode 100644 index 9f147bb..0000000 --- a/tasks/metrics/yardstick.rake +++ /dev/null @@ -1,25 +0,0 @@ -# encoding: utf-8 - -begin - require 'yardstick/rake/measurement' - require 'yardstick/rake/verify' - require 'yaml' - - config = YAML.load_file(File.expand_path('../../../config/yardstick.yml', __FILE__)) - - namespace :metrics do - # yardstick_measure task - Yardstick::Rake::Measurement.new - - # verify_measurements task - Yardstick::Rake::Verify.new do |verify| - verify.threshold = config.fetch('threshold') - end - end -rescue LoadError - %w[ yardstick_measure verify_measurements ].each do |name| - task name.to_s do - $stderr.puts "Yardstick is not available. In order to run #{name}, you must: gem install yardstick" - end - end -end diff --git a/tasks/spec.rake b/tasks/spec.rake deleted file mode 100644 index 76e59db..0000000 --- a/tasks/spec.rake +++ /dev/null @@ -1,60 +0,0 @@ -# encoding: utf-8 - -spec_defaults = lambda do |spec| - spec.ruby_opts = %w[ -r./spec/support/config_alias ] - spec.spec_opts << '--options' << 'spec/spec.opts' -end - -begin - require 'spec/rake/spectask' - - desc 'Run all specs' - task :spec => %w[ spec:unit spec:integration ] - - namespace :spec do - desc 'Run unit specs' - Spec::Rake::SpecTask.new(:unit) do |unit| - spec_defaults.call(unit) - unit.pattern = 'spec/unit/**/*_spec.rb' - end - - desc 'Run integration specs' - Spec::Rake::SpecTask.new(:integration) do |integration| - spec_defaults.call(integration) - integration.pattern = 'spec/integration/**/*_spec.rb' - end - end -rescue LoadError - %w[ spec spec:unit spec:integration ].each do |name| - task name do - $stderr.puts "rspec is not available. In order to run #{name}, you must: gem install rspec" - end - end -end - -namespace :metrics do - begin - if RUBY_VERSION < '1.9' - desc 'Generate code coverage' - Spec::Rake::SpecTask.new(:coverage) do |rcov| - spec_defaults.call(rcov) - rcov.rcov = true - rcov.pattern = 'spec/unit/**/*_spec.rb' - rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) - end - else - desc 'Generate code coverage' - task :coverage do - ENV['COVERAGE'] = 'true' - Rake::Task['spec:unit'].execute - end - end - rescue LoadError - task :coverage do - lib = RUBY_VERSION < '1.9' ? 'rcov' : 'simplecov' - $stderr.puts "coverage is not available. In order to run #{lib}, you must: gem install #{lib}" - end - end -end - -task :test => :spec diff --git a/tasks/yard.rake b/tasks/yard.rake deleted file mode 100644 index 15cb99f..0000000 --- a/tasks/yard.rake +++ /dev/null @@ -1,11 +0,0 @@ -# encoding: utf-8 - -begin - require 'yard' - - YARD::Rake::YardocTask.new -rescue LoadError - task :yard do - $stderr.puts 'YARD is not available. In order to run yard, you must: gem install yard' - end -end