Sha256: 747e31f43787b4aa8d4f3f0c10e52f37aeda132dd9a19ae59fa274f126e3a33a

Contents?: true

Size: 582 Bytes

Versions: 5

Compression:

Stored size: 582 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

5 entries across 5 versions & 1 rubygems

Version Path
alephant-preview-0.5.3 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.5.2 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.5.1 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.5.0 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.4.0 lib/alephant/preview/fixture_loader.rb