How to request (GET/POST) routes in RSpec that have a wildcard How to request (GET/POST) routes in RSpec that have a wildcard ruby ruby

How to request (GET/POST) routes in RSpec that have a wildcard


(Answering my own question)

This turned out to be a bit of a 'rookie' mistake.

The wildcard (event) part of the route still requires a parameter. I wasn't passing the 'event' parameter, therefore the route was incomplete.

The following code works:

describe "post_event" do  it "should respond with 204" do    params = {      attachment_id: @attachment.uid,      software_id: @license.id,      event: 'some/event'    }    post :post_event, params    response.code.should eq "204"  endend

/*event(.:format) means it's expecting a parameter.

Special note to self and others:

If you ever have routing errors in Rails, verify that you're passing all the parameters.