Sha256: a33f6177f22e3a2087ef9ee40ab7daae99902396924fda52caf3f0eecf92df6d

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

require './test/sinatra_app'
require 'test/unit'
require 'rack/test'

set :environment, :test

class SintraStaticAssetsTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    Sinatra::Application
  end

  def test_url_for_returns_absolute_paths_and_full_urls
    get '/url_for', {}, 'SCRIPT_NAME' => '/bar'
    assert last_response.ok?
    assert_equal last_response.body,  <<EOD
/bar/
/bar/foo
http://example.org/bar/foo
EOD
  end

  def test_image_tag_returns_sub_uri
    get '/image_tag', {}, 'SCRIPT_NAME' => '/bar'
    assert last_response.ok?
    assert_equal last_response.body,  <<EOD
<img alt="[foo image]" src="/bar/images/foo.jpg">
EOD
  end

  def test_stylesheet_link_tag_returns_sub_uri
    get '/stylesheet_link_tag', {}, 'SCRIPT_NAME' => '/bar'
    assert last_response.ok?
    assert_equal last_response.body,  <<EOD
<link charset="utf-8" href="/bar/stylesheets/winter.css" media="projection" rel="stylesheet" type="text/css">
<link charset="utf-8" href="/bar/stylesheets/summer.css" media="projection" rel="stylesheet" type="text/css">
EOD
  end

  def test_javascript_script_tag_returns_sub_uri
    get '/javascript_script_tag', {}, 'SCRIPT_NAME' => '/bar'
    assert last_response.ok?
    assert_equal last_response.body,  <<EOD
<script charset="iso-8859-2" src="/bar/javascripts/summer.js" type="text/javascript"></script>
EOD
  end

  def test_link_to_tag_returns_sub_uri
    get '/link_to_tag', {}, 'SCRIPT_NAME' => '/bar'
    assert last_response.ok?
    assert_equal last_response.body,  <<EOD
<a href="/bar/topr">Tatry Mountains Rescue Team</a>
EOD
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sinatra-static-assets-1.0.2 test/sinatra_static_assets_test.rb
sinatra-static-assets-1.0.1 test/sinatra_static_assets_test.rb
sinatra-static-assets-1.0.0 test/sinatra_static_assets_test.rb