Sha256: e80adfe45a16d50be17c08efdb6c25bc3e92a3d42310251422eb17d6c4b571d8

Contents?: true

Size: 1.4 KB

Versions: 28

Compression:

Stored size: 1.4 KB

Contents

module Spec
  module Example
    class ExampleMatcher
      def initialize(example_group_description, example_name)
        @example_group_description = example_group_description
        @example_name = example_name
      end
      
      def matches?(specified_examples)
        specified_examples.each do |specified_example|
          return true if matches_literal_example?(specified_example) || matches_example_not_considering_modules?(specified_example)
        end
        false
      end
      
      protected
      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

      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

      def example_group_regex
        Regexp.escape(@example_group_description)
      end

      def example_group_with_before_all_regexp
        Regexp.escape("#{@example_group_description} before(:all)")
      end

      def example_group_regex_not_considering_modules
        Regexp.escape(@example_group_description.split('::').last)
      end

      def example_regexp
        Regexp.escape(@example_name)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 5 rubygems

Version Path
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/lib/spec/example/example_matcher.rb
picolena-0.1.0 rails_plugins/rspec/lib/spec/example/example_matcher.rb
picolena-0.1.1 rails_plugins/rspec/lib/spec/example/example_matcher.rb
picolena-0.1.2 rails_plugins/rspec/lib/spec/example/example_matcher.rb
picolena-0.1.4 rails_plugins/rspec/lib/spec/example/example_matcher.rb
picolena-0.1.3 rails_plugins/rspec/lib/spec/example/example_matcher.rb
picolena-0.1.5 rails_plugins/rspec/lib/spec/example/example_matcher.rb
radiant-0.6.5.1 vendor/plugins/rspec/lib/spec/example/example_matcher.rb
radiant-0.6.5 vendor/plugins/rspec/lib/spec/example/example_matcher.rb
radiant-0.6.7 vendor/plugins/rspec/lib/spec/example/example_matcher.rb
radiant-0.6.6 vendor/plugins/rspec/lib/spec/example/example_matcher.rb
radiant-0.6.9 vendor/plugins/rspec/lib/spec/example/example_matcher.rb
radiant-0.6.8 vendor/plugins/rspec/lib/spec/example/example_matcher.rb
rspec-1.1.0 lib/spec/example/example_matcher.rb
rspec-1.1.1 lib/spec/example/example_matcher.rb
rspec-1.1.2 lib/spec/example/example_matcher.rb
rspec-1.1.4 lib/spec/example/example_matcher.rb
rspec-1.1.3 lib/spec/example/example_matcher.rb
spree-0.2.0 vendor/plugins/rspec/lib/spec/example/example_matcher.rb
typo-5.0.2 vendor/plugins/rspec/lib/spec/example/example_matcher.rb