Stripping whitespace
This commit is contained in:
parent
3e71ae3733
commit
453cb4b3eb
@ -15,7 +15,7 @@ module Webrat
|
|||||||
else
|
else
|
||||||
gem "nokogiri", ">= 1.0.6"
|
gem "nokogiri", ">= 1.0.6"
|
||||||
end
|
end
|
||||||
|
|
||||||
require "nokogiri"
|
require "nokogiri"
|
||||||
require "webrat/core/xml/nokogiri"
|
require "webrat/core/xml/nokogiri"
|
||||||
end
|
end
|
||||||
|
@ -287,7 +287,7 @@ For example:
|
|||||||
send "#{http_method}", url, data || {}, headers
|
send "#{http_method}", url, data || {}, headers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_location
|
def response_location
|
||||||
canonicalize_url(response.headers["Location"])
|
canonicalize_url(response.headers["Location"])
|
||||||
end
|
end
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
module Webrat
|
module Webrat
|
||||||
class RackTestSession < Session
|
class RackTestSession < Session
|
||||||
|
|
||||||
def initialize(rack_test_session) #:nodoc:
|
def initialize(rack_test_session) #:nodoc:
|
||||||
super()
|
super()
|
||||||
@rack_test_session = rack_test_session
|
@rack_test_session = rack_test_session
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_body
|
def response_body
|
||||||
response.body
|
response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_code
|
def response_code
|
||||||
response.status
|
response.status
|
||||||
end
|
end
|
||||||
|
|
||||||
def response
|
def response
|
||||||
@rack_test_session.last_response
|
@rack_test_session.last_response
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def process_request(http_method, url, data = {}, headers = {})
|
def process_request(http_method, url, data = {}, headers = {})
|
||||||
headers ||= {}
|
headers ||= {}
|
||||||
data ||= {}
|
data ||= {}
|
||||||
|
|
||||||
env = headers.merge(:params => data, :method => http_method.to_s.upcase)
|
env = headers.merge(:params => data, :method => http_method.to_s.upcase)
|
||||||
@rack_test_session.request(url, env)
|
@rack_test_session.request(url, env)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ class Test::Unit::TestCase
|
|||||||
include Rack::Test::Methods
|
include Rack::Test::Methods
|
||||||
include Webrat::Methods
|
include Webrat::Methods
|
||||||
include Webrat::Matchers
|
include Webrat::Matchers
|
||||||
|
|
||||||
def app
|
def app
|
||||||
RackApp.new
|
RackApp.new
|
||||||
end
|
end
|
||||||
|
@ -6,12 +6,12 @@ class WebratRackTest < Test::Unit::TestCase
|
|||||||
response = visit "/"
|
response = visit "/"
|
||||||
assert response.ok?
|
assert response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_last_response_is_available
|
def test_last_response_is_available
|
||||||
visit "/"
|
visit "/"
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_last_request_is_available
|
def test_last_request_is_available
|
||||||
visit "/"
|
visit "/"
|
||||||
assert_equal "/", last_request.env["PATH_INFO"]
|
assert_equal "/", last_request.env["PATH_INFO"]
|
||||||
@ -21,45 +21,45 @@ class WebratRackTest < Test::Unit::TestCase
|
|||||||
visit "/redirect_absolute_url"
|
visit "/redirect_absolute_url"
|
||||||
assert_equal "spam", response_body
|
assert_equal "spam", response_body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assertions_after_visit
|
def test_assertions_after_visit
|
||||||
visit "/"
|
visit "/"
|
||||||
assert_contain "Hello World"
|
assert_contain "Hello World"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assertions_after_visit
|
def test_assertions_after_visit
|
||||||
get "/"
|
get "/"
|
||||||
assert_contain "Hello World"
|
assert_contain "Hello World"
|
||||||
end
|
end
|
||||||
|
|
||||||
# def test_visits_pages
|
# def test_visits_pages
|
||||||
# visit "/"
|
# visit "/"
|
||||||
# assert response_body.include?("visit")
|
# assert response_body.include?("visit")
|
||||||
#
|
#
|
||||||
# click_link "there"
|
# click_link "there"
|
||||||
# assert response_body.include?('<form method="post" action="/go">')
|
# assert response_body.include?('<form method="post" action="/go">')
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# def test_submits_form
|
# def test_submits_form
|
||||||
# visit "/go"
|
# visit "/go"
|
||||||
# fill_in "Name", :with => "World"
|
# fill_in "Name", :with => "World"
|
||||||
# fill_in "Email", :with => "world@example.org"
|
# fill_in "Email", :with => "world@example.org"
|
||||||
# click_button "Submit"
|
# click_button "Submit"
|
||||||
#
|
#
|
||||||
# assert response_body.include?("Hello, World")
|
# assert response_body.include?("Hello, World")
|
||||||
# assert response_body.include?("Your email is: world@example.org")
|
# assert response_body.include?("Your email is: world@example.org")
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# def test_check_value_of_field
|
# def test_check_value_of_field
|
||||||
# visit "/"
|
# visit "/"
|
||||||
# assert field_labeled("Prefilled").value, "text"
|
# assert field_labeled("Prefilled").value, "text"
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# def test_follows_internal_redirects
|
# def test_follows_internal_redirects
|
||||||
# visit "/internal_redirect"
|
# visit "/internal_redirect"
|
||||||
# assert response_body.include?("visit")
|
# assert response_body.include?("visit")
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# def test_does_not_follow_external_redirects
|
# def test_does_not_follow_external_redirects
|
||||||
# visit "/external_redirect"
|
# visit "/external_redirect"
|
||||||
# assert response_code == 302
|
# assert response_code == 302
|
||||||
|
@ -101,7 +101,7 @@ describe "click_link" do
|
|||||||
webrat_session.should_receive(:get).with("http://www.example.com/page", {})
|
webrat_session.should_receive(:get).with("http://www.example.com/page", {})
|
||||||
click_link /_text_/
|
click_link /_text_/
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should click links by title" do
|
it "should click links by title" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<html>
|
<html>
|
||||||
@ -111,7 +111,7 @@ describe "click_link" do
|
|||||||
webrat_session.should_receive(:get).with("http://www.example.com/page", {})
|
webrat_session.should_receive(:get).with("http://www.example.com/page", {})
|
||||||
click_link 'piddle'
|
click_link 'piddle'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should click links by title regex" do
|
it "should click links by title regex" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<html>
|
<html>
|
||||||
@ -121,7 +121,7 @@ describe "click_link" do
|
|||||||
webrat_session.should_receive(:get).with("http://www.example.com/page", {})
|
webrat_session.should_receive(:get).with("http://www.example.com/page", {})
|
||||||
click_link /iddle/
|
click_link /iddle/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it "should click rails javascript links with authenticity tokens" do
|
it "should click rails javascript links with authenticity tokens" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
|
@ -153,7 +153,7 @@ describe "field_labeled" do
|
|||||||
should_return_a Webrat::TextField, :for => "The Label"
|
should_return_a Webrat::TextField, :for => "The Label"
|
||||||
with_an_id_of "element_42", :for => "The Label"
|
with_an_id_of "element_42", :for => "The Label"
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "finding a field whose label ends with an non word character" do
|
describe "finding a field whose label ends with an non word character" do
|
||||||
using_this_html <<-HTML
|
using_this_html <<-HTML
|
||||||
<html>
|
<html>
|
||||||
@ -163,7 +163,7 @@ describe "field_labeled" do
|
|||||||
</form>
|
</form>
|
||||||
</html>
|
</html>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
should_return_a Webrat::TextField, :for => "License #"
|
should_return_a Webrat::TextField, :for => "License #"
|
||||||
with_an_id_of "element_42", :for => "License #"
|
with_an_id_of "element_42", :for => "License #"
|
||||||
should_raise_error_matching /Could not find .* "Other License #"/, :for => "Other License #"
|
should_raise_error_matching /Could not find .* "Other License #"/, :for => "Other License #"
|
||||||
|
@ -71,7 +71,7 @@ describe "select_date" do
|
|||||||
select_date "December 25, 2003"
|
select_date "December 25, 2003"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work when the label ends in a non word character" do
|
it "should work when the label ends in a non word character" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<html>
|
<html>
|
||||||
|
@ -231,7 +231,7 @@ describe "select" do
|
|||||||
}.should_not raise_error(Webrat::NotFoundError)
|
}.should_not raise_error(Webrat::NotFoundError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should submit duplicates selected options as a single value" do
|
it "should submit duplicates selected options as a single value" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<html>
|
<html>
|
||||||
@ -241,9 +241,9 @@ describe "select" do
|
|||||||
</form>
|
</form>
|
||||||
</html>
|
</html>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
webrat_session.should_receive(:post).with("http://www.example.com/login", "clothes" => "pants")
|
webrat_session.should_receive(:post).with("http://www.example.com/login", "clothes" => "pants")
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user