summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/lib/mspec')
-rw-r--r--spec/mspec/lib/mspec/runner/filters/regexp.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/spec/mspec/lib/mspec/runner/filters/regexp.rb b/spec/mspec/lib/mspec/runner/filters/regexp.rb
index 2bd1448d3f..097ec6a755 100644
--- a/spec/mspec/lib/mspec/runner/filters/regexp.rb
+++ b/spec/mspec/lib/mspec/runner/filters/regexp.rb
@@ -1,7 +1,23 @@
-require 'mspec/runner/filters/match'
+class RegexpFilter
+ def initialize(what, *regexps)
+ @what = what
+ @regexps = to_regexp(*regexps)
+ end
+
+ def ===(string)
+ @regexps.any? { |regexp| regexp === string }
+ end
+
+ def register
+ MSpec.register @what, self
+ end
+
+ def unregister
+ MSpec.unregister @what, self
+ end
-class RegexpFilter < MatchFilter
- def to_regexp(*strings)
- strings.map { |str| Regexp.new str }
+ def to_regexp(*regexps)
+ regexps.map { |str| Regexp.new str }
end
+ private :to_regexp
end