-
-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support env named parameter to import SERVER_PORT header. #954
Comments
I have test like this, it told me no should method exist. class RoutesTest < ActionController::TestCase
include Shoulda::Matchers::ActionController
setup { request.env['SERVER_PORT'] = '8629' }
test 'test case' do
should route(:get, 'v1/test/hello').to('api/v1/test#hello')
end
end If change to this: class RoutesTest < ActionController::TestCase
include Shoulda::Matchers::ActionController
setup { request.env['SERVER_PORT'] = '8629' }
should route(:get, 'v1/test/hello').to('api/v1/test#hello')
end should exist, but |
It looks like the That said -- |
because i need test route which use constraint to limit only special port can be access。 |
Oh, interesting. I didn't know you could do that. Under the hood the If you can figure out a way to get |
I just tried it. It worked! class RoutesTest < ActionDispatch::IntegrationTest
test 'route' do
# asdfasdf can be replace to any char.
assert_routing('http://asdfasdf.com:8629/v1/test/hello', controller: 'api/v1/test', action: 'hello')
end
end |
And, following is worked too. class RoutesTest < ActionController::TestCase
should route(:get, 'http://example.com:8629/v1/test/hello').to('api/v1/test#hello')
end Thanks. |
Maybe should close by you. Rails 5 current exist Anywhy, port problem is resolved. |
Glad you got it working! I'm not sure what all of the possible values of should route(:get, '/v1/test/hello', port: 8629).to('api/v1/test#hello') We'll have to come to some kind of decision on this. |
Cool, maybe for me, I only occur those two case in recent project. Thanks. |
Okay, this has been added like so:
|
Cool, will try it later. Thanks |
Rails 5 could not get @request object in ActionDispatch::IntegrationTest,
But it support a env name args to support import SERVER_PORT header.
How to do this in should-matcher ?
Thanks.
The text was updated successfully, but these errors were encountered: