Sha256: 38cf0653d455651c8f48cd8539f3072da09de41200f9942da867ac536530111c

Contents?: true

Size: 984 Bytes

Versions: 2

Compression:

Stored size: 984 Bytes

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'}
  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'}
  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

2 entries across 2 versions & 1 rubygems

Version Path
sinatra-assetpack-0.3.1 test/helpers_test.rb
sinatra-assetpack-0.3.0 test/helpers_test.rb