Skip to content

Commit

Permalink
Code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
jnbt committed Feb 24, 2023
1 parent 5588411 commit 194372d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Style/PercentLiteralDelimiters:
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
- '*.gemspec'
Security/MarshalLoad:
Exclude:
- 'lib/candy_check/play_store/discovery_repository.rb'
Expand Down
6 changes: 4 additions & 2 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions spec/play_store/acknowledger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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!
Expand Down
10 changes: 5 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 194372d

Please sign in to comment.