Sha256: c9f187949334a688f0177fce24616e02b6fa0e29eccf02373f5864b8bab3805b

Contents?: true

Size: 576 Bytes

Versions: 2

Compression:

Stored size: 576 Bytes

Contents

module Alephant
  module Preview
    class FixtureLoader
      attr_reader :base_path, :current_fixture, :fixtures

      def initialize(base_path)
        @base_path = base_path
        @fixtures  = Dir.glob("#{base_path}/fixtures/*")
      end

      def get(_uri)
        OpenStruct.new(
          status: 200,
          body:   fixture
        )
      end

      protected

      def fixture
        path = fixtures.shift
        raise "There isn't a fixture matching the request call, please add one" if path.nil?
        File.open(path).read
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alephant-preview-0.6.1 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.6.0 lib/alephant/preview/fixture_loader.rb