Class: Scenario::Fixtures

Inherits:
Object
  • Object
show all
Defined in:
lib/scenario/fixtures.rb

Overview

Easy access to fixture files (HTML, CSS, JSON, etc.)

Class Method Summary collapse

Class Method Details

.[](rel_path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/scenario/fixtures.rb', line 6

def self.[]( rel_path )
  @content_cache ||= {}
  
  unless @content_cache.key?( rel_path )
    path = "#{self.root}/#{rel_path}"
    raise "#{path} doesn't exist or is not a file." unless File.file?( path )
    @content_cache[rel_path] = File.open( path, 'r' ).read
  end
  
  @content_cache[rel_path]
end