Module: Perfgate::RSpec::IdResolver

Defined in:
lib/perfgate/rspec/id_resolver.rb

Overview

Computes the stable workload identifier for an RSpec example, per spec section 9.2: ":", unless overridden via perfgate: { id: "..." }.

Class Method Summary collapse

Class Method Details

.explicit_id(example) ⇒ Object



17
18
19
20
21
22
# File 'lib/perfgate/rspec/id_resolver.rb', line 17

def explicit_id(example)
   = example.[:perfgate]
  return nil unless .is_a?(Hash)

  [:id]
end

.relative_spec_path(example) ⇒ Object



24
25
26
27
# File 'lib/perfgate/rspec/id_resolver.rb', line 24

def relative_spec_path(example)
  absolute = File.expand_path(example.[:file_path])
  Pathname.new(absolute).relative_path_from(Pathname.pwd).to_s
end

.resolve(example) ⇒ Object



13
14
15
# File 'lib/perfgate/rspec/id_resolver.rb', line 13

def resolve(example)
  explicit_id(example) || "#{relative_spec_path(example)}:#{example.full_description}"
end