-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix with_routing
not working with get :index
#1777
base: main
Are you sure you want to change the base?
Conversation
Hi penople. This is my first try for rspec and also just a working draft rather then full solution. |
ae5c8be
to
88eadea
Compare
with_routing
not working with get :index
with_routing
not working with get :index
On the other hand we can do it like that https://gist.github.com/sclinede/3dc0565e5ef9cb9d99bbcf6719302c5d#file-controller_example_group-rb-L4-L18 |
@sclinede Can you please add a test that would fail without the patch? |
88eadea
to
610c5e3
Compare
The solution was tested against https://github.com/samphippen/test_issue_817 provided by @penelopezone |
610c5e3
to
9854b4e
Compare
As guys previously mentioned in the thread the problem is that `#get` is called on other context then `#with_routing`. It is caused by https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example/controller_example_group.rb#L5. ActionDispatch::Assertions::RoutingAssertions is adding #with_routing to an assertion_instance, and ActionController::TestCase::Behavior is adding #get to ControllerExampleGroup. So I decided to add an ControllerAssertionDelegator which will include both of them. Actually AssertionDelegator missed some methods, so I featured them in that delegator. Closes rspec#1652
9854b4e
to
afebe67
Compare
I don't get it. The test suit is failing around |
def setup(*methods, &block) | ||
@setup_methods += methods | ||
@setup_blocks << block if block | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may have found it yourself already, but anyway - if you add a def teardown(*); end
here, the spec starts failing with a different error.
So... it looks like I need more time to invest in that change. Hope I'll find it soon :) |
@sclinede Have you had a chance to take a closer look at |
As guys previously mentioned in the thread the problem is that
#get
is called on other context then#with_routing
.It is caused by https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example/controller_example_group.rb#L5.
ActionDispatch::Assertions::RoutingAssertions is adding #with_routing to an assertion_instance, and ActionController::TestCase::Behavior is adding #get to ControllerExampleGroup.
But they are included to different classes and do not affect each other.
So I decided to add an ControllerAssertionDelegator which will include both of them. Actually AssertionDelegator missed some methods, so I featured them in that delegator.
Closes #1652