Process HEAD requests as GET
When I'm using remote browser (such as Browserstuck) my tests are failed with the following message:
#<ActionController::RoutingError: No route matches [HEAD] "/rack_session/edit">
Rails had the same issue with HEAD requests and it was fixed here: https://github.com/rails/rails/pull/19431 . So, they just process HEAD requests as GET.
P.S. I really don't know how to cover this case with RSpec and I would appreciate if you give me an advice.
Browserstuck
BrowserStack perhaps ? Interesting why they do HEAD instead of GET. Any extra info?
I really don't know how to cover this case with RSpec
I believe ( ⛪️ ) we can test it against rack_test driver here:
https://github.com/railsware/rack_session_access/blob/master/spec/middleware_spec.rb#L135-L153
using page.driver.browser.head() instead of visit.
Looks like head is not exposed as api method by cabybara because usually you can't do it in real browser as user.
More info:
- https://github.com/teamcapybara/capybara/blob/master/lib/capybara/rack_test/driver.rb#L101
- https://github.com/teamcapybara/capybara/blob/master/lib/capybara/rack_test/browser.rb#L4
- https://github.com/rack-test/rack-test/blob/master/lib/rack/test/methods.rb#L66
Thank you for response, @ayanko !
BrowserStack perhaps ?
Oh, yes, BrowserStack of course. 😬
Interesting why they do HEAD instead of GET. Any extra info?
They don't use HEAD instead of GET. They use both of them. Request order in my log file looks like:
Started GET "/rack_session/edit" for 127.0.0.1 at 2018-05-28 17:29:15 +0400
Started PUT "/rack_session" for 127.0.0.1 at 2018-05-28 17:29:19 +0400
Started HEAD "/rack_session/edit" for 127.0.0.1 at 2018-05-28 17:29:20 +0400