david icon indicating copy to clipboard operation
david copied to clipboard

how to do rspec testing for /.well-known/core

Open mcr opened this issue 7 years ago • 1 comments

I naturally want to do rspec testing of my CoAP application. It also speaks HTTP(S), although I imagine that production that it will be two completely different deploys.

I have changed things so that david is not automatically chosen for "rails server", so that I can develop in both worlds the same time. So one has to do something like: "bin/rails server david -b ::2 -p 5684"

rspec requests skip the framework layer and goes directly to routes. I can test my controllers via config/routes.rb just fine. But I can't test the resource discovery process, doing a GET to /.well-known/core?rt=est.ace to get the location of the resource and then using it.

I propose that the /.well-known/core processing no longer be special cased in lib/david/resource_discovery.rb's call, but instead be referenced in the applications' routes.rb.

The rails5 way might be to use a concern, I see that this how active-scaffold has gone, but the old rails4 "as_routes" may work as well for this.

mcr avatar Feb 07 '18 19:02 mcr

I am not sure if adding the route completely manually is a good solution. However, I see the problem with /.well-known/core being provided by a middleware and therefor not having a proper route.

Automatically adding routes does not seem to be a solution. We could mount an engine to /.well-known/core with a routing helper (comparable to devise_for for example).

nning avatar Mar 04 '18 15:03 nning