Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting undefined method key?' for nil:NilClass when tos_acceptance` key is not passed #794

Open
rohitjoshixyz opened this issue Oct 18, 2021 · 0 comments

Comments

@rohitjoshixyz
Copy link

I am trying to mock Stripe::Account.update call which I use to update the metadata field in stripe.
But when I pass metadata only metadata key in arguments, I get the following error in the gem.

Stripe::Account.update(community.payment_processor.processor_id,
         { metadata: stripe_connected_account_metadata })
     
     NoMethodError:
       undefined method `key?' for nil:NilClass
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/stripe-ruby-mock-f291ba4e33cf/lib/stripe_mock/request_handlers/accounts.rb:65:in `blank_value?'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/stripe-ruby-mock-f291ba4e33cf/lib/stripe_mock/request_handlers/accounts.rb:32:in `update_account'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/stripe-ruby-mock-f291ba4e33cf/lib/stripe_mock/instance.rb:129:in `mock_request'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/stripe-ruby-mock-f291ba4e33cf/lib/stripe_mock/api/instance.rb:10:in `block in start'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/stripe-5.30.0/lib/stripe/api_operations/request.rb:25:in `execute_resource_request'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/stripe-5.30.0/lib/stripe/api_operations/save.rb:27:in `update'
     # ./app/services/update_stripe_metadata_service.rb:18:in `update_stripe_connected_account_info'
     # ./app/services/update_stripe_metadata_service.rb:11:in `perform'
     # ./app/services/communities/owner_updation_service.rb:20:in `block in perform'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:310:in `block in within_new_transaction'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:308:in `within_new_transaction'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:209:in `transaction'
     # ./app/services/communities/owner_updation_service.rb:14:in `perform'
     # ./spec/services/communities/owner_updation_service_spec.rb:70:in `block (3 levels) in <top (required)>'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:262:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:262:in `block in run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:508:in `block in with_around_and_singleton_context_hooks'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:465:in `block in with_around_example_hooks'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:486:in `block in run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:626:in `block in run_around_example_hooks_for'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-rails-5.0.1/lib/rspec/rails/adapters.rb:75:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:390:in `execute_with'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
     # ./spec/spec_helper.rb:123:in `block (2 levels) in <top (required)>'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:390:in `execute_with'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
     # ./spec/spec_helper.rb:113:in `block (2 levels) in <top (required)>'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:390:in `execute_with'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
     # ./spec/support/vcr_setup.rb:13:in `block (2 levels) in <top (required)>'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:390:in `execute_with'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/webmock-3.12.2/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:390:in `execute_with'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:124:in `block in run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:110:in `loop'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:110:in `run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-retry-0.6.2/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:37:in `block (2 levels) in setup'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:390:in `execute_with'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:629:in `run_around_example_hooks_for'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:486:in `run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:465:in `with_around_example_hooks'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:508:in `with_around_and_singleton_context_hooks'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:259:in `run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:644:in `block in run_examples'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:640:in `map'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:640:in `run_examples'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:606:in `run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:607:in `block in run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:607:in `map'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:607:in `run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:121:in `map'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2067:in `with_suite_hooks'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:116:in `block in run_specs'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/reporter.rb:74:in `report'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:115:in `run_specs'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:89:in `run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/exe/rspec:4:in `<top (required)>'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/bin/rspec:23:in `load'
     # /Users/rohitjoshi/.rbenv/versions/2.6.5/bin/rspec:23:in `<main>'

Passing an additional key as tos_acceptance: {} fixes the error but I do not want to update that key on production. Please fix this bug

metadata: {
        user_id: community.owner.id,
        community_id: community.id,
        community_owner_email: community.owner.email,
        community_member_id: old_community_member.id,
        stripe_customer_id: stripe_customer_mock.id
      },
      tos_acceptance: {}
    }```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant