2
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 5 years have passed since last update.

[個人的メモ]RSpecでHogeHelerを読み込む方法

Last updated at Posted at 2018-09-10

はじめに

現在勉強中のRailsとRSpecで、RSpec内でHogeHelperの中のメソッドを使いたい場合
どのようにすれば良いのかを調べてもなかなか出てこなかったのでメモします

現在使用中のバージョン

  • ruby 2.4.4p296
  • Rails 5.2.1
  • RSpec 3.8
    • rspec-core 3.8.0
    • rspec-expectations 3.8.1
    • rspec-mocks 3.8.0
    • rspec-rails 3.8.0
    • rspec-support 3.8.0

やり方

spec/rails_helper.rbのなかを変更します

変更内容は以下のように、config.includeで使いたいHelperを呼び出すだけです

spec/rails_helper.rb
RSpec.configure do |config|

# 略

  config.include HogeHelper
end
2
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
2
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?