Sha256: 1440a155cd39d9e40bccb6b13a4c0635aa24792a229737531cca5d0b2e658a33

Contents?: true

Size: 582 Bytes

Versions: 10

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

10 entries across 10 versions & 1 rubygems

Version Path
alephant-preview-0.3.9 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.8 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.7 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.6 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.5 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.4 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.3 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.2 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.1 lib/alephant/preview/fixture_loader.rb
alephant-preview-0.3.0 lib/alephant/preview/fixture_loader.rb