Rails 5.1 testing
Today I got almost 300 spec errors when flipping our core app to use Rails 5.1. Why? Well, it’s just syntax in controller, request specs but the syntax makes things much clearer and is probably a welcome change if not a time consuming fix.
get :show, { :id => 1 }, { 'HTTP_REFERER' => '/something' }
get :show, params: { :id => 1 }, headers: { 'HTTP_REFERER' => '/something' }
Now XHR requests are being wonky.
xhr :show, params: { :id => 1 }
NoMethodError:
super: no superclass method `xhr' for #<RSpec::ExampleGroups
Ok that’s make sense.
get :show, :xhr => true, params: { :id => 1 }