6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rspec-stripe/test_frameworks/rspec.rb', line 6
def configure!
::RSpec.configure do |config|
when_tagged_with_stripe = { stripe: lambda { |val| !!val } }
config.before(:each, when_tagged_with_stripe) do |ex|
example = ex.respond_to?(:metadata) ? ex : ex.example
recipes = example.metadata[:stripe]
@runner = RSpecStripe::Runner.new(recipes)
@runner.call!
def stripe_customer
@stripe_customer ||= @runner.customer
end
def stripe_plan
@stripe_plan ||= @runner.plan
end
def stripe_subscription
@stripe_subscription ||= @runner.subscription
end
end
config.after(:each, when_tagged_with_stripe) do |ex|
example = ex.respond_to?(:metadata) ? ex : ex.example
@runner.cleanup!
end
end
end
|