12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sorcery 利用時のテストの書き方

Last updated at Posted at 2014-10-23

まあ wiki にあるとおりなんだけど,

まず fixture や factory で login する user 用意して

noam:
  email: whatever@whatever.com
  salt: <%= salt = "asdasdastr4325234324sdfds" %>
  crypted_password: <%= Sorcery::CryptoProviders::BCrypt.encrypt("secret", salt) %>
  activation_state: active

以下のように spec_helper.rb 内で include.

RSpec.configure do |config|
  config.include Sorcery::TestHelpers::Rails::Controller, type: :controller
  config.include Sorcery::TestHelpers::Rails::Integration, type: :feature
end

それでテスト内で

login_user(user) # login
logout_user

という helper method を呼ぶ.
Feature Test での書き方など詳しいことについては Reference のリンクを参照.

Reference

Testing Rails · NoamB/sorcery Wiki

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?