From 194372de15af0aae46c7f618b60180fa2644a2ca Mon Sep 17 00:00:00 2001 From: Jonas Thiel Date: Fri, 24 Feb 2023 10:51:07 +0100 Subject: [PATCH] Code readability --- .rubocop.yml | 1 + Guardfile | 6 ++++-- .../subscription_purchases/subscription_purchase.rb | 3 ++- spec/play_store/acknowledger_spec.rb | 4 ++++ .../product_acknowledgements/acknowledgement_spec.rb | 4 ++++ spec/spec_helper.rb | 10 +++++----- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index bc0c31a..cee8e01 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,6 +22,7 @@ Style/PercentLiteralDelimiters: Metrics/BlockLength: Exclude: - 'spec/**/*' + - '*.gemspec' Security/MarshalLoad: Exclude: - 'lib/candy_check/play_store/discovery_repository.rb' diff --git a/Guardfile b/Guardfile index c658f94..2037978 100644 --- a/Guardfile +++ b/Guardfile @@ -2,8 +2,10 @@ # More info at https://github.com/guard/guard#readme ## Uncomment and set this to only include directories you want to watch -directories %w(lib spec) \ - .select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") } +directories( + %w(lib spec) \ + .select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") }, +) ## Note: if you are using the `directories` clause above and you are not ## watching the project directory ('.'), then you will want to move diff --git a/lib/candy_check/play_store/subscription_purchases/subscription_purchase.rb b/lib/candy_check/play_store/subscription_purchases/subscription_purchase.rb index 9d1068d..7ad89a3 100644 --- a/lib/candy_check/play_store/subscription_purchases/subscription_purchase.rb +++ b/lib/candy_check/play_store/subscription_purchases/subscription_purchase.rb @@ -5,7 +5,8 @@ module SubscriptionPurchases class SubscriptionPurchase include Utils::AttributeReader - # @return [Google::Apis::AndroidpublisherV3::SubscriptionPurchase] the raw subscription purchase from google-api-client + # @return [Google::Apis::AndroidpublisherV3::SubscriptionPurchase] the raw subscription purchase + # from google-api-client attr_reader :subscription_purchase # The payment of the subscription is pending (paymentState) diff --git a/spec/play_store/acknowledger_spec.rb b/spec/play_store/acknowledger_spec.rb index 0fbb1e2..1f1247d 100644 --- a/spec/play_store/acknowledger_spec.rb +++ b/spec/play_store/acknowledger_spec.rb @@ -21,7 +21,9 @@ end end it "when already acknowledged" do + # rubocop:disable Layout/LineLength error_body = "{\n \"error\": {\n \"code\": 400,\n \"message\": \"The purchase is not in a valid state to perform the desired operation.\",\n \"errors\": [\n {\n \"message\": \"The purchase is not in a valid state to perform the desired operation.\",\n \"domain\": \"androidpublisher\",\n \"reason\": \"invalidPurchaseState\",\n \"location\": \"token\",\n \"locationType\": \"parameter\"\n }\n ]\n }\n}\n" + # rubocop:enable Layout/LineLength VCR.use_cassette("play_store/product_acknowledgements/already_acknowledged") do result = subject.acknowledge_product_purchase(package_name: package_name, product_id: product_id, token: token) @@ -33,7 +35,9 @@ end end it "when it has been refunded" do + # rubocop:disable Layout/LineLength error_body = "{\n \"error\": {\n \"code\": 400,\n \"message\": \"The product purchase is not owned by the user.\",\n \"errors\": [\n {\n \"message\": \"The product purchase is not owned by the user.\",\n \"domain\": \"androidpublisher\",\n \"reason\": \"productNotOwnedByUser\"\n }\n ]\n }\n}\n" + # rubocop:enable Layout/LineLength VCR.use_cassette("play_store/product_acknowledgements/refunded") do result = subject.acknowledge_product_purchase(package_name: package_name, product_id: product_id, token: token) diff --git a/spec/play_store/product_acknowledgements/acknowledgement_spec.rb b/spec/play_store/product_acknowledgements/acknowledgement_spec.rb index b7c1d86..c5b15b2 100644 --- a/spec/play_store/product_acknowledgements/acknowledgement_spec.rb +++ b/spec/play_store/product_acknowledgements/acknowledgement_spec.rb @@ -27,7 +27,9 @@ end end it "when already acknowledged" do + # rubocop:disable Layout/LineLength error_body = "{\n \"error\": {\n \"code\": 400,\n \"message\": \"The purchase is not in a valid state to perform the desired operation.\",\n \"errors\": [\n {\n \"message\": \"The purchase is not in a valid state to perform the desired operation.\",\n \"domain\": \"androidpublisher\",\n \"reason\": \"invalidPurchaseState\",\n \"location\": \"token\",\n \"locationType\": \"parameter\"\n }\n ]\n }\n}\n" + # rubocop:enable Layout/LineLength VCR.use_cassette("play_store/product_acknowledgements/already_acknowledged") do result = subject.call! @@ -39,7 +41,9 @@ end end it "when it has been refunded" do + # rubocop:disable Layout/LineLength error_body = "{\n \"error\": {\n \"code\": 400,\n \"message\": \"The product purchase is not owned by the user.\",\n \"errors\": [\n {\n \"message\": \"The product purchase is not owned by the user.\",\n \"domain\": \"androidpublisher\",\n \"reason\": \"productNotOwnedByUser\"\n }\n ]\n }\n}\n" + # rubocop:enable Layout/LineLength VCR.use_cassette("play_store/product_acknowledgements/refunded") do result = subject.call! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b3b49d8..8b10098 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -37,13 +37,13 @@ def in_continuous_integration_environment? ENV["DEBUG"] && Google::APIClient.logger.level = Logger::DEBUG -class MiniTest::Spec - class << self - alias context describe +module MiniTest + class Spec + class << self + alias context describe + end end -end -module MiniTest module Assertions # The first parameter must be ```true```, not coercible to true. def assert_true(obj, msg = nil)