Skip to content

Instantly share code, notes, and snippets.

@smoak
Created September 25, 2014 17:40
Show Gist options
  • Save smoak/bd1eb00971ba1f8d442f to your computer and use it in GitHub Desktop.
Save smoak/bd1eb00971ba1f8d442f to your computer and use it in GitHub Desktop.
Trying to create a test case for missing a slash when dealing with engines.
$ ruby test_case_missing_slash.rb
Run options: --seed 62773
# Running:
D, [2014-09-25T10:40:05.782387 #7511] DEBUG -- :
D, [2014-09-25T10:40:05.782441 #7511] DEBUG -- :
I, [2014-09-25T10:40:05.782843 #7511] INFO -- : Started GET "/test" for 127.0.0.1 at 2014-09-25 10:40:05 -0700
F, [2014-09-25T10:40:05.783768 #7511] FATAL -- :
RuntimeError (Could not find root path for #<TestEngine1::Engine:0x007f3beee14110>):
test_missing_slash.rb:49:in `test_another_get'
FD, [2014-09-25T10:40:05.784740 #7511] DEBUG -- :
D, [2014-09-25T10:40:05.784775 #7511] DEBUG -- :
I, [2014-09-25T10:40:05.784846 #7511] INFO -- : Started GET "/" for 127.0.0.1 at 2014-09-25 10:40:05 -0700
.
Finished in 0.152034s, 13.1549 runs/s, 13.1549 assertions/s.
1) Failure:
BugTest#test_another_get [test_missing_slash.rb:50]:
Failed assertion, no message given.
2 runs, 2 assertions, 1 failures, 0 errors, 0 skips
gem 'rails', '4.1.6'
require 'rails'
require 'action_controller/railtie'
module TestEngine1
class Engine < ::Rails::Engine
end
end
TestEngine1::Engine.routes.draw do
get '/test', to: lambda { |env|
[200, {"Content-Type" => "text/html"}, [env['PATH_INFO']]]
}
end
class TestApp < Rails::Application
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'cookie_store_key'
config.secret_token = 'secret_token'
config.secret_key_base = 'secret_key_base'
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
get '/', to: lambda { |env|
[200, {"Content-Type" => "text/html"}, [env['PATH_INFO']]]
}
mount TestEngine1::Engine => '/'
end
end
require 'minitest/autorun'
require 'rack/test'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
class BugTest < MiniTest::Test
include Rack::Test::Methods
def test_returns_success
get '/'
assert last_response.ok?
end
def test_another_get
get '/test'
assert last_response.ok?
end
private
def app
Rails.application
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment