Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Trying to understand namespaces through a bog-simple Rails app stand-up. (SOLVED)S
# 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

SOLVED IT! See this Gist. Original follows:

====

OK, here's where I am: trying to get a bog-simple blog app (adapting Avdi Grimm's Objects on Rails e-book example up and happy. With a few twists, as I explain here.

But I can't spec my routes. Why?

In this Gist:

Help?

EDIT: Making progress; now it routes, it just doesn't match expectations. See this new Gist.

InteractorDemo::Application.routes.draw do
namespace :blog do
# get "blog/index"
resources :blog, only: [:index]
end
root to: 'blog/blog#index'
end
require 'spec_helper'
# Blog module contains Blog app-related code suitable for gemification
describe Blog::BlogController do
describe :routing do
# it { expect(get 'index').to route_to 'Blog::blog#index' }
# it { expect(get '/index').to route_to 'Blog::blog#index' }
# it { expect(get 'blog/index').to route_to 'Blog::blog#index' }
# it { expect(get '/blog/index').to route_to 'Blog::blog#index' }
it { expect(get '/blog/blog/index').to route_to 'Blog::blog#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
teaspoon /teaspoon Teaspoon::Engine
blog_blog_index GET /blog/blog(.:format) blog/blog#index
root / blog/blog#index
Routes for Teaspoon::Engine:
GET /fixtures/*filename(.:format) teaspoon/spec#fixtures
GET /:suite(.:format) teaspoon/spec#runner {:suite=>"default"}
POST /:suite/hooks(/:group)(.:format) teaspoon/spec#hooks {:suite=>"default", :group=>"default"}
root / teaspoon/spec#suites
F..
Failures:
1) Blog::BlogController routing
Failure/Error: it { expect(get '/blog/index').to route_to 'blog#index' }
ActionController::RoutingError:
No route matches {:controller=>"blog/blog", :action=>"/blog/index"}
# ./spec/controllers/blog/blog_controller_spec.rb:11:in `block (3 levels) in <top (required)>'
Finished in 0.06787 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/controllers/blog/blog_controller_spec.rb:11 # Blog::BlogController routing
Randomized with seed 13647
Coverage report generated for RSpec to /Users/jeffdickey/src/rails/meldd/interactor_demo/coverage. 8 / 8 LOC (100.0%) covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment