From 979c5b4c3a9d5d3c0a70a7ce0aa44f50025ee460 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Tue, 10 Aug 2021 14:24:47 +0900 Subject: [PATCH] add history max_size test --- spec/agent_spec.cr | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/agent_spec.cr b/spec/agent_spec.cr index 634e80e..e6b9dbe 100644 --- a/spec/agent_spec.cr +++ b/spec/agent_spec.cr @@ -42,4 +42,18 @@ describe "Mechanize Agent test" do agent.back agent.current_page.title.should eq "" end + + it "can set maximum number of items allowed in the history" do + agent1 = Mechanize.new + agent1.get("http://example.com/") + agent1.get("http://example.com/form") + agent1.history.size.should eq 2 + # set max size + agent2 = Mechanize.new + agent2.max_history = 1 + agent2.get("http://example.com/") + agent2.get("http://example.com/form") + agent2.history.size.should eq 1 + agent2.history.pop.uri.to_s.should eq "http://example.com/form" + end end