spec/pushpad/notification_spec.rb in pushpad-0.7.0 vs spec/pushpad/notification_spec.rb in pushpad-0.8.0

- old
+ new

@@ -26,10 +26,11 @@ stub_request(:get, "https://pushpad.xyz/projects/#{options[:project_id]}/notifications"). to_return(status: 403) end def stub_notification_post(project_id, params = {}, response_body = "{}") + stub_request(:post, "https://pushpad.xyz/projects/#{project_id}/notifications"). with(body: hash_including(params)). to_return(status: 201, body: response_body) end @@ -246,13 +247,15 @@ describe "#deliver_to" do include_examples "delivery method", lambda { |notification| notification.deliver_to(100) } + let(:notification_params_to_json) { {} } + shared_examples "notification params" do it "includes the params in the request" do - req = stub_notification_post project_id, notification: notification_params + req = stub_notification_post project_id, notification: notification_params.merge(notification_params_to_json) notification.deliver_to [123, 456] expect(req).to have_been_made.once end end @@ -281,13 +284,19 @@ target_url: "http://example.com/button-link", icon: "http://example.com/assets/button-icon.png", action: "myActionName" } ], - starred: true + starred: true, + send_at: Time.utc(2016, 7, 25, 10, 9) } end + let(:notification_params_to_json) do + { + send_at: "2016-07-25T10:09" + } + end let(:notification) { Pushpad::Notification.new notification_params } include_examples "notification params" end context "with a scalar as a param" do @@ -318,13 +327,15 @@ describe "#broadcast" do include_examples "delivery method", lambda { |notification| notification.broadcast } + let(:notification_params_to_json) { {} } + shared_examples "notification params" do it "includes the params in the request" do - req = stub_notification_post project_id, notification: notification_params + req = stub_notification_post project_id, notification: notification_params.merge(notification_params_to_json) notification.broadcast expect(req).to have_been_made.once end end @@ -353,10 +364,16 @@ target_url: "http://example.com/button-link", icon: "http://example.com/assets/button-icon.png", action: "myActionName" } ], - starred: true + starred: true, + send_at: Time.utc(2016, 7, 25, 10, 9) + } + end + let(:notification_params_to_json) do + { + send_at: "2016-07-25T10:09" } end let(:notification) { Pushpad::Notification.new notification_params } include_examples "notification params" end