From 0b130e7da7021527c624add3b16f8c7b8faacc03 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Fri, 11 Jun 2021 08:45:23 +0900 Subject: [PATCH] add page.title test --- spec/page_spec.cr | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/page_spec.cr b/spec/page_spec.cr index 59a642d..c060ba5 100644 --- a/spec/page_spec.cr +++ b/spec/page_spec.cr @@ -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 + + + + page_title + + + +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