|
32 | 32 |
|
33 | 33 | describe ".all" do |
34 | 34 | it "makes a new Get request using the correct API endpoint" do |
35 | | - expect(Shipcloud).to receive(:request).with(:get, "webhooks", {}).and_return([]) |
| 35 | + expect(Shipcloud).to receive(:request). |
| 36 | + with(:get, "webhooks", {}). |
| 37 | + and_return("webhooks" => []) |
36 | 38 |
|
37 | 39 | Shipcloud::Webhook.all |
38 | 40 | end |
|
49 | 51 | end |
50 | 52 |
|
51 | 53 | def stub_webhooks_request |
52 | | - allow(Shipcloud).to receive(:request).with(:get, "webhooks", {}).and_return( |
53 | | - [ |
54 | | - { |
55 | | - "id" => "583cfd8b-77c7-4447-a3a0-1568bb9cc553", |
56 | | - "url" => "https://example.com/webhook", |
57 | | - "event_types" => ["shipment.tracking.delayed", "shipment.tracking.delivered"], |
58 | | - "deactivated" => false |
59 | | - }, |
60 | | - { |
61 | | - "id" => "e0ff4250-6c8e-494d-a069-afd9d566e372", |
62 | | - "url" => "https://example.com/webhook", |
63 | | - "event_types" => ["shipment.tracking.delayed", "shipment.tracking.delivered"], |
64 | | - "deactivated" => false |
65 | | - } |
66 | | - ] |
67 | | - ) |
| 54 | + allow(Shipcloud).to receive(:request). |
| 55 | + with(:get, "webhooks", {}). |
| 56 | + and_return("webhooks" => webhooks_array) |
| 57 | + end |
| 58 | + |
| 59 | + def webhooks_array |
| 60 | + [ |
| 61 | + { |
| 62 | + "id" => "583cfd8b-77c7-4447-a3a0-1568bb9cc553", |
| 63 | + "url" => "https://example.com/webhook", |
| 64 | + "event_types" => ["shipment.tracking.delayed", "shipment.tracking.delivered"], |
| 65 | + "deactivated" => false |
| 66 | + }, |
| 67 | + { |
| 68 | + "id" => "e0ff4250-6c8e-494d-a069-afd9d566e372", |
| 69 | + "url" => "https://example.com/webhook", |
| 70 | + "event_types" => ["shipment.tracking.delayed", "shipment.tracking.delivered"], |
| 71 | + "deactivated" => false |
| 72 | + } |
| 73 | + ] |
68 | 74 | end |
69 | 75 | end |
0 commit comments