diff --git a/Gemfile b/Gemfile index 1aa98e4..7e38847 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,7 @@ source "http://rubygems.org" gemspec + +group :test do + gem 'mocha' + gem 'flexmock' +end diff --git a/Gemfile.lock b/Gemfile.lock index ae1d0f6..dc45df0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,6 +11,8 @@ GEM specs: emk-sinatra-url-for (0.2.1) sinatra (>= 0.9.1.1) + flexmock (0.9.0) + mocha (0.9.12) rack (1.3.0) rack-test (0.6.0) rack (>= 1.0) @@ -23,5 +25,7 @@ PLATFORMS ruby DEPENDENCIES + flexmock + mocha rack-test (>= 0.3.0) sinatra-static-assets! diff --git a/test/sinatra_static_assets_test.rb b/test/sinatra_static_assets_test.rb index 60c344f..6afa937 100644 --- a/test/sinatra_static_assets_test.rb +++ b/test/sinatra_static_assets_test.rb @@ -1,6 +1,8 @@ require 'sinatra_app' require 'test/unit' require 'rack/test' +require 'flexmock/test_unit' +require 'mocha' set :environment, :test @@ -53,5 +55,16 @@ EOD Tatry Mountains Rescue Team EOD end - + + def test_tags_returns_time_stamp_when_file_exists + file_path = "#{Sinatra::Application.root}/public/bar/javascripts/summer.js" + File.expects(:"exists?").with(file_path).returns(true) + File.expects(:mtime).with(file_path).returns(123456789) + + get '/javascript_script_tag', {}, 'SCRIPT_NAME' => '/bar' + assert last_response.ok? + assert_equal last_response.body, < +EOD + end end