tasks/metrics/heckle.rake in veritas-sql-generator-0.0.6 vs tasks/metrics/heckle.rake in veritas-sql-generator-0.0.7

- old
+ new

@@ -4,11 +4,11 @@ # http://aviewfromafar.net/2007/11/1/rake-task-for-heckling-your-specs begin require 'pathname' require 'backports' - require 'backports/basic_object' + require 'backports/basic_object' unless RUBY_VERSION >= '1.9.2' && (RUBY_PLATFORM.include?('java') || RUBY_ENGINE == 'rbx') require 'active_support/inflector' require 'heckle' require 'mspec' require 'mspec/utils/name_map' @@ -25,18 +25,21 @@ "#{name}_spec.rb" end end desc 'Heckle each module and class' - task :heckle => :verify_rcov do + task :heckle => :rcov 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 'veritas/sql/generator' - root_module = 'Veritas::SQL::Generator' + root_module_regexp = Regexp.union( + 'Veritas::SQL::Generator' + ) + spec_dir = Pathname('spec/unit') NameMap::MAP.each do |op, method| next if method.kind_of?(Hash) NameMap::MAP[op] = { :default => method } @@ -48,11 +51,11 @@ heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] } unhandled_mutations = 0 ObjectSpace.each_object(Module) do |mod| - next unless mod.name =~ /\A#{root_module}(?::|\z)/ + next unless mod.name =~ /\A#{root_module_regexp}(?::|\z)/ spec_prefix = spec_dir.join(mod.name.underscore) specs = [] @@ -133,13 +136,13 @@ # 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}(?::|\z)/ && mod >= descedant + next unless descedant.name =~ /\A#{root_module_regexp}(?::|\z)/ && mod >= descedant descedant_spec_prefix = spec_dir.join(descedant.name.underscore) - descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('*_spec.rb'))) + 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 @@ -149,12 +152,11 @@ other_class_methods.each do |method| descedant_specs = [] ObjectSpace.each_object(Module) do |descedant| - next unless descedant.name =~ /\A#{root_module}(?::|\z)/ && mod >= descedant - descedant_spec_prefix = spec_dir.join(descedant.name.underscore) - descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('class_methods/*_spec.rb'))) + 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