From 534ab0a47aedfe257c6ea9eba185b2e4d6e7f1d5 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Thu, 19 Aug 2021 09:02:14 +0900 Subject: [PATCH] add Page#links test --- spec/page_spec.cr | 6 ++++++ spec/spec_helper.cr | 13 +++++++++++++ 2 files changed, 19 insertions(+) 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")