diff --git a/spec/page_spec.cr b/spec/page_spec.cr index 4c2f4a1..88b9840 100644 --- a/spec/page_spec.cr +++ b/spec/page_spec.cr @@ -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 diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 74be39a..6000e77 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -22,6 +22,19 @@ WebMock.stub(:get, "example.com/form").to_return(body: <<-BODY BODY ) + +WebMock.stub(:get, "example.com/link").to_return(body: <<-BODY + + + page_title + + + ページのリンク + + +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")