From c1bda3d71a409078b68aff2f935719edd1ed7a84 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 29 Apr 2022 01:30:00 +0900 Subject: [PATCH] follow hound rule: prefer single-quoted strings --- lib/fcm.rb | 8 +++++--- spec/fcm_spec.rb | 38 ++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/fcm.rb b/lib/fcm.rb index 37b13e0..08980ce 100644 --- a/lib/fcm.rb +++ b/lib/fcm.rb @@ -52,10 +52,12 @@ def send_notification_v1(message) post_body = { 'message': message } extra_headers = { - "Authorization" => "Bearer #{jwt_token}" + 'Authorization' => "Bearer #{jwt_token}" } for_uri(BASE_URI_V1, extra_headers) do |connection| - response = connection.post("#{@project_name}/messages:send", post_body.to_json) + response = connection.post( + "#{@project_name}/messages:send", post_body.to_json + ) build_response(response) end end @@ -224,7 +226,7 @@ def for_uri(uri, extra_headers = {}) ) do |faraday| faraday.adapter Faraday.default_adapter faraday.headers["Content-Type"] = "application/json" - faraday.headers["Authorization"] = "key=#{@api_key}" + faraday.headers['Authorization'] = "key=#{@api_key}" extra_headers.each do |key, value| faraday.headers[key] = value end diff --git a/spec/fcm_spec.rb b/spec/fcm_spec.rb index 07d367a..e976433 100644 --- a/spec/fcm_spec.rb +++ b/spec/fcm_spec.rb @@ -36,24 +36,24 @@ let(:send_v1_params) do { - "token" => "4sdsx", - "notification" => { - "title" => "Breaking News", - "body" => "New news story available." + 'token' => '4sdsx', + 'notification' => { + 'title' => 'Breaking News', + 'body' => 'New news story available.' }, - "data" => { - "story_id" => "story_12345" + 'data' => { + 'story_id' => 'story_12345' }, - "android" => { - "notification" => { - "click_action": "TOP_STORY_ACTIVITY", - "body" => "Check out the Top Story" + 'android' => { + 'notification' => { + 'click_action' => 'TOP_STORY_ACTIVITY', + 'body' => 'Check out the Top Story' } }, - "apns" => { - "payload" => { - "aps" => { - "category" => "NEW_MESSAGE_CATEGORY" + 'apns' => { + 'payload' => { + 'aps' => { + 'category' => 'NEW_MESSAGE_CATEGORY' } } } @@ -61,13 +61,13 @@ end let(:valid_request_v1_body) do - { "message" => send_v1_params } + { 'message' => send_v1_params } end let(:stub_fcm_send_v1_request) do stub_request(:post, send_v1_url).with( body: valid_request_v1_body.to_json, - headers: valid_request_v1_headers, + headers: valid_request_v1_headers ).to_return( # ref: https://firebase.google.com/docs/cloud-messaging/http-server-ref#interpret-downstream body: "{}", @@ -86,9 +86,11 @@ stub_fcm_send_v1_request end - it "should send notification of HTTP V1 using POST to FCM server" do + it 'should send notification of HTTP V1 using POST to FCM server' do fcm = FCM.new(api_key, json_key_path, project_name) - fcm.send_v1(send_v1_params).should eq(response: "success", body: "{}", headers: {}, status_code: 200) + fcm.send_v1(send_v1_params).should eq( + response: 'success', body: '{}', headers: {}, status_code: 200 + ) stub_fcm_send_v1_request.should have_been_made.times(1) end end