0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RSpecで_spec.rbファイルの先頭行にrequire 'rails_helper'を忘れたときのエラー

Last updated at Posted at 2021-04-26

こんなエラーになりました。

spec/models/address_purchase_spec.rb
% bundle exec rspec spec/models/address_purchase_spec.rb

An error occurred while loading ./spec/models/address_purchase_spec.rb.
Failure/Error:
  RSpec.describe AddressPurchase, type: :model do
    describe '商品購入テスト' do
      before do
        # @address_purchase = FactoryBot.build(:address_purchase)
      end
  
      it 'すべての値が正しく入力されていれば保存できること' do
      end
      it '郵便番号が空だと保存できないこと' do
        @address_purchase.postal_code = ''


NameError:
  uninitialized constant AddressPurchase
# ./spec/models/address_purchase_spec.rb:2:in `<top (required)>'
No examples found.

ちなみにrequire 'rails_helper'は

20210426-205938.png

のrails_helper.rbを読みにいっています。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?