For me, it was a combination of comments from almost all the participants involved so far.
First, I started with this simple test:
it "routes / to the widgets controller" do get('/').should route_to("mozoo/widget#index") end
The result is:
Failures: 1) Mozoo::WidgetController GET widget index routes / to the widgets controller Failure/Error: get('/').should route_to("mozoo/widget#index") ActionController::RoutingError: No route matches {:controller=>"mozoo/widget", :action=>"/"}
So, I switched from get('/') to { :get => '/' } , and everything started to work fine. I do not know why. According to lib / rspec / rails / matchers / routing_matchers.rb L102-105 , there is no difference, but it matters to me. Regardless, thanks @ cameron-pope.
Then I added another fairly simple and very similar test, as shown above:
it "routes root_path to the widgets controller" do { :get => root_path }.should route_to("mozoo/widget#index") end
And got this error:
Failures: 1) Mozoo::WidgetController GET widget index routes root_path to the widgets controller Failure/Error: { :get => '/mozoo' }.should route_to("mozoo/widget#index") No route matches "/mozoo"
So, I added this:
before(:each) { @routes = Mozoo::Engine.routes }
And got a better / different error:
Failures: 1) Mozoo::WidgetController GET widget index routes root_path to the widgets controller Failure/Error: { :get => root_path }.should route_to("mozoo/widget#index") The recognized options <{"controller"=>"mozoo/widget", "action"=>"index", "section"=>"mozoo"}> did not match <{"controller"=>"mozoo/widget", "action"=>"index"}>, difference: <{"section"=>"mozoo"}>. <{"controller"=>"mozoo/widget", "action"=>"index"}> expected but was <{"controller"=>"mozoo/widget", "action"=>"index", "section"=>"mozoo"}>.
From there, I modified my test to include a section (the namespace in which my engine is located):
{ :get => root_path }.should route_to(:controller => "mozoo/widget", :action => "index", :section => "mozoo")
And viola, he passed. Thanks @ steven-anderson.
This next part is odd. After adding another test for a specific widget that used the widget_path URL helper for the named route:
it "will successfully serve the widget show page" do visit widget_path(:foobar) response.should be_success end
The test quickly inflates me:
Failures: 1) GET bubble_summary_row widget will have the content section properly scoped Failure/Error: visit widget_path(:bubble_summary_row) NoMethodError: undefined method `widget_path' for #<RSpec::Core::ExampleGroup::Nested_3:0x0000010748f618> # ./spec/views/mozoo/widgets/show.html.haml_spec.rb:7:in `block (2 levels) in <module:Mozoo>'
So, I added the following spec_helper configuration entry:
RSpec.configure do |config| config.include Testy::Engine.routes.url_helpers end
And BAM! It has passed. Thanks @ sam-soffes. What makes this weird is that later on when I created this comment, I deleted this configuration entry in order to try to return it, and I could not reproduce the error by simply deleting the config entry. Alright, I'm moving on. Hope this long count helps someone.