I am new to testing. I am trying to use stripe-ruby-mock gem with minitest.
In the stripe-ruby-mock docs they describe a dummy example in Rspec that I am trying to translate to minitest:
require 'stripe_mock'
describe MyApp do
let(:stripe_helper) { StripeMock.create_test_helper }
before { StripeMock.start }
after { StripeMock.stop }
it "creates a stripe customer" do
# This doesn't touch stripe's servers nor the internet!
customer = Stripe::Customer.create({
email: '[email protected]',
card: stripe_helper.generate_card_token
})
expect(customer.email).to eq('[email protected]')
end
end
My translation to minitest
require 'test_helper'
require 'stripe_mock'
class SuccessfulCustomerCreationTest < ActionDispatch::IntegrationTest
describe 'create customer' do
def stripe_helper
StripeMock.create_test_helper
end
before do
StripeMock.start
end
after do
StripeMock.stop
end
test "creates a stripe customer" do
customer = Stripe::Customer.create({
email: "[email protected]",
card: stripe_helper.generate_card_token
})
assert_equal customer.email, "[email protected]"
end
end
end
The error
NoMethodError: undefined method `describe' for SuccessfulPurchaseTest:Class
I consulted the minitest docs to make sure describe wasn't specific to Rspec but it turns out it is also used in minitest. I am guessing the implementation isn't done properly. Any help appreciated.
Hi I'm mostly an Rspec guy but I think you're issue is that you are using and integration test case when you should be using an unit test case. Try the following instead
class SuccessfulCustomerCreationTest < MiniTest::Unit::TestCase
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With