-
-
Notifications
You must be signed in to change notification settings - Fork 1k
assigns
and assert_template
have been removed and extracted to a gem in Rails 5.
#1393
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
Comments
Personally my vote would be no, @cupakromer ? |
I need to think it over a bit. @JonRowe could you expand on your thoughts more? I'd like to understand your reasoning and view on the future of controller tests. |
Sure, my reasoning is that However I'm now realising they've been pulled out to another gem, so for now I'd be ok with just continuing to make the matchers available by using that gem... |
I share my issue: rails/rails-controller-testing#5 . |
So is going to be a problem. Yes, current RSpec does not support Rails 5, but that is changing very soon. However, with |
Nope not true. I just realized
Actually the dependency is going to be Rails >= 5.0 but since it hasn't been released yet we placed it at Rails >= 4.2. In a way, the gem isn't going to be useful until Rails 5.0 rolls out. |
Thanks 😸 I'll look into this.
This is good to know, though that is still a problem. rspec-rails cannot default to including the gem in the gemspec since it still supports other Rails versions. That leaves us with two main choices: implement those methods ourselves or shim stubs for them defaulting to throwing errors if the |
Let me know how I can help since I extracted the two methods into |
There's another possiility: move the rspec-rails stuff that integrates with these features into a separate gem that depends directly on |
I need to dig more to really understand the full impact. They are most heavily used by controller specs. Those two matchers combined with views not being rendered by default, is really what made controller specs isolated. However, reviewing things, this may have an impact on request specs, which seem to allow use of the template matching and view specs. The view specs allow you to stub out partials, layouts, and other things; as well as the ability to "assign" an ivar for the view to use. This could be much more invasive than I had originally anticipated. On a related note for controller specs, I'm a little surprised Rails left the |
Usually used in the next requests views but always set by a controller though... |
I'd like to see this work as a first class behaviour. I think we should soft depend on rails-controller-testing and provide an integration if it's present. I'm happy to work on this. |
I'd be ok with conditionally supporting this, and requiring |
I've just fixed this with fc5fe38 |
…ests#676 - update jsonapi initializer and corresponding JSON response keys - add rails-controller-testing gem to support 'assert_template' and 'assigns' - see rspec/rspec-rails#1393 - update controller tests as Rails5 only accepts keyword arguments - see rails/rails#18323
Updated required gems. Ran `rails app:update` and applied updates. Skipping all tests in user_spec as the use `assigns` which has been removed (rspec/rspec-rails#1393). Could use the gem to add them back in but that file skips majorty of tests anyway so might as well revisit at another point and update the tests to not use assigns. Fixed naming of a couple specs that have a typo and a meaningless name.
Hello, |
assigns
and assert_template
have been remove and extracted to a gem in Rails 5.assigns
and assert_template
have been removed and extracted to a gem in Rails 5.
👋 rspec-rails exists to enable the usage of Rails testing patterns with RSpec. Rails recommends that you write system specs for "end to end" testing and request specs when you do not. Controller specs are thus not recommended. The The render_template matcher is not included by default (you'd need the |
Dear @JonRowe, Thank you very much for your kind time and help :) I am a little bit confused because in https://relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec (the official site for rspec) it states:
This page is about Probably I am missing something here... PS: Please excuse me if I missing something obvious, I just started to learn TDD and RSpec... :) |
They are the two matchers mentioned, one still works
The Rails team have driven the decision to push request specs over controller specs. The underlying functionality comes from Rails. The reason is that controller specs were a partial integration of various Rails functionality and didn't behave as production did. Request specs are the total Rails stack going from the top right down to the response being rendered and are thus a more complete integration test. It's virtually impossible to unit test parts of Rails due to its high level of coupling between its internal components. |
Moving discussion from rspec/rspec-core#1993
The text was updated successfully, but these errors were encountered: