add Page#links test

master
Kanezoh 2021-08-19 09:02:14 +09:00
parent f0ac299bb3
commit 534ab0a47a
2 changed files with 19 additions and 0 deletions

View File

@ -45,4 +45,10 @@ describe "Mechanize Page test" do
form = page.form_with({name: "sample_form"})
form.name.should eq "sample_form"
end
it "return page links" do
agent = Mechanize.new
page = agent.get("http://example.com/link")
page.links.size.should eq 1
end
end

View File

@ -22,6 +22,19 @@ WebMock.stub(:get, "example.com/form").to_return(body: <<-BODY
</html>
BODY
)
WebMock.stub(:get, "example.com/link").to_return(body: <<-BODY
<html>
<head>
<title>page_title</title>
</head>
<body>
<a href="http://example.com/"></a>
</body>
</html>
BODY
)
WebMock.stub(:post, "example.com/post_path")
.with(body: "name=foo&email=bar", headers: {"Content-Type" => "application/x-www-form-urlencoded"})
.to_return(body: "success")