我是新來的測試。我正在嘗試用minitest使用條紋紅寶石模擬寶石。條紋紅寶石模擬寶石與MINITEST
在條紋紅寶石模擬文檔他們描述Rspec的一個虛擬的例子,我想翻譯成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
我翻譯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
錯誤
NoMethodError: undefined method `describe' for SuccessfulPurchaseTest:Class
我查閱了minitest文檔以確保describe
不是特定於R規範,但事實證明,它也用於minitest。我猜測實施沒有做好。任何幫助讚賞。