0

I'm writing an rspec test which fails at line

 if URI(request.referrer).path.include?('cart')

I want to be able to make the request.referrer include 'cart'

Please let me know if you have any approaches.

i tried the following and they didn't work:

@request.env['HTTP_REFERER']='http://localhost:port/account/cart/id'
post url, params

also tried:

post url, params, {"HTTP_REFERER" => "http://localhost:port/account/cart/id"}
1
  • are these request specs or controller specs?
    – Anthony
    Commented Jan 20, 2018 at 15:21

1 Answer 1

1

Try mocking it:

allow(@request).to receive(:referer).and_return('http://localhost:port/account/cart/id')

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.