Derived from the `Autotest` class, extends the `autotest` command to work with RSpec.
@note this will be extracted to a separate gem when we release rspec-3.
# File lib/autotest/rspec2.rb, line 12 12: def initialize 13: super() 14: clear_mappings 15: setup_rspec_project_mappings 16: 17: # Example for Ruby 1.8: http://rubular.com/r/AOXNVDrZpx 18: # Example for Ruby 1.9: http://rubular.com/r/85ag5AZ2jP 19: self.failed_results_re = /^\s*\d+\).*\n\s+(?:\e\[\d*m)?Failure.*(\n(?:\e\[\d*m)?\s+#\s(.*)?:\d+(?::.*)?(?:\e\[\d*m)?)+$/ 20: self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/ 21: end
Overrides Autotest’s implementation to read rspec output
# File lib/autotest/rspec2.rb, line 37 37: def consolidate_failures(failed) 38: filters = new_hash_of_arrays 39: failed.each do |spec, trace| 40: if trace =~ /(.*spec\.rb)/ 41: filters[$1] << spec 42: end 43: end 44: return filters 45: end
Overrides Autotest’s implementation to generate the rspec command to run
# File lib/autotest/rspec2.rb, line 48 48: def make_test_cmd(files_to_test) 49: files_to_test.empty? ? '' : 50: "#{prefix}#{ruby}#{suffix} -S '#{RSPEC_EXECUTABLE}' --tty #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}" 51: end
Generates a map of filenames to Arrays for Autotest
# File lib/autotest/rspec2.rb, line 54 54: def normalize(files_to_test) 55: files_to_test.keys.inject({}) do |result, filename| 56: result.merge!(File.expand_path(filename) => []) 57: end 58: end
Adds conventional spec-to-file mappings to Autotest configuation.
# File lib/autotest/rspec2.rb, line 24 24: def setup_rspec_project_mappings 25: add_mapping(%^spec/.*_spec\.rb$%) { |filename, _| 26: filename 27: } 28: add_mapping(%^lib/(.*)\.rb$%) { |_, m| 29: ["spec/#{m[1]}_spec.rb"] 30: } 31: add_mapping(%^spec/(spec_helper|shared/.*)\.rb$%) { 32: files_matching %^spec/.*_spec\.rb$% 33: } 34: end
# File lib/autotest/rspec2.rb, line 70 70: def gemfile? 71: File.exist?('./Gemfile') 72: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.