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

Version Path
metric_fu-4.11.3 spec/support/test_fixtures.rb
metric_fu-4.11.2 spec/support/test_fixtures.rb
metric_fu-4.11.1 spec/support/test_fixtures.rb
metric_fu-4.11.0 spec/support/test_fixtures.rb
metric_fu-4.10.0 spec/support/test_fixtures.rb
metric_fu-4.9.0 spec/support/test_fixtures.rb
metric_fu-4.8.0 spec/support/test_fixtures.rb
metric_fu-4.7.4 spec/support/test_fixtures.rb
metric_fu-4.7.3 spec/support/test_fixtures.rb
metric_fu-4.7.2 spec/support/test_fixtures.rb
metric_fu-4.7.1 spec/support/test_fixtures.rb
metric_fu-4.7.0 spec/support/test_fixtures.rb
metric_fu-4.6.0 spec/support/test_fixtures.rb
metric_fu-4.5.2 spec/support/test_fixtures.rb
metric_fu-4.5.1 spec/support/test_fixtures.rb