Sha256: 7fb6cd478518e2198ad810f3a200e3aeab4c88a0423c96f8091786b2657d7a9a

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

# rubocop:disable Metrics/BlockNesting
RSpec.configure do |config|
  config.around(:each, stripe: true) do |example|
    config.rspeckled_logger.debug("Before Each  - Start - #{__FILE__}")

    if defined?(::VCR)
      vcr_turned_on = ::VCR.turned_on?
      ::VCR.turn_off!
    end

    if defined?(::WebMock)
      webmock_net_connect = ::WebMock.net_connect_allowed?
      ::WebMock.allow_net_connect!
    end

    ::StripeMock.start if defined?(::StripeMock)

    begin
      ::Stripe::Plan.all(count: 100).each do |plan|
        plan.delete if plan.id.match(/test/i) || plan.name.match(/test/i)
      end

      ::Stripe::Customer.all(count: 100).each(&:delete)
    ensure
      ::VCR.turn_on!                if defined?(::VCR) && vcr_turned_on
      ::WebMock.allow_net_connect!  if defined?(::WebMock) && webmock_net_connect
    end

    config.rspeckled_logger.debug("Before Each  - End   - #{__FILE__}")

    example.run

    config.rspeckled_logger.debug("After Each - Start - #{__FILE__}")

    ::StripeMock.stop if defined?(::StripeMock)

    config.rspeckled_logger.debug("After Each - End   - #{__FILE__}")
  end
end
# rubocop:enable Metrics/BlockNesting

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspeckled-2.1.0 lib/rspeckled/plugins/hooks/stripe.rb