Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdickey/9908206 to your computer and use it in GitHub Desktop.
Save jdickey/9908206 to your computer and use it in GitHub Desktop.
Getting closer(?) to figuring out namespaces in a Rails app

SOLVED IT! See this new Gist.

Original follows:

====

After reading /u/Nitrodist's response to my earlier plea for help, I couldn't make requests for /blog/blog (or /blog/blog/, or blog/blog) work.

However, poking around led to this spec file, where only the first of the three specs fails, producing the output in the second attachment.

I'm getting closer, but I still can't quite see the forest for the tree that's bashing me in the nose. Can anyone help?

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' }
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
F..
Failures:
1) Blog::BlogController routing should route #<ActionController::TestResponse:0x007fecf10b3980 @body=[""], @header={"Content-Type"=>"text/html; charset=utf-8"}, @status=200, @sending_file=false, @blank=false, @cache_control={}, @etag=nil, @writer=#<Proc:0x007fecf1da0c10@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/actionpack-3.2.17/lib/action_controller/test_case.rb:229 (lambda)>, @block=nil, @length=0, @content_type="text/html", @charset="utf-8", @template=nil, @request=#<ActionController::TestRequest:0x007fecf824c880 @env={"rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x007fecf1e30b58>, "rack.errors"=>#<StringIO:0x007fecf362e638>, "rack.multithread"=>true, "rack.multiprocess"=>true, "rack.run_once"=>false, "REQUEST_METHOD"=>"GET", "SERVER_NAME"=>"example.org", "SERVER_PORT"=>"80", "QUERY_STRING"=>"", "rack.url_scheme"=>"http", "HTTPS"=>"off", "SCRIPT_NAME"=>nil, "CONTENT_LENGTH"=>"0", "action_dispatch.routes"=>#<ActionDispatch::Routing::RouteSet:0x007fecf2e99cb0>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.secret_token"=>"62a686e8ff68d48ac239202d3f4862a30a92abcfc104970dc7ca6ef1e3eefb835ba9aa9e117638b1dd7d4e3c8422fbcc4b4a185abe1771acfd96127a5742dc3f", "action_dispatch.show_exceptions"=>false, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<ActiveSupport::TaggedLogging:0x007fecf2c0ae90 @logger=#<ActiveSupport::BufferedLogger:0x007fecf2c0bb88 @log_dest=#<File:/Users/jeffdickey/src/rails/meldd/interactor_demo/log/test.log>, @log=#<Logger:0x007fecf2c0ba98 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007fecf2c0b778 @datetime_format=nil>, @formatter=#<Logger::SimpleFormatter:0x007fecf2c0af58 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x007fecf2c0b390 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/Users/jeffdickey/src/rails/meldd/interactor_demo/log/test.log>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007fecf2c0b340 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fecf2c0b188>>>>>>, "action_dispatch.backtrace_cleaner"=>#<Rails::BacktraceCleaner:0x007fecf10a2388 @filters=[#<Proc:0x007fecf10ab988@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:10>, #<Proc:0x007fecf10ab8e8@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:11>, #<Proc:0x007fecf10ab7f8@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:12>, #<Proc:0x007fecf10a9188@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:26>], @silencers=[#<Proc:0x007fecf10a9138@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:15>]>, "HTTP_HOST"=>"test.host", "REMOTE_ADDR"=>"0.0.0.0", "HTTP_USER_AGENT"=>"Rails Testing", "rack.session"=>{}, "rack.session.options"=>{:key=>"rack.session", :path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false, :sidbits=>128, :cookie_only=>true, :secure_random=>SecureRandom, :id=>"dd71bd9772159856f1ca029a1a2eead5"}, "action_dispatch.request.query_parameters"=>{}, "action_dispatch.cookies"=>#<ActionDispatch::Cookies::CookieJar:0x007fecf1da2178 @secret="62a686e8ff68d48ac239202d3f4862a30a92abcfc104970dc7ca6ef1e3eefb835ba9aa9e117638b1dd7d4e3c8422fbcc4b4a185abe1771acfd96127a5742dc3f", @set_cookies={}, @delete_cookies={}, @host="test.host", @secure=false, @closed=false, @cookies={}>, "rack.request.cookie_hash"=>{}, "action_dispatch.request.path_parameters"=>{"controller"=>"blog/blog", "action"=>"index"}, "action_dispatch.request.content_type"=>nil, "action_dispatch.request.request_parameters"=>{}, "action_dispatch.request.flash_hash"=>#<ActionDispatch::Flash::FlashHash:0x007fecf1e30950 @used=#<Set: {}>, @closed=false, @flashes={}, @now=nil>, "PATH_INFO"=>"/blog/blog", "action_dispatch.request.parameters"=>{"controller"=>"blog/blog", "action"=>"index"}, "action_dispatch.request.formats"=>[#<Mime::Type:0x007fecf30a84c0 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html">]}, @formats=nil, @symbolized_path_params={:controller=>"blog/blog", :action=>"index"}, @request_method="GET", @method="GET", @protocol="http://", @remote_ip=nil, @ip=nil, @fullpath="/blog/blog", @set_cookies={}, @cookies={}, @port=80, @filtered_parameters={"controller"=>"blog/blog", "action"=>"index"}>> to {:controller=>"Blog::Blog", :action=>"index"}
Failure/Error: it { expect(get 'index').to route_to 'Blog::Blog#index' }
NoMethodError:
undefined method `values' for #<ActionController::TestResponse:0x007fecf10b3980>
# ./spec/controllers/blog/blog_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 0.14562 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/controllers/blog/blog_controller_spec.rb:7 # Blog::BlogController routing should route #<ActionController::TestResponse:0x007fecf10b3980 @body=[""], @header={"Content-Type"=>"text/html; charset=utf-8"}, @status=200, @sending_file=false, @blank=false, @cache_control={}, @etag=nil, @writer=#<Proc:0x007fecf1da0c10@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/actionpack-3.2.17/lib/action_controller/test_case.rb:229 (lambda)>, @block=nil, @length=0, @content_type="text/html", @charset="utf-8", @template=nil, @request=#<ActionController::TestRequest:0x007fecf824c880 @env={"rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x007fecf1e30b58>, "rack.errors"=>#<StringIO:0x007fecf362e638>, "rack.multithread"=>true, "rack.multiprocess"=>true, "rack.run_once"=>false, "REQUEST_METHOD"=>"GET", "SERVER_NAME"=>"example.org", "SERVER_PORT"=>"80", "QUERY_STRING"=>"", "rack.url_scheme"=>"http", "HTTPS"=>"off", "SCRIPT_NAME"=>nil, "CONTENT_LENGTH"=>"0", "action_dispatch.routes"=>#<ActionDispatch::Routing::RouteSet:0x007fecf2e99cb0>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.secret_token"=>"62a686e8ff68d48ac239202d3f4862a30a92abcfc104970dc7ca6ef1e3eefb835ba9aa9e117638b1dd7d4e3c8422fbcc4b4a185abe1771acfd96127a5742dc3f", "action_dispatch.show_exceptions"=>false, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<ActiveSupport::TaggedLogging:0x007fecf2c0ae90 @logger=#<ActiveSupport::BufferedLogger:0x007fecf2c0bb88 @log_dest=#<File:/Users/jeffdickey/src/rails/meldd/interactor_demo/log/test.log>, @log=#<Logger:0x007fecf2c0ba98 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007fecf2c0b778 @datetime_format=nil>, @formatter=#<Logger::SimpleFormatter:0x007fecf2c0af58 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x007fecf2c0b390 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/Users/jeffdickey/src/rails/meldd/interactor_demo/log/test.log>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007fecf2c0b340 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fecf2c0b188>>>>>>, "action_dispatch.backtrace_cleaner"=>#<Rails::BacktraceCleaner:0x007fecf10a2388 @filters=[#<Proc:0x007fecf10ab988@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:10>, #<Proc:0x007fecf10ab8e8@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:11>, #<Proc:0x007fecf10ab7f8@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:12>, #<Proc:0x007fecf10a9188@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:26>], @silencers=[#<Proc:0x007fecf10a9138@/Users/jeffdickey/src/rails/meldd/interactor_demo/vendor/ruby/2.1.0/gems/railties-3.2.17/lib/rails/backtrace_cleaner.rb:15>]>, "HTTP_HOST"=>"test.host", "REMOTE_ADDR"=>"0.0.0.0", "HTTP_USER_AGENT"=>"Rails Testing", "rack.session"=>{}, "rack.session.options"=>{:key=>"rack.session", :path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false, :sidbits=>128, :cookie_only=>true, :secure_random=>SecureRandom, :id=>"dd71bd9772159856f1ca029a1a2eead5"}, "action_dispatch.request.query_parameters"=>{}, "action_dispatch.cookies"=>#<ActionDispatch::Cookies::CookieJar:0x007fecf1da2178 @secret="62a686e8ff68d48ac239202d3f4862a30a92abcfc104970dc7ca6ef1e3eefb835ba9aa9e117638b1dd7d4e3c8422fbcc4b4a185abe1771acfd96127a5742dc3f", @set_cookies={}, @delete_cookies={}, @host="test.host", @secure=false, @closed=false, @cookies={}>, "rack.request.cookie_hash"=>{}, "action_dispatch.request.path_parameters"=>{"controller"=>"blog/blog", "action"=>"index"}, "action_dispatch.request.content_type"=>nil, "action_dispatch.request.request_parameters"=>{}, "action_dispatch.request.flash_hash"=>#<ActionDispatch::Flash::FlashHash:0x007fecf1e30950 @used=#<Set: {}>, @closed=false, @flashes={}, @now=nil>, "PATH_INFO"=>"/blog/blog", "action_dispatch.request.parameters"=>{"controller"=>"blog/blog", "action"=>"index"}, "action_dispatch.request.formats"=>[#<Mime::Type:0x007fecf30a84c0 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html">]}, @formats=nil, @symbolized_path_params={:controller=>"blog/blog", :action=>"index"}, @request_method="GET", @method="GET", @protocol="http://", @remote_ip=nil, @ip=nil, @fullpath="/blog/blog", @set_cookies={}, @cookies={}, @port=80, @filtered_parameters={"controller"=>"blog/blog", "action"=>"index"}>> to {:controller=>"Blog::Blog", :action=>"index"}
Randomized with seed 0
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