Where should I store methods to make them available both to my application and to RSpec?

前端 未结 3 1238
梦毁少年i
梦毁少年i 2020-12-18 11:42

I need to create some methods that are available both to my application (models, views and controllers) and to RSpec.

Specifically I need to create some path_helper

3条回答
  •  感动是毒
    2020-12-18 12:08

    You can make RSpec include a module by (in spec/spec_helper.rb):

    RSpec.configure do |config|
      config.include YourModule
    end
    

    If you want to use routing path helpers, you can include them like this:

    RSpec.configure do |config|
      config.include Rails.application.routes.url_helpers
    end
    

提交回复
热议问题