|
19 | 19 | "<html><head><title>Test</title></head><body><p>This is a simplified version of the webpage content.</p></body></html>", |
20 | 20 | ) |
21 | 21 |
|
22 | | - tool = described_class.new({ url: url }, bot_user: bot_user, llm: llm) |
23 | | - result = tool.invoke |
| 22 | + tool = described_class.new(bot_user: bot_user, llm: llm) |
| 23 | + result = tool.invoke(url: url) |
24 | 24 |
|
25 | 25 | expect(result).to have_key(:text) |
26 | 26 | expect(result[:text]).to eq(processed_text) |
|
33 | 33 | # Simulating a failed request |
34 | 34 | stub_request(:get, url).to_return(status: [500, "Internal Server Error"]) |
35 | 35 |
|
36 | | - tool = described_class.new({ url: url }, bot_user: bot_user, llm: llm) |
37 | | - result = tool.invoke |
| 36 | + tool = described_class.new(bot_user: bot_user, llm: llm) |
| 37 | + result = tool.invoke(url: url) |
38 | 38 |
|
39 | 39 | expect(result).to have_key(:error) |
40 | 40 | expect(result[:error]).to include("Failed to retrieve the web page") |
|
48 | 48 | simple_html = "<html><body><p>Simple content.</p></body></html>" |
49 | 49 | stub_request(:get, url).to_return(status: 200, body: simple_html) |
50 | 50 |
|
51 | | - tool = described_class.new({ url: url }, bot_user: bot_user, llm: llm) |
52 | | - result = tool.invoke |
| 51 | + tool = described_class.new(bot_user: bot_user, llm: llm) |
| 52 | + result = tool.invoke(url: url) |
53 | 53 |
|
54 | 54 | expect(result[:text]).to eq("Simple content.") |
55 | 55 | end |
|
59 | 59 | "<html><head><script>console.log('Ignore me')</script></head><body><style>body { background-color: #000; }</style><p>Only relevant content here.</p></body></html>" |
60 | 60 | stub_request(:get, url).to_return(status: 200, body: complex_html) |
61 | 61 |
|
62 | | - tool = described_class.new({ url: url }, bot_user: bot_user, llm: llm) |
63 | | - result = tool.invoke |
| 62 | + tool = described_class.new(bot_user: bot_user, llm: llm) |
| 63 | + result = tool.invoke(url: url) |
64 | 64 |
|
65 | 65 | expect(result[:text]).to eq("Only relevant content here.") |
66 | 66 | end |
|
70 | 70 | "<html><body><div><section><p>Nested paragraph 1.</p></section><section><p>Nested paragraph 2.</p></section></div></body></html>" |
71 | 71 | stub_request(:get, url).to_return(status: 200, body: nested_html) |
72 | 72 |
|
73 | | - tool = described_class.new({ url: url }, bot_user: bot_user, llm: llm) |
74 | | - result = tool.invoke |
| 73 | + tool = described_class.new(bot_user: bot_user, llm: llm) |
| 74 | + result = tool.invoke(url: url) |
75 | 75 |
|
76 | 76 | expect(result[:text]).to eq("Nested paragraph 1. Nested paragraph 2.") |
77 | 77 | end |
|
86 | 86 | stub_request(:get, initial_url).to_return(status: 302, headers: { "Location" => final_url }) |
87 | 87 | stub_request(:get, final_url).to_return(status: 200, body: redirect_html) |
88 | 88 |
|
89 | | - tool = described_class.new({ url: initial_url }, bot_user: bot_user, llm: llm) |
90 | | - result = tool.invoke |
| 89 | + tool = described_class.new(bot_user: bot_user, llm: llm) |
| 90 | + result = tool.invoke(url: initial_url) |
91 | 91 |
|
92 | 92 | expect(result[:url]).to eq(final_url) |
93 | 93 | expect(result[:text]).to eq("Redirected content.") |
|
0 commit comments