Fix with_routing not working with get :index#1777
Fix with_routing not working with get :index#1777sclinede wants to merge 2 commits intorspec:mainfrom
with_routing not working with get :index#1777Conversation
|
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 :indexwith_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.
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
#getis 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