Rails: how to check subdomains with RSpec

I am developing an application that is highly dependent on subdomains. It has an application built into the application (module), which will be the basis for administering the application. Call it kong.

I have this code in the routes file:

constraints :subdomain => "kong" do scope :module => "kong", :as => "kong" do resources :clients end end 

How can I check this route, so when I write something like the following, it extracts from the subdomain and only from the subdomain:

 get :index 
+7
source share
1 answer

In the test block, I used something like this to set request.host from the subdomain:

 def get_sub(sub = "one") @request.host = "#{sub}.local.me" end 

I personally would put this in the spec_helper.rb file and the link when you need it.

For you in these tests, you set sub to "kong" , probably like

 before :each do get_sub("kong") end 

This joker also has the answer I found after via Google

+5
source

All Articles