How do I write a Rails 3.1 engine controller test in rspec?

后端 未结 7 2001
北荒
北荒 2020-12-02 12:37

I have written a Rails 3.1 engine with the namespace Posts. Hence, my controllers are found in app/controllers/posts/, my models in app/models/posts, etc. I can test the mod

7条回答
  •  醉梦人生
    2020-12-02 13:06

    Based on this answer I chose the following solution:

    #spec/spec_helper.rb
    RSpec.configure do |config|
     # other code
     config.before(:each) { @routes = UserManager::Engine.routes }
    end
    

    The additional benefit is, that you don't need to have the before(:each) block in every controller-spec.

提交回复
热议问题