2009-04-15 02:19:57 +00:00
|
|
|
require File.dirname(__FILE__) + "/test_helper"
|
|
|
|
require File.dirname(__FILE__) + "/../rack_app"
|
|
|
|
|
|
|
|
class WebratRackTest < Test::Unit::TestCase
|
|
|
|
def test_visit_returns_response
|
|
|
|
response = visit "/"
|
|
|
|
assert response.ok?
|
|
|
|
end
|
2009-05-11 05:27:04 +00:00
|
|
|
|
2009-04-15 02:19:57 +00:00
|
|
|
def test_last_response_is_available
|
|
|
|
visit "/"
|
|
|
|
assert last_response.ok?
|
|
|
|
end
|
2009-05-11 05:27:04 +00:00
|
|
|
|
2009-04-15 02:19:57 +00:00
|
|
|
def test_last_request_is_available
|
|
|
|
visit "/"
|
|
|
|
assert_equal "/", last_request.env["PATH_INFO"]
|
|
|
|
end
|
|
|
|
|
2009-06-24 13:19:06 +00:00
|
|
|
def test_redirects
|
|
|
|
visit "/redirect_absolute_url"
|
|
|
|
assert_equal "spam", response_body
|
|
|
|
end
|
2009-05-11 05:27:04 +00:00
|
|
|
|
2009-04-15 02:19:57 +00:00
|
|
|
def test_assertions_after_visit
|
|
|
|
visit "/"
|
|
|
|
assert_contain "Hello World"
|
|
|
|
end
|
2009-05-11 05:27:04 +00:00
|
|
|
|
2009-04-15 02:19:57 +00:00
|
|
|
def test_assertions_after_visit
|
|
|
|
get "/"
|
|
|
|
assert_contain "Hello World"
|
|
|
|
end
|
2009-05-11 05:27:04 +00:00
|
|
|
|
2009-04-15 02:19:57 +00:00
|
|
|
# def test_visits_pages
|
|
|
|
# visit "/"
|
|
|
|
# assert response_body.include?("visit")
|
2009-05-11 05:27:04 +00:00
|
|
|
#
|
2009-04-15 02:19:57 +00:00
|
|
|
# click_link "there"
|
|
|
|
# assert response_body.include?('<form method="post" action="/go">')
|
|
|
|
# end
|
2009-05-11 05:27:04 +00:00
|
|
|
#
|
2009-04-15 02:19:57 +00:00
|
|
|
# def test_submits_form
|
|
|
|
# visit "/go"
|
|
|
|
# fill_in "Name", :with => "World"
|
|
|
|
# fill_in "Email", :with => "world@example.org"
|
|
|
|
# click_button "Submit"
|
2009-05-11 05:27:04 +00:00
|
|
|
#
|
2009-04-15 02:19:57 +00:00
|
|
|
# assert response_body.include?("Hello, World")
|
|
|
|
# assert response_body.include?("Your email is: world@example.org")
|
|
|
|
# end
|
2009-05-11 05:27:04 +00:00
|
|
|
#
|
2009-04-15 02:19:57 +00:00
|
|
|
# def test_check_value_of_field
|
|
|
|
# visit "/"
|
|
|
|
# assert field_labeled("Prefilled").value, "text"
|
|
|
|
# end
|
2009-05-11 05:27:04 +00:00
|
|
|
#
|
2009-04-15 02:19:57 +00:00
|
|
|
# def test_follows_internal_redirects
|
|
|
|
# visit "/internal_redirect"
|
|
|
|
# assert response_body.include?("visit")
|
|
|
|
# end
|
2009-05-11 05:27:04 +00:00
|
|
|
#
|
2009-04-15 02:19:57 +00:00
|
|
|
# def test_does_not_follow_external_redirects
|
|
|
|
# visit "/external_redirect"
|
|
|
|
# assert response_code == 302
|
|
|
|
# end
|
|
|
|
end
|