What is the route matcher for?

Monday, June 30, 2014

According to the shoulda page,

- route tests your routes.

And I'm just not sure what it's used for. Especially in an isolated controller unit spec. The best way to find out is to experiment:

describe '#update' do
let(:new_name) { Faker::Lorem.word }
let(:request) { patch :update, id: parent_folder.id, folder: { name: new_name, parent_id: nil, user_id: user.id } }

describe 'response' do
before { request }
subject { response }

it { should route(:get, '/posts/1').to(action: :show, id: 1) }

However, I just get:

undefined method `controller_path' for #<ActionController::TestResponse:0x007fb33036fbb0>

whenever the route matcher is run. Why is this? How can I fix it?

Or should I forget about it? I like unit tests, and this appears to pull the routes file into the spec...