add page.title test
parent
29a0969504
commit
0b130e7da7
|
@ -3,6 +3,17 @@ require "webmock"
|
|||
WebMock.stub(:get, "example.com")
|
||||
WebMock.stub(:get, "fail_example.com").to_return(status: 500)
|
||||
WebMock.stub(:get, "body_example.com").to_return(body: "hello")
|
||||
WebMock.stub(:get, "html_example.com").to_return(body:
|
||||
<<-BODY
|
||||
<html>
|
||||
<meta>
|
||||
<head>
|
||||
<title>page_title</title>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
BODY
|
||||
)
|
||||
|
||||
describe "Mechanize Page test" do
|
||||
it "return status code of request" do
|
||||
|
@ -20,4 +31,12 @@ describe "Mechanize Page test" do
|
|||
page = agent.get("http://body_example.com")
|
||||
page.body.should eq "hello"
|
||||
end
|
||||
|
||||
it "return page title" do
|
||||
agent = Mechanize.new
|
||||
page = agent.get("http://example.com/")
|
||||
page.title.should eq ""
|
||||
page = agent.get("http://html_example.com")
|
||||
page.title.should eq "page_title"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue