Rails rspec set subdomain

后端 未结 4 1008
暗喜
暗喜 2020-12-01 04:07

I am using rSpec for testing my application. In my application controller I have a method like so:

def set_current_account
  @current_account ||= Account.fi         


        
4条回答
  •  清歌不尽
    2020-12-01 04:36

    I figured out how to sort this issue.

    In my before block in my specs I simply added:

    before(:each) do
      @request.host = "#{mock_subdomain}.example.com"
    end
    

    This setups up the request.subdomains.first to be the value of the mock_subdomain.

    Hope someone finds this useful as its not explained very well anywhere else on the net.

提交回复
热议问题