Class | Spec::Example::ExampleMatcher
In: | lib/spec/example/example_matcher.rb
Parent: | Object

### Methods

example_group_regex example_group_regex_not_considering_modules example_group_with_before_all_regexp example_regexp matches? matches_example_not_considering_modules? matches_literal_example? new

### Public Class methods

new(example_group_description, example_name)

[Source]

       # File lib/spec/example/example_matcher.rb, line 4
    4:       def initialize(example_group_description, example_name)
    5:         @example_group_description = example_group_description
    6:         @example_name = example_name
    7:       end

### Public Instance methods

matches?(specified_examples)

[Source]

        # File lib/spec/example/example_matcher.rb, line 9
     9:       def matches?(specified_examples)
    10:         specified_examples.each do |specified_example|
    11:           return true if matches_literal_example?(specified_example) || matches_example_not_considering_modules?(specified_example)
    12:         end
    13:         false
    14:       end

### Protected Instance methods

example_group_regex()

[Source]

        # File lib/spec/example/example_matcher.rb, line 25
    25:       def example_group_regex
    26:         Regexp.escape(@example_group_description)
    27:       end

example_group_regex_not_considering_modules()

[Source]

        # File lib/spec/example/example_matcher.rb, line 33
    33:       def example_group_regex_not_considering_modules
    34:         Regexp.escape(@example_group_description.split('::').last)
    35:       end

example_group_with_before_all_regexp()

[Source]

        # File lib/spec/example/example_matcher.rb, line 29
    29:       def example_group_with_before_all_regexp
    30:         Regexp.escape("#{@example_group_description} before(:all)")
    31:       end

example_regexp()

[Source]

        # File lib/spec/example/example_matcher.rb, line 37
    37:       def example_regexp
    38:         Regexp.escape(@example_name)
    39:       end

matches_example_not_considering_modules?(specified_example)

[Source]

        # File lib/spec/example/example_matcher.rb, line 21
    21:       def matches_example_not_considering_modules?(specified_example)
    22:         specified_example =~ /(^#{example_group_regex_not_considering_modules} #{example_regexp}$|^#{example_group_regex_not_considering_modules}$|^#{example_regexp}$)/
    23:       end

matches_literal_example?(specified_example)

[Source]

        # File lib/spec/example/example_matcher.rb, line 17
    17:       def matches_literal_example?(specified_example)
    18:         specified_example =~ /(^#{example_group_regex} #{example_regexp}$|^#{example_group_regex}$|^#{example_group_with_before_all_regexp}$|^#{example_regexp}$)/
    19:       end

[Validate]