diff options
author | Francis Irving <francis@mysociety.org> | 2009-12-02 17:56:17 +0000 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2009-12-02 17:56:17 +0000 |
commit | 1bbb3f950f8bee92bf8a39e6f18c3278f1bab11d (patch) | |
tree | 5d0312d5d00446cd1454a5e1c799cd89d57b10d6 /vendor/plugins/rspec/lib/autotest/rspec.rb | |
parent | 5f3139b538d1ff58b719a72d7c7cf05a5b6136b5 (diff) |
Changing rspec / rspec_on_rails version
Diffstat (limited to 'vendor/plugins/rspec/lib/autotest/rspec.rb')
-rw-r--r-- | vendor/plugins/rspec/lib/autotest/rspec.rb | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/vendor/plugins/rspec/lib/autotest/rspec.rb b/vendor/plugins/rspec/lib/autotest/rspec.rb index 164f298f5..625e340b5 100644 --- a/vendor/plugins/rspec/lib/autotest/rspec.rb +++ b/vendor/plugins/rspec/lib/autotest/rspec.rb @@ -4,13 +4,13 @@ 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%^spec/.*_spec.rb$%) { |filename, _| + filename } - at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| + at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| ["spec/#{m[1]}_spec.rb"] } - at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) { + at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) { at.files_matching %r%^spec/.*_spec\.rb$% } end @@ -21,14 +21,14 @@ class Autotest::Rspec < Autotest def initialize super - self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m + self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n\n?(.*?(\n\n\(.*?)?)\n\n/m self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m end - + def consolidate_failures(failed) filters = new_hash_of_arrays failed.each do |spec, trace| - if trace =~ /\n(\.\/)?(.*\.rb):[\d]+:\Z?/ + if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:/ filters[$2] << spec end end @@ -36,37 +36,12 @@ 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 '' if files_to_test.empty? + spec_program = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')) + return "#{ruby} #{spec_program} --autospec #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}" end - + def add_options_if_present # :nodoc: File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : "" end - - # Finds the proper spec command to use. Precendence is set in the - # lazily-evaluated method spec_commands. Alias + Override that in - # ~/.autotest to provide a different spec command then the default - # paths provided. - def spec_command(separator=File::ALT_SEPARATOR) - unless defined? @spec_command then - @spec_command = spec_commands.find { |cmd| File.exists? cmd } - - raise RspecCommandError, "No spec command could be found!" unless @spec_command - - @spec_command.gsub! File::SEPARATOR, separator if separator - end - @spec_command - end - - # Autotest will look for spec commands in the following - # locations, in this order: - # - # * bin/spec - # * default spec bin/loader installed in Rubygems - def spec_commands - [ - File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')), - File.join(Config::CONFIG['bindir'], 'spec') - ] - end end |