class Perfume::Testing::FixtureFiles

Public: Sometimes you have to test file contents or some biggest chunks of data. Put them in fixtures folder and load using this helper class. Example:

MY_FIXTURE_FILES = FixtureFiles.load('path/to/fixtures/*.txt')
MY_FIXTURE_FILES.each { |content| ... }
puts MY_FIXTURE_FILES['filename.txt']

Public Class Methods

new(dir) click to toggle source
# File lib/perfume/testing/fixture_files.rb, line 23
def initialize(dir)
  @fixtures = load_fixtures(dir)
end

Private Instance Methods

load_fixtures(dir) click to toggle source
# File lib/perfume/testing/fixture_files.rb, line 29
def load_fixtures(dir)
  {}.tap do |fixtures|
    Pathname.glob(dir.to_s) do |entry|
      fixtures[entry.basename.to_s] = entry.read if entry.file?
    end
  end
end