add current_page and back
parent
316a3de570
commit
76d09d6802
|
@ -91,4 +91,13 @@ describe "Mechanize Agent test" do
|
|||
agent.history.size.should eq 2
|
||||
agent.history.last.title.should eq "page_title"
|
||||
end
|
||||
|
||||
it "can back previous page" do
|
||||
agent = Mechanize.new
|
||||
agent.get("http://example.com/")
|
||||
agent.get("http://html_example.com/")
|
||||
agent.current_page.title.should eq "page_title"
|
||||
agent.back
|
||||
agent.current_page.title.should eq ""
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,6 +60,14 @@ class Mechanize
|
|||
@agent.request_headers = request_headers
|
||||
end
|
||||
|
||||
def current_page
|
||||
@agent.current_page
|
||||
end
|
||||
|
||||
def back
|
||||
@agent.history.pop
|
||||
end
|
||||
|
||||
def submit(form)
|
||||
case form.method.upcase
|
||||
when "POST"
|
||||
|
|
|
@ -37,6 +37,10 @@ module MechanizeCr
|
|||
end
|
||||
end
|
||||
|
||||
def current_page
|
||||
@history.last
|
||||
end
|
||||
|
||||
def back
|
||||
@history.pop
|
||||
end
|
||||
|
@ -102,10 +106,6 @@ module MechanizeCr
|
|||
end
|
||||
end
|
||||
|
||||
private def current_page
|
||||
@history.last
|
||||
end
|
||||
|
||||
private def reset_request_header_cookies
|
||||
request_headers.delete("Cookie")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue