Sha256: 96f0272f402a798fb390299ed835c7edf1caf17ae1f2b434976b5987bbe45953

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

require File.expand_path('../test_helper', __FILE__)

class LocalFileTest < UnitTest

  class App < Main

    ABS_FONTS_PATH = File.join(File.expand_path('../', __FILE__), 'app', 'app', 'fonts')

    assets {
      css :application, [ '/css/*.css' ]
      serve '/fonts', :from => 'app/fonts'
      serve '/abs_fonts', :from => ABS_FONTS_PATH
    }
  end

  test "local file for (in existing files)" do
    fn = App.assets.local_file_for '/images/background.jpg'
    assert_equal r('app/images/background.jpg'), fn
  end

  test "local file for (in existing files, custom serve path)" do
    fn = App.assets.local_file_for '/fonts/cantarell-regular-webfont.ttf'
    assert_equal r('app/fonts/cantarell-regular-webfont.ttf'), fn
  end

  test "local file for (in existing files, custom absolute serve path)" do
    fn = App.assets.local_file_for '/abs_fonts/cantarell-regular-webfont.ttf'
    assert_equal "#{App::ABS_FONTS_PATH}/cantarell-regular-webfont.ttf", fn
  end

  test "local file for (in nonexisting files)" do
    fn = App.assets.local_file_for '/images/404.jpg'
    assert fn.nil?
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sinatra-assetpack-0.3.1 test/local_file_test.rb
sinatra-assetpack-0.3.0 test/local_file_test.rb
sinatra-assetpack-0.2.8 test/local_file_test.rb
sinatra-assetpack-0.2.7 test/local_file_test.rb
sinatra-assetpack-0.2.6 test/local_file_test.rb
sinatra-assetpack-0.2.5 test/local_file_test.rb
sinatra-assetpack-0.2.4 test/local_file_test.rb