|
123 | 123 | }.to raise_error StripeMock::UnsupportedRequestError
|
124 | 124 | end
|
125 | 125 |
|
| 126 | + describe "listing events" do |
| 127 | + |
| 128 | + it "retrieves all events" do |
| 129 | + customer_created_event = StripeMock.mock_webhook_event('customer.created') |
| 130 | + expect(customer_created_event).to be_a(Stripe::Event) |
| 131 | + expect(customer_created_event.id).to_not be_nil |
| 132 | + |
| 133 | + plan_created_event = StripeMock.mock_webhook_event('plan.created') |
| 134 | + expect(plan_created_event).to be_a(Stripe::Event) |
| 135 | + expect(plan_created_event.id).to_not be_nil |
| 136 | + |
| 137 | + coupon_created_event = StripeMock.mock_webhook_event('coupon.created') |
| 138 | + expect(coupon_created_event).to be_a(Stripe::Event) |
| 139 | + expect(coupon_created_event).to_not be_nil |
| 140 | + |
| 141 | + invoice_created_event = StripeMock.mock_webhook_event('invoice.created') |
| 142 | + expect(invoice_created_event).to be_a(Stripe::Event) |
| 143 | + expect(invoice_created_event).to_not be_nil |
| 144 | + |
| 145 | + invoice_item_created_event = StripeMock.mock_webhook_event('invoiceitem.created') |
| 146 | + expect(invoice_item_created_event).to be_a(Stripe::Event) |
| 147 | + expect(invoice_item_created_event).to_not be_nil |
| 148 | + |
| 149 | + events = Stripe::Event.all |
| 150 | + |
| 151 | + expect(events.count).to eq(5) |
| 152 | + expect(events.map &:id).to include(customer_created_event.id, plan_created_event.id, coupon_created_event.id, invoice_created_event.id, invoice_item_created_event.id) |
| 153 | + expect(events.map &:type).to include('customer.created', 'plan.created', 'coupon.created', 'invoice.created', 'invoiceitem.created') |
| 154 | + end |
| 155 | + |
| 156 | + it "retrieves events with a limit(3)" do |
| 157 | + customer_created_event = StripeMock.mock_webhook_event('customer.created') |
| 158 | + expect(customer_created_event).to be_a(Stripe::Event) |
| 159 | + expect(customer_created_event.id).to_not be_nil |
| 160 | + |
| 161 | + plan_created_event = StripeMock.mock_webhook_event('plan.created') |
| 162 | + expect(plan_created_event).to be_a(Stripe::Event) |
| 163 | + expect(plan_created_event.id).to_not be_nil |
| 164 | + |
| 165 | + coupon_created_event = StripeMock.mock_webhook_event('coupon.created') |
| 166 | + expect(coupon_created_event).to be_a(Stripe::Event) |
| 167 | + expect(coupon_created_event).to_not be_nil |
| 168 | + |
| 169 | + invoice_created_event = StripeMock.mock_webhook_event('invoice.created') |
| 170 | + expect(invoice_created_event).to be_a(Stripe::Event) |
| 171 | + expect(invoice_created_event).to_not be_nil |
| 172 | + |
| 173 | + invoice_item_created_event = StripeMock.mock_webhook_event('invoiceitem.created') |
| 174 | + expect(invoice_item_created_event).to be_a(Stripe::Event) |
| 175 | + expect(invoice_item_created_event).to_not be_nil |
| 176 | + |
| 177 | + events = Stripe::Event.all(limit: 3) |
| 178 | + |
| 179 | + expect(events.count).to eq(3) |
| 180 | + expect(events.map &:id).to include(customer_created_event.id, plan_created_event.id, coupon_created_event.id) |
| 181 | + expect(events.map &:type).to include('customer.created', 'plan.created', 'coupon.created') |
| 182 | + end |
| 183 | + |
| 184 | + end |
| 185 | + |
126 | 186 | end
|
0 commit comments