aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/plugins/rspec/lib/autotest/rspec.rb
diff options
context:
space:
mode:
authorfrancis <francis>2008-01-23 01:54:49 +0000
committerfrancis <francis>2008-01-23 01:54:49 +0000
commitfdaa98e06ba6d6f8b62480a83e9ecffdbcb21402 (patch)
tree40b8b0d7602a7a17bead44e0fd3a2ea101b18bd6 /vendor/plugins/rspec/lib/autotest/rspec.rb
parent60eaae4f7df1f1dae91defb87d3707451c359cf4 (diff)
Upgrade to rspec 1.1.2
Diffstat (limited to 'vendor/plugins/rspec/lib/autotest/rspec.rb')
-rw-r--r--vendor/plugins/rspec/lib/autotest/rspec.rb43
1 files changed, 18 insertions, 25 deletions
diff --git a/vendor/plugins/rspec/lib/autotest/rspec.rb b/vendor/plugins/rspec/lib/autotest/rspec.rb
index d4b77ea6b..cf7421ee1 100644
--- a/vendor/plugins/rspec/lib/autotest/rspec.rb
+++ b/vendor/plugins/rspec/lib/autotest/rspec.rb
@@ -1,30 +1,24 @@
require 'autotest'
+Autotest.add_hook :initialize do |at|
+ at.clear_mappings
+ # watch out: Ruby bug (1.8.6):
+ # %r(/) != /\//
+ at.add_mapping(%r%^spec/.*\.rb$%) { |filename, _|
+ filename
+ }
+ at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
+ ["spec/#{m[1]}_spec.rb"]
+ }
+ at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
+ at.files_matching %r%^spec/.*_spec\.rb$%
+ }
+end
+
class RspecCommandError < StandardError; end
class Autotest::Rspec < Autotest
- def initialize(kernel=Kernel, separator=File::SEPARATOR, alt_separator=File::ALT_SEPARATOR) # :nodoc:
- super()
- @kernel, @separator, @alt_separator = kernel, separator, alt_separator
- @spec_command = spec_command
-
- # watch out: Ruby bug (1.8.6):
- # %r(/) != /\//
- # since Ruby compares the REGEXP source, not the resulting pattern
- @test_mappings = {
- %r%^spec/.*\.rb$% => kernel.proc { |filename, _|
- filename
- },
- %r%^lib/(.*)\.rb$% => kernel.proc { |_, m|
- ["spec/#{m[1]}_spec.rb"]
- },
- %r%^spec/(spec_helper|shared/.*)\.rb$% => kernel.proc {
- files_matching %r%^spec/.*_spec\.rb$%
- }
- }
- end
-
def tests_for_file(filename)
super.select { |f| @files.has_key? f }
end
@@ -59,7 +53,7 @@ class Autotest::Rspec < Autotest
end
def make_test_cmd(files_to_test)
- return "#{ruby} -S #{@spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
+ return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
end
def add_options_if_present
@@ -71,12 +65,11 @@ class Autotest::Rspec < Autotest
# that in ~/.autotest to provide a different spec command
# then the default paths provided.
def spec_command
- spec_commands.each do |command|
+ @spec_command ||= spec_commands.each do |command|
if File.exists?(command)
return @alt_separator ? (command.gsub @separator, @alt_separator) : command
end
end
-
raise RspecCommandError, "No spec command could be found!"
end
@@ -87,7 +80,7 @@ class Autotest::Rspec < Autotest
# * default spec bin/loader installed in Rubygems
def spec_commands
[
- File.join('bin', 'spec'),
+ File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')),
File.join(Config::CONFIG['bindir'], 'spec')
]
end