Sha256: cc7fc64f90687e7bccf4b565fc46a37da3c33970288989ff87114e3b25455e07

Contents?: true

Size: 1.22 KB

Versions: 24

Compression:

Stored size: 1.22 KB

Contents

module Spec
  module Example
    module ExampleMethods
      def identifier
        file, line = implementation_backtrace.first.split(/:/)
        Identifier.new(file, line.to_i, self.class.description, description)
      end

      class Identifier
        attr_reader :file, :line, :group_description, :description
        def initialize(file, line, group_description, description)
          @file, @line, @group_description, @description = 
           file,  line,  group_description,  description
        end

        def ==(other)
          eql?(other)
        end

        def eql?(other)
          File.basename(file) == File.basename(other.file) && 
                         line == other.line &&
            group_description == other.group_description &&
                  description == other.description
        end

        def hash
          description.hash
        end

        def locate(groups)
          groups.each do |group|
            group.examples.each do |example|
              return example if example.identifier == self
            end
          end
          raise "Unable to locate example #{self}"
        end

        def to_s
          "#{group_description} #{description}"
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.1 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.10 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.11 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.12 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.13 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.14 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.2 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.3 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.4 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.5 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.6 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.7 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.8 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.9 lib/deep_test/spec/extensions/example_methods.rb
jperkins-deep_test-1.2.2 lib/deep_test/spec/extensions/example_methods.rb
jason-o-matic-deep_test-1.2.2.15 lib/deep_test/spec/extensions/example_methods.rb
jstorimer-deep-test-1.4.0 lib/deep_test/spec/extensions/example_methods.rb
jstorimer-deep-test-1.3.0 lib/deep_test/spec/extensions/example_methods.rb
jstorimer-deep-test-1.2.0 lib/deep_test/spec/extensions/example_methods.rb
jstorimer-deep-test-1.1.0 lib/deep_test/spec/extensions/example_methods.rb