Sha256: 70c0568bd7e1da7b3dfca5c0d1d0da16f95cd094daf8f84922850f03c9e4169c

Contents?: true

Size: 706 Bytes

Versions: 8

Compression:

Stored size: 706 Bytes

Contents

module Spec
  module DSL
    class ExampleMatcher

      attr_writer :example_desc
      def initialize(context_desc, example_desc=nil)
        @context_desc = context_desc
        @example_desc = example_desc
      end
      
      def matches?(specified_examples)
        specified_examples.each do |specified_example|
          return true if specified_example =~ /(^#{context_regexp} #{example_regexp}$|^#{context_regexp}$|^#{example_regexp}$)/
        end
        false
      end
      
      private
        def context_regexp
          Regexp.escape(@context_desc.split('::').last)
        end
        
        def example_regexp
          Regexp.escape(@example_desc)
        end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rspec-0.9.1 lib/spec/dsl/example_matcher.rb
rspec-1.0.0 lib/spec/dsl/example_matcher.rb
rspec-0.9.0 lib/spec/dsl/example_matcher.rb
rspec-0.9.2 lib/spec/dsl/example_matcher.rb
rspec-0.9.3 lib/spec/dsl/example_matcher.rb
rspec-0.9.4 lib/spec/dsl/example_matcher.rb
rspec-1.0.1 lib/spec/dsl/example_matcher.rb
rspec-1.0.2 lib/spec/dsl/example_matcher.rb