Parent

Included Modules

Class/Module Index [+]

Quicksearch

DeltacloudUnitTest::UrlForTest

Public Class Methods

create_test_url_content(test_url, url_content, mode) click to toggle source
# File tests/drivers/mock/url_for_test.rb, line 59
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

Public Instance Methods

app() click to toggle source
# File tests/drivers/mock/url_for_test.rb, line 24
def app
  Sinatra::Application
end
test_it_works_for_root() click to toggle source
# File tests/drivers/mock/url_for_test.rb, line 28
def test_it_works_for_root
  verify_url_for("/", "/")
end
test_it_works_for_root_absolute() click to toggle source
# File tests/drivers/mock/url_for_test.rb, line 32
def test_it_works_for_root_absolute
  verify_url_for("/", "http://example.org/", :full)
end
test_it_works_when_given_absolute() click to toggle source
# File tests/drivers/mock/url_for_test.rb, line 40
def test_it_works_when_given_absolute
  verify_url_for("http://test.com", "http://test.com")
end
test_it_works_when_not_at_root_context() click to toggle source
# File tests/drivers/mock/url_for_test.rb, line 44
def test_it_works_when_not_at_root_context
  verify_url_for("/", "context/", :path_only, {}, {"SCRIPT_NAME" => "context"})
end
test_it_works_with_spaces() click to toggle source
# File tests/drivers/mock/url_for_test.rb, line 36
def test_it_works_with_spaces
  verify_url_for("/url with spaces", "/url%20with%20spaces")
end
verify_url_for(url, expected_url, mode=:path_only, params={}, rack_env={}) click to toggle source
# File tests/drivers/mock/url_for_test.rb, line 48
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_i}"
  # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.