Sha256: d7c5f7f1176aa5944547615d30ccccbd3a5b0ab31ea51974d0e50028c91fdd22

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 KB

Contents

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

class HelpersTest < UnitTest
  Main.get('/helper/foo') { img '/images/foo.jpg' }
  Main.get('/helper/email') { img '/images/email.png' }
  Main.get('/helper/css/all') { css :application, :sq }
  Main.get('/helper/css/app') { css :application }
  Main.get('/helper/css/sq') { css :sq }

  test "img non-existing" do
    get '/helper/foo'
    assert body == "<img src='/images/foo.jpg' />"
  end

  test "img existing (development)" do
    app.stubs(:development?).returns(true)
    get '/helper/email'

    assert body =~ %r{src='/images/email.png'}
    assert body =~ %r{width='16'}
    assert body =~ %r{height='16'}
  end

  test "img existing (production)" do
    app.stubs(:development?).returns(false)
    get '/helper/email'

    assert body =~ %r{src='/images/email.[a-f0-9]{32}.png'}
    assert body =~ %r{width='16'}
    assert body =~ %r{height='16'}
  end

  test "css" do
    re = Array.new
    get '/helper/css/app'; re << body
    get '/helper/css/sq';  re << body

    get '/helper/css/all'
    assert body.gsub(/[\r\n]*/m, '') == re.join('')
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sinatra-assetpack-0.2.8 test/helpers_test.rb
sinatra-assetpack-0.2.7 test/helpers_test.rb
sinatra-assetpack-0.2.6 test/helpers_test.rb
sinatra-assetpack-0.2.5 test/helpers_test.rb
sinatra-assetpack-0.2.4 test/helpers_test.rb
sinatra-assetpack-0.2.3 test/helpers_test.rb
sinatra-assetpack-0.2.2 test/helpers_test.rb
sinatra-assetpack-0.2.1 test/helpers_test.rb
sinatra-assetpack-0.2.0 test/helpers_test.rb