Sha256: 1b056ba7eb3bffb6c5e044c0c957ec7f9564c2bc1f60ce01d05b9b633299055c

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require File.join(File.dirname(__FILE__), *%w".. lib sprockets")
require "test/unit"

class Test::Unit::TestCase
  FIXTURES_PATH = File.expand_path(File.join(File.dirname(__FILE__), "fixtures")) unless defined?(FIXTURES_PATH)
  
  protected
    def location_for_fixture(fixture)
      File.join(FIXTURES_PATH, fixture)
    end
    
    def content_of_fixture(fixture)
      IO.read(location_for_fixture(fixture))
    end
  
    def environment_for_fixtures
      Sprockets::Environment.new(FIXTURES_PATH, source_directories_in_fixtures_path)
    end
  
    def source_directories_in_fixtures_path
      Dir[File.join(FIXTURES_PATH, "**", "src")]
    end

    def assert_absolute_location(location, pathname)
      assert_equal location, pathname.absolute_location
    end
    
    def assert_absolute_location_ends_with(location_ending, pathname)
      assert pathname.absolute_location[/#{Regexp.escape(location_ending)}$/]
    end

    def pathname(location, environment = @environment)
      Sprockets::Pathname.new(environment, File.join(FIXTURES_PATH, location))
    end
    
    def source_file(location, environment = @environment)
      Sprockets::SourceFile.new(environment, pathname(location, environment))
    end

    def source_line(line, source_file = nil, line_number = 1)
      Sprockets::SourceLine.new(source_file || source_file("dummy"), line, line_number)
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sstephenson-sprockets-0.3.0 test/test_helper.rb
sstephenson-sprockets-0.4.0 test/test_helper.rb