Sha256: aafe119459057873e0fc847932edbe525c138275546a5c343e40b71aa75e485c
Contents?: true
Size: 1.31 KB
Versions: 6
Compression:
Stored size: 1.31 KB
Contents
require 'tests/common' module DeltacloudUnitTest class UrlForTest < Test::Unit::TestCase include Rack::Test::Methods def app Sinatra::Application end def test_it_works_for_root verify_url_for("/", "/") end def test_it_works_for_root_absolute verify_url_for("/", "http://localhost/", :full) end def test_it_works_with_spaces verify_url_for("/url with spaces", "/url%20with%20spaces") end def test_it_works_when_given_absolute verify_url_for("http://test.com", "http://test.com") end def test_it_works_when_not_at_root_context verify_url_for("/", "context/", :path_only, {}, {"SCRIPT_NAME" => "context"}) end def verify_url_for(url, expected_url, mode=:path_only, params={}, rack_env={}) # generate a unique url for each test test_url = "/url_for_test/#{expected_url.hash}/#{Time.now.to_f}" # Create our sinatra test endpoint self.class.create_test_url_content(test_url, url, mode) # verify the generated url matches what we expect get test_url, params, rack_env last_response.body.should == expected_url end def self.create_test_url_content(test_url, url_content, mode) get test_url do content_type "text/plain" url_for(url_content, mode) end end end end
Version data entries
6 entries across 6 versions & 2 rubygems