|
42 | 42 | end |
43 | 43 | end |
44 | 44 |
|
45 | | - describe "#body" do |
| 45 | + describe "#body!" do |
46 | 46 | it "gets response body" do |
47 | 47 | page.go_to("/with_js") |
48 | 48 | responses = traffic.map(&:response) |
49 | 49 |
|
50 | 50 | expect(responses.size).to eq(4) |
51 | 51 |
|
52 | 52 | expect(responses[0].url).to end_with("/with_js") |
53 | | - expect(responses[0].body).to include("ferrum with_js") |
| 53 | + expect(responses[0].body!).to include("ferrum with_js") |
54 | 54 |
|
55 | 55 | expect(responses[1].url).to end_with("/jquery.min.js") |
56 | | - expect(responses[1].body).to include("jQuery v3.7.1") |
| 56 | + expect(responses[1].body!).to include("jQuery v3.7.1") |
57 | 57 |
|
58 | 58 | expect(responses[2].url).to end_with("/jquery-ui.min.js") |
59 | | - expect(responses[2].body).to include("jQuery UI - v1.13.2") |
| 59 | + expect(responses[2].body!).to include("jQuery UI - v1.13.2") |
60 | 60 |
|
61 | 61 | expect(responses[3].url).to end_with("/test.js") |
62 | | - expect(responses[3].body).to include("This is test.js file content") |
| 62 | + expect(responses[3].body!).to include("This is test.js file content") |
| 63 | + end |
| 64 | + |
| 65 | + it "throws error" do |
| 66 | + page.go_to("/with_js") |
| 67 | + responses = traffic.map(&:response) |
| 68 | + page.go_to("/with_different_resources") |
| 69 | + |
| 70 | + expect(responses[0].url).to end_with("/with_js") |
| 71 | + expect { responses[0].body! }.to raise_error(Ferrum::BrowserError, "No resource with given identifier found") |
| 72 | + end |
| 73 | + end |
| 74 | + |
| 75 | + describe "#body" do |
| 76 | + it "gets response body" do |
| 77 | + page.go_to("/with_js") |
| 78 | + responses = traffic.map(&:response) |
| 79 | + |
| 80 | + expect(responses.size).to eq(4) |
| 81 | + |
| 82 | + expect(responses[0].url).to end_with("/with_js") |
| 83 | + expect(responses[0].body).to include("ferrum with_js") |
| 84 | + end |
| 85 | + |
| 86 | + it "throws error" do |
| 87 | + page.go_to("/with_js") |
| 88 | + responses = traffic.map(&:response) |
| 89 | + page.go_to("/with_different_resources") |
| 90 | + |
| 91 | + expect(responses[0].url).to end_with("/with_js") |
| 92 | + expect(responses[0].body).to be_nil |
63 | 93 | end |
64 | 94 | end |
65 | 95 |
|
|
0 commit comments