aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/plugins/rspec/lib/spec/rake
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2009-12-02 17:56:17 +0000
committerFrancis Irving <francis@mysociety.org>2009-12-02 17:56:17 +0000
commit1bbb3f950f8bee92bf8a39e6f18c3278f1bab11d (patch)
tree5d0312d5d00446cd1454a5e1c799cd89d57b10d6 /vendor/plugins/rspec/lib/spec/rake
parent5f3139b538d1ff58b719a72d7c7cf05a5b6136b5 (diff)
Changing rspec / rspec_on_rails version
Diffstat (limited to 'vendor/plugins/rspec/lib/spec/rake')
-rw-r--r--vendor/plugins/rspec/lib/spec/rake/spectask.rb63
-rw-r--r--vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb6
2 files changed, 32 insertions, 37 deletions
diff --git a/vendor/plugins/rspec/lib/spec/rake/spectask.rb b/vendor/plugins/rspec/lib/spec/rake/spectask.rb
index ecf39506d..9049fd08e 100644
--- a/vendor/plugins/rspec/lib/spec/rake/spectask.rb
+++ b/vendor/plugins/rspec/lib/spec/rake/spectask.rb
@@ -48,7 +48,6 @@ module Spec
# This task can also be used to run existing Test::Unit tests and get RSpec
# output, for example like this:
#
- # require 'rubygems'
# require 'spec/rake/spectask'
# Spec::Rake::SpecTask.new do |t|
# t.ruby_opts = ['-rtest/unit']
@@ -56,12 +55,10 @@ module Spec
# end
#
class SpecTask < ::Rake::TaskLib
- class << self
- def attr_accessor(*names)
- super(*names)
- names.each do |name|
- module_eval "def #{name}() evaluate(@#{name}) end" # Allows use of procs
- end
+ def self.attr_accessor(*names)
+ super(*names)
+ names.each do |name|
+ module_eval "def #{name}() evaluate(@#{name}) end" # Allows use of procs
end
end
@@ -107,7 +104,7 @@ module Spec
# A message to print to stderr when there are failures.
attr_accessor :failure_message
- # Where RSpec's output is written. Defaults to STDOUT.
+ # Where RSpec's output is written. Defaults to $stdout.
# DEPRECATED. Use --format FORMAT:WHERE in spec_opts.
attr_accessor :out
@@ -122,10 +119,13 @@ module Spec
# the executed spec command to stdout. Defaults to false.
attr_accessor :verbose
+ # Explicitly define the path to the ruby binary, or its proxy (e.g. multiruby)
+ attr_accessor :ruby_cmd
+
# Defines a new task, using the name +name+.
def initialize(name=:spec)
@name = name
- @libs = [File.expand_path(File.dirname(__FILE__) + '/../../../lib')]
+ @libs = ['lib']
@pattern = nil
@spec_files = nil
@spec_opts = []
@@ -142,7 +142,7 @@ module Spec
end
def define # :nodoc:
- spec_script = File.expand_path(File.dirname(__FILE__) + '/../../../bin/spec')
+ spec_script = File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","bin","spec"))
lib_path = libs.join(File::PATH_SEPARATOR)
actual_name = Hash === name ? name.keys.first : name
@@ -155,30 +155,23 @@ module Spec
# ruby [ruby_opts] -Ilib -S rcov [rcov_opts] bin/spec -- examples [spec_opts]
# or
# ruby [ruby_opts] -Ilib bin/spec examples [spec_opts]
- cmd = "#{File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])} "
-
- rb_opts = ruby_opts.clone
- rb_opts << "-I\"#{lib_path}\""
- rb_opts << "-S rcov" if rcov
- rb_opts << "-w" if warning
- cmd << rb_opts.join(" ")
- cmd << " "
- cmd << rcov_option_list
- cmd << %[ -o "#{rcov_dir}" ] if rcov
- cmd << %Q|"#{spec_script}"|
- cmd << " "
- cmd << "-- " if rcov
- cmd << spec_file_list.collect { |fn| %["#{fn}"] }.join(' ')
- cmd << " "
- cmd << spec_option_list
+ cmd_parts = [ruby_cmd || RUBY]
+ cmd_parts += ruby_opts
+ cmd_parts << %[-I"#{lib_path}"]
+ cmd_parts << "-S rcov" if rcov
+ cmd_parts << "-w" if warning
+ cmd_parts << rcov_option_list
+ cmd_parts << %[-o "#{rcov_dir}"] if rcov
+ cmd_parts << %["#{spec_script}"]
+ cmd_parts << "--" if rcov
+ cmd_parts += spec_file_list.collect { |fn| %["#{fn}"] }
+ cmd_parts << spec_option_list
if out
- cmd << " "
- cmd << %Q| > "#{out}"|
+ cmd_parts << %[> "#{out}"]
STDERR.puts "The Spec::Rake::SpecTask#out attribute is DEPRECATED and will be removed in a future version. Use --format FORMAT:WHERE instead."
end
- if verbose
- puts cmd
- end
+ cmd = cmd_parts.join(" ")
+ puts cmd if verbose
unless system(cmd)
STDERR.puts failure_message if failure_message
raise("Command #{cmd} failed") if fail_on_error
@@ -202,8 +195,11 @@ module Spec
end
def rcov_option_list # :nodoc:
- return "" unless rcov
- ENV['RCOV_OPTS'] || rcov_opts.join(" ") || ""
+ if rcov
+ ENV['RCOV_OPTS'] || rcov_opts.join(" ") || ""
+ else
+ ""
+ end
end
def spec_option_list # :nodoc:
@@ -232,4 +228,3 @@ module Spec
end
end
end
-
diff --git a/vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb b/vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb
index 3328f9e9a..199bd8546 100644
--- a/vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb
+++ b/vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb
@@ -35,11 +35,11 @@ module RCov
def define
desc "Verify that rcov coverage is at least #{threshold}%"
task @name do
- total_coverage = nil
+ total_coverage = 0
File.open(index_html).each_line do |line|
- if line =~ /<tt class='coverage_total'>(\d+\.\d+)%<\/tt>/
- total_coverage = eval($1)
+ if line =~ /<tt class='coverage_total'>\s*(\d+\.\d+)%\s*<\/tt>/
+ total_coverage = $1.to_f
break
end
end