Sha256: 04d143f84a12eebbc2864ccb96fa1a193d9ec216b54f3fe45665b2fed3af0f05
Contents?: true
Size: 725 Bytes
Versions: 15
Compression:
Stored size: 725 Bytes
Contents
require 'pathname' class TestFixtures attr_reader :fixtures_path def initialize @loaded_data = {} @fixtures_path = Pathname(MetricFu.root_dir).join('spec','fixtures') end def load_metric(path) retrieve_data(path) do |path| YAML.load_file( fixture_path(path) ) end end def load_file(path) retrieve_data(path) do |path| File.read( fixture_path(path) ) end end def fixture_path(path) fixtures_path.join(*Array(path)) end private def retrieve_data(path) @loaded_data.fetch(path) do @loaded_data[path] = yield(path) end end end FIXTURE = TestFixtures.new HOTSPOT_DATA = ->(paths) { FIXTURE.load_metric( ['hotspots'].concat(Array(paths)) ) }
Version data entries
15 entries across 15 versions & 1 rubygems