0
+# require File.dirname(__FILE__) + '/textmate'
0
+# cloned from Rspec's autotest settings, but modified
0
+# to cope w/ Merb's specs directory layout
0
+# ==== Merb Source Autotest Rules
0
+# 1. Updating a spec reruns that spec
0
+# 2. Updating a spec_helper reruns all specs at that level and below
0
+# 3. Updating a file under controller (i.e. abstract_controller.rb)
0
+# reruns all the specs under (public|private)/abstract_controller
0
+# 4. Updating a file under controller/mixins (e.g. render)
0
+# reruns all specs under
0
+# (public|private)/(abstract_controller|controller)/render_spec.rb
0
+# 5. Updating a file directly under merb_core (e.g. core_ext.rb)
0
+# reruns all the specs under spec/(public|private)/core_ext
0
+# 6. Updating merb.rb reruns all specs
0
+class RspecCommandError < StandardError; end
0
+class Autotest::MerbsourceRspec < Autotest
0
+ Autotest.add_hook :initialize do |at|
0
+ %w{.git}.each {|exception| at.exceptions.push exception}
0
+ Autotest.add_hook :run do |at|
0
+ # See above for human-readable descriptions of these rules
0
+ at.add_mapping(%r{^spec/.*_spec\.rb$}) { |filename, _| filename}
0
+ at.add_mapping(%r{^spec/(.*)/spec_helper\.rb$}) { |_, m| at.files_matching %r{^spec/#{m[1]}/.*_spec\.rb$} }
0
+ at.add_mapping(%r{^lib/merb_core/controller/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec\/(public|private)\/#{m[1]}\/.*_spec\.rb} }
0
+ at.add_mapping(%r{^lib/merb_core/controller/mixins/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec/(public|private)/(abstract_)?controller/#{m[1]}_spec\.rb} }
0
+ at.add_mapping(%r{^lib/merb_core/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec/(public|private)/#{m[1]}/.*_spec\.rb} }
0
+ at.add_mapping(%r{^lib/merb\.rb$}) { at.files_matching %r{^spec/[^/]*_spec\.rb$} }
0
+ def initialize(kernel = Kernel, separator = File::SEPARATOR, alt_separator = File::ALT_SEPARATOR) # :nodoc:
0
+ super() # need parens so that Ruby doesn't pass our args
0
+ # to the superclass version which takes none..
0
+ @kernel, @separator, @alt_separator = kernel, separator, alt_separator
0
+ @spec_command = spec_command
0
+ attr_accessor :failures
0
+ def tests_for_file(filename)
0
+ super.select { |f| @files.has_key? f }
0
+ alias :specs_for_file :tests_for_file
0
+ def failed_results(results)
0
+ results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
0
+ def handle_results(results)
0
+ @failures = failed_results(results)
0
+ @files_to_test = consolidate_failures @failures
0
+ if @files_to_test.empty?
0
+ @tainted = true unless @files_to_test.empty?
0
+ def consolidate_failures(failed)
0
+ filters = Hash.new { |h,k| h[k] = [] }
0
+ failed.each do |spec, failed_trace|
0
+ @files.keys.select { |f| f =~ /spec\// }.each do |f|
0
+ if failed_trace =~ Regexp.new(f)
0
+ def make_test_cmd(files_to_test)
0
+ "#{ruby} -S #{@spec_command} #{test_cmd_options} #{files_to_test.keys.flatten.join(' ')}"
0
+ '-O specs/spec.opts' if File.exist?('specs/spec.opts')
0
+ # Finds the proper spec command to use. Precendence
0
+ # is set in the lazily-evaluated method spec_commands. Alias + Override
0
+ # that in ~/.autotest to provide a different spec command
0
+ # then the default paths provided.
0
+ if cmd = spec_commands.detect { |c| File.exist? c }
0
+ @alt_separator ? (cmd.gsub @separator, @alt_separator) : cmd
0
+ raise RspecCommandError, 'No spec command could be found!'
0
+ # Autotest will look for spec commands in the following
0
+ # locations, in this order:
0
+ # * default spec bin/loader installed in Rubygems
0
+ if (spec = `which spec`.chomp) && !spec.empty?
0
+ [File.join('bin', 'spec'),
0
+ File.join(Config::CONFIG['bindir'], 'spec')]
Comments
No one has commented yet.