Browse files

Fix so that coverage works in 1.8.7 and 1.9

  • Loading branch information...
1 parent af0a74c commit 692fcd72c391c731dc21014c15f54cc8fe6d252b @copiousfreetime committed Jan 10, 2013
View
33 Rakefile
@@ -19,13 +19,7 @@ namespace :develop do
require 'rubygems/dependency_installer'
installer = Gem::DependencyInstaller.new
- # list these here instead of gem dependencies since there is not a way to
- # specify ruby version specific dependencies
- if RUBY_VERSION < "1.9.2"
- Util.platform_gemspec.add_development_dependency( 'rcov', '~> 0.9.11' )
- else
- Util.platform_gemspec.add_development_dependency( 'simplecov', '~> 0.6.4' )
- end
+ Util.set_coverage_gem
puts "Installing gem depedencies needed for development"
Util.platform_gemspec.dependencies.each do |dep|
@@ -94,7 +88,7 @@ end
# Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
# for the moment only rcov is listed.
#------------------------------------------------------------------------------
-if RUBY_VERSION <= "1.9.2"
+if RUBY_VERSION < "1.9.2"
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new( 'coverage' ) do |t|
@@ -218,6 +212,7 @@ This.gemspec_file = "#{This.name}.gemspec"
# Really this is only here to support those who use bundler
desc "Build the #{This.name}.gemspec file"
task :gemspec do
+ Util.set_coverage_gem
File.open( This.gemspec_file, "wb+" ) do |f|
f.write Util.platform_gemspec.to_ruby
end
@@ -265,9 +260,14 @@ task :release => [ :release_check, 'manifest:check', :gem ] do
end
#------------------------------------------------------------------------------
-# Load the extra tasks
+# Load the extra rake tasks
#------------------------------------------------------------------------------
-load 'tasks/extension.rake'
+$: << "." unless $:.include?(".")
+begin
+ load 'tasks/extension.rake'
+rescue LoadError => e
+ Util.task_warning( 'extension' )
+end
#------------------------------------------------------------------------------
# Rakefile Support - This is all the guts and utility methods that are
@@ -331,6 +331,19 @@ BEGIN {
Pathname.new( File.expand_path( "..", __FILE__ ) )
end
+ def self.set_coverage_gem
+ # list these here instead of gem dependencies since there is not a way to
+ # specify ruby version specific dependencies
+ g, v = 'simplecov', '~> 0.7.1'
+ if RUBY_VERSION < "1.9.2"
+ g, v = 'rcov', '~> 1.0.0'
+ end
+
+ if Util.platform_gemspec.dependencies.none? { |s| s.name == g } then
+ Util.platform_gemspec.add_development_dependency( g, v )
+ end
+ end
+
def self.proj_path( *args )
proj_root_path.join( *args )
end
View
4 spec/interval_spec.rb
@@ -1,6 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-
-require 'hitimes'
+require "spec_helper"
describe Hitimes::Interval do
it "raises an error if duration is called on a non-started interval" do
View
4 spec/metric_spec.rb
@@ -1,6 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-
-require 'hitimes/metric'
+require "spec_helper"
describe Hitimes::Metric do
before( :each ) do
View
5 spec/mutex_stats_spec.rb
@@ -1,7 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-
-require 'hitimes'
-require 'hitimes/mutexed_stats'
+require 'spec_helper'
describe Hitimes::MutexedStats do
before( :each ) do
View
4 spec/paths_spec.rb
@@ -1,6 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-
-require 'hitimes/paths'
+require 'spec_helper'
describe Hitimes::Paths do
it "can access the root dir of the project" do
View
9 spec/spec_helper.rb
@@ -1,4 +1,9 @@
-require 'rubygems'
-require 'rspec'
+if RUBY_VERSION >= '1.9.2' then
+ require 'simplecov'
+ puts "Using coverage!"
+ SimpleCov.start if ENV['COVERAGE']
+end
+
+require 'rspec/autorun'
require 'hitimes'
View
4 spec/stats_spec.rb
@@ -1,6 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-
-require 'hitimes/stats'
+require 'spec_helper'
require 'json'
describe Hitimes::Stats do
View
4 spec/timed_metric_spec.rb
@@ -1,6 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-
-require 'hitimes/timed_metric'
+require 'spec_helper'
describe Hitimes::TimedMetric do
before( :each ) do
View
4 spec/timed_value_metric_spec.rb
@@ -1,6 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-
-require 'hitimes/timed_value_metric'
+require 'spec_helper'
describe Hitimes::TimedValueMetric do
before( :each ) do
View
4 spec/value_metric_spec.rb
@@ -1,6 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-
-require 'hitimes/value_metric'
+require 'spec_helper'
describe Hitimes::ValueMetric do
before( :each ) do
View
2 spec/version_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper" ) )
+require "spec_helper"
describe "Hitimes::Version" do
it "should be accessable as a constant" do

0 comments on commit 692fcd7

Please sign in to comment.