mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Include Devise Helpers In Your Controller Tests as a rails til
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
|
||||
|
||||
_1005 TILs and counting..._
|
||||
_1006 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -628,6 +628,7 @@ _1005 TILs and counting..._
|
||||
- [Get The Column Names For A Model](rails/get-the-column-names-for-a-model.md)
|
||||
- [Hash Slicing](rails/hash-slicing.md)
|
||||
- [Ignore Poltergeist JavaScript Errors](rails/ignore-poltergeist-javascript-errors.md)
|
||||
- [Include Devise Helpers In Your Controller Tests](rails/include-devise-helpers-in-your-controller-tests.md)
|
||||
- [Inspect Previous Changes To ActiveRecord Object](rails/inspect-previous-changes-to-activerecord-object.md)
|
||||
- [List All Installable Rails Versions](rails/list-all-installable-rails-versions.md)
|
||||
- [List The Enqueued Jobs](rails/list-the-enqueued-jobs.md)
|
||||
|
||||
24
rails/include-devise-helpers-in-your-controller-tests.md
Normal file
24
rails/include-devise-helpers-in-your-controller-tests.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Include Devise Helpers In Your Controller Tests
|
||||
|
||||
For past versions of Devise, you could include `DeviseHelpers` as part of
|
||||
`controller` or `request` type tests to have access to the `sign_in` and
|
||||
`sign_out` helpers.
|
||||
|
||||
```ruby
|
||||
RSpec.configure do |config|
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
end
|
||||
```
|
||||
|
||||
As of [Devise
|
||||
4.2.0+](https://github.com/heartcombo/devise/blob/master/CHANGELOG.md#420---2016-07-01),
|
||||
the `Devise::TestHelpers` have been deprecated. The
|
||||
`Devise::Test::ControllerHelpers` module should instead be included.
|
||||
|
||||
```ruby
|
||||
RSpec.configure do |config|
|
||||
config.include Devise::Test::ControllerHelpers, :type => :controller
|
||||
end
|
||||
```
|
||||
|
||||
[source](https://github.com/heartcombo/devise/blob/98fc5e8e396b66b826528811287ea6680a6d0757/lib/devise/test/controller_helpers.rb#L26)
|
||||
Reference in New Issue
Block a user