Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
SOLVED specifying namespaces in a Rails routing spec.
# Blog module contains Blog app-related code for The Future, You Know?(TM)
module Blog
# BlogController: "main app" controller for our "fancy" blog.
class BlogController < ApplicationController
def index
end
end
end

FINALLY! For the three of you who have been following this epic saga through Gists 9907240 and 9908206, we have finally found the elusive green bar; a mystery wrapped in an enigma disguised as a riddle.

There were two key changes that made this work:

  1. The describe group containing the routing spec must have the annotation :type => :routing; and
  2. The route I was actually trying to get was /blog/blog.

The fact that get 'index' returns success in the third spec in the file is the most flaming of red herrings I've seen in a long, long time.

Green-bar-inducing code and spec files follow. The routing is unchanged from that quoted in the first Gist.

For those who may be interested, I've now blogged about all this.

require 'spec_helper'
# Blog module contains Blog app-related code suitable for gemification
describe Blog::BlogController do
describe :routing, :type => :routing do
it { expect(get '/blog/blog').to be_routable }
# it { expect(get 'index').to route_to controller: 'blog/blog', action: 'index' }
end
describe :helpers do
it { expect(blog_blog_index_path).to eq('/blog/blog')}
end
describe "GET 'index'" do
it 'returns http success' do
get 'index'
response.should be_success
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment