Class Spec::Example::ExampleMatcher

  1. lib/spec/example/example_matcher.rb
Parent: Object

Public class methods

new (example_group_description, example_name)
[show source]
# File lib/spec/example/example_matcher.rb, line 4
      def initialize(example_group_description, example_name)
        @example_group_description = example_group_description
        @example_name = example_name
      end

Public instance methods

matches? (specified_examples)
[show source]
# File lib/spec/example/example_matcher.rb, line 9
      def matches?(specified_examples)
        specified_examples.any? do |specified_example|
          matches_literal_example?(specified_example) || matches_example_not_considering_modules?(specified_example)
        end
      end

Protected instance methods

example_group_regex ()
[show source]
# File lib/spec/example/example_matcher.rb, line 24
      def example_group_regex
        Regexp.escape(@example_group_description)
      end
example_group_regex_not_considering_modules ()
[show source]
# File lib/spec/example/example_matcher.rb, line 32
      def example_group_regex_not_considering_modules
        Regexp.escape(@example_group_description.split('::').last)
      end
example_group_with_before_all_regexp ()
[show source]
# File lib/spec/example/example_matcher.rb, line 28
      def example_group_with_before_all_regexp
        Regexp.escape("#{@example_group_description} before(:all)")
      end
example_regexp ()
[show source]
# File lib/spec/example/example_matcher.rb, line 36
      def example_regexp
        Regexp.escape(@example_name) if @example_name
      end
matches_example_not_considering_modules? (specified_example)
[show source]
# File lib/spec/example/example_matcher.rb, line 20
      def matches_example_not_considering_modules?(specified_example)
        specified_example =~ /(^#{example_group_regex_not_considering_modules} #{example_regexp}$|^#{example_group_regex_not_considering_modules}$|^#{example_regexp}$)/
      end
matches_literal_example? (specified_example)
[show source]
# File lib/spec/example/example_matcher.rb, line 16
      def matches_literal_example?(specified_example)
        specified_example =~ /(^#{example_group_regex} #{example_regexp}$|^#{example_group_regex}$|^#{example_group_with_before_all_regexp}$|^#{example_regexp}$)/
      end