-
-
Save tenderlove/4695587283008c0b8716 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb | |
index 739823b..45000bc 100644 | |
--- a/activesupport/lib/active_support/test_case.rb | |
+++ b/activesupport/lib/active_support/test_case.rb | |
@@ -75,6 +75,27 @@ module ActiveSupport | |
alias :assert_not_respond_to :refute_respond_to | |
alias :assert_not_same :refute_same | |
+ class FileAndLineFilter < Struct.new(:klass, :file, :line) | |
+ def === method | |
+ return false unless klass.method_defined? method | |
+ test_file, test_line = klass.instance_method(method).source_location | |
+ test_file == file && test_line == line | |
+ end | |
+ end | |
+ | |
+ def self.run reporter, options = {} | |
+ if file_and_line? options[:filter] | |
+ options = options.dup | |
+ options[:filter] =~ /^(.*):(\d+)/ | |
+ options[:filter] = FileAndLineFilter.new(self, $1, $2.to_i) | |
+ end | |
+ super(reporter, options) | |
+ end | |
+ | |
+ def self.file_and_line? option | |
+ option && option =~ /:\d+/ | |
+ end | |
+ | |
# Fails if the block raises an exception. | |
# | |
# assert_nothing_raised do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment