I’ve written cover story 2, “[Practical] Kotlin”, in WEB+DB PRESS Vol. 109. My parts are chapter 2, 3 and 5.
Tag Archives: [:ja]テスト[:en]Test[:]
(日本語) JUnit 5 ユーザーズガイド を読む 1
RSpec: Test Helper Method using current_user function
I’ll introduce the way to test rails helper code that uses current_user method provided by device gem.
Environment
- Ruby 2.2.2
- Rails 4.1.8
- RSpec 3.1.0
Test Target
The function we are going to test is below. It compare the return value of current_user method and user_id given as argument, and check the argument user_id is of current login user or not.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
module ExampleHelper # check if the id is of current user # ==== Parameter # * +user_id+ # ==== Return # Boolean def is_current_user?(user_id) if current_user && current_user.id == user_id return true end return false end end |





