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 1 year has passed since last update.

【Rspec】レシーバーの「FactoryBot」の記述を省略する設定

Posted at

FactoryBotの記述を省略し、よりコードをすっきりさせる

インスタンスを作成する記述のたびにFactoryBotを書く手間を減らし、よりコードをすっきりさせていきます。

user = FactoryBot.build(:user, fullname: "")

spec/rails_helper.rbに省略する記述を追加

spec/rails_helper.rb
RSpec.configure do |config|
:
  #下記の記述を追加
  config.include FactoryBot::Syntax::Methods
:
end

設定後

書く手間が減り、よりコードをすっきりさせることができました。

user = FactoryBot.build(:user, fullname: "")

user = build(:user, fullname: "")
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?