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.



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

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.



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

def description
  @description
end

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

#group_descriptionObject (readonly)

Returns the value of attribute group_description.



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

def group_description
  @group_description
end

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

Instance Method Details

#==(other) ⇒ Object



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

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#hashObject



33
34
35
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 33

def hash
  description.hash
end

#locate(groups) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 37

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



46
47
48
# File 'lib/deep_test/spec/extensions/example_methods.rb', line 46

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