From 1a58c0806b54503416c517acc7d66afd3e5a56cd Mon Sep 17 00:00:00 2001 From: Wlodek Bzyl Date: Sun, 5 Jul 2009 18:28:12 +0200 Subject: [PATCH] added tests --- Rakefile | 2 +- test/sinatra_app.rb | 10 +++++++++- test/sinatra_static_assets_test.rb | 29 ++++++++++++++++++++++------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Rakefile b/Rakefile index 80dd49a..e7782d2 100644 --- a/Rakefile +++ b/Rakefile @@ -20,7 +20,7 @@ This Sinatra extensions provides following helper methods: gemspec.files = %w{TODO VERSION.yml} + FileList['lib/**/*.rb', 'test/**/*.rb', 'examples/**/*'] gemspec.add_runtime_dependency 'rack', '>=1.0.0' - gemspec.add_runtime_dependency 'sinatra' + gemspec.add_runtime_dependency 'sinatra', '>=0.9.1' gemspec.add_runtime_dependency 'emk-sinatra-url-for', '>=0.2.1' gemspec.add_development_dependency 'rack-test', '>=0.3.0' diff --git a/test/sinatra_app.rb b/test/sinatra_app.rb index ae3bd4d..e67d4ea 100644 --- a/test/sinatra_app.rb +++ b/test/sinatra_app.rb @@ -2,8 +2,9 @@ require 'rubygems' require 'sinatra' require 'sinatra/url_for' +require 'sinatra/static_assets' -get "/" do +get "/url_for" do content_type "text/plain" <<"EOD" #{url_for("/")} @@ -11,3 +12,10 @@ get "/" do #{url_for("/foo", :full)} EOD end + +get "/image_tag" do + content_type "text/plain" + <<"EOD" +#{image_tag("/images/foo.jpg", :alt => "[foo image]")} +EOD +end diff --git a/test/sinatra_static_assets_test.rb b/test/sinatra_static_assets_test.rb index 2814be6..05f6991 100644 --- a/test/sinatra_static_assets_test.rb +++ b/test/sinatra_static_assets_test.rb @@ -11,14 +11,29 @@ class SintraStaticAssetsTest < Test::Unit::TestCase Sinatra::Application end - def test_it_says_hello_world - get '/' + def test_url_for_returns_absolute_paths_and_full_urls + get '/url_for', {}, 'SCRIPT_NAME' => '/bar' assert last_response.ok? - assert_equal 'Hello World', last_response.body + assert_equal last_response.body, < '/bar' + assert last_response.ok? + assert_equal last_response.body, < +EOD end - def test_it_says_hello_to_a_person - get '/', :name => 'Simon' - assert last_response.body.include?('Simon') - end + end + +__END__ + +stylesheet_link_tag "/stylesheets/screen.css", "/stylesheets/summer.css", :media => "projection" +javascript_script_tag "/javascripts/jquery.js", "/javascripts/summer.js", :charset => "iso-8859-2" +link_to "Tatry Mountains Rescue Team", "/topr"