mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 09:40:13 +01:00
Added Rspec and Webrat plugins and started porting Selenium on Rails tests to Rspec Plain Text Stories driving Webrat driving Selenium.
This commit is contained in:
parent
0600756bbf
commit
0f7d6f7a1d
602 changed files with 47788 additions and 29 deletions
72
vendor/plugins/rspec/lib/autotest/rspec.rb
vendored
Normal file
72
vendor/plugins/rspec/lib/autotest/rspec.rb
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
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
|
||||
super
|
||||
self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\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(\.\/)?(.*spec\.rb):[\d]+:\Z?/
|
||||
filters[$2] << spec
|
||||
end
|
||||
end
|
||||
return filters
|
||||
end
|
||||
|
||||
def make_test_cmd(files_to_test)
|
||||
return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue