Class: Spec::Example::ExampleMethods::Identifier

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_test/spec/extensions/example_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, line, group_description, description) ⇒ Identifier

Returns a new instance of Identifier.



11
12
13
14
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 11

def initialize(file, line, group_description, description)
  @file, @line, @group_description, @description = 
   file,  line,  group_description,  description
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



10
11
12
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 10

def description
  @description
end

#fileObject (readonly)

Returns the value of attribute file.



10
11
12
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 10

def file
  @file
end

#group_descriptionObject (readonly)

Returns the value of attribute group_description.



10
11
12
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 10

def group_description
  @group_description
end

#lineObject (readonly)

Returns the value of attribute line.



10
11
12
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 10

def line
  @line
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 16

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 20

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

#hashObject



27
28
29
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 27

def hash
  description.hash
end

#locate(groups) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 31

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

#to_sObject



40
41
42
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 40

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