ruby on rails - Stub Method error in request spec -
I study the API tutorial with ROR (Ruby -2.2, Rail 4.x).
This is a fantastic book to follow, but I have found this issue in the RSPC exam in Chapter 5 (Please mention that Listings 5.9 See.)
Failure / Error: Authentication. Stub & lt ;: request & gt; .and_return & lt; Request & gt; # & Lt; Authentication: 0x000000075fe220 & gt; Not authorized: request
source code:
class authentication includes authenticated end details Authenticable do let (authentication) {Authentication.new} " # Current_user "do @customer = FactoryGirl.create: Customer Request Before the orders ["authorization"] = @ customer.auth_token authentication.stub (: request). And _ Return (Request) Finally "Authorization Header to User"
How can I fix this problem?
spec / controllers / concerns / authenticable_spec .rb
Requires a certified end description in the 'rails_helper' class authentication attributable, type = & gt; : Controller (Authentication) {Authentication.new} describes "#current_user" before you create @username = factoryGreat.quote: User Request. Ideers ["Authorization"] = @ Users: To Get AuthToken (Authentication). To receive (: request) .and_return (request) is finally expected to "give the user to the authorization header" (authentication.current_user.auth_token). Eql @ user.auth_token End End
App /controllers/concerns/authenticable.rb
Module authentic # dev methods DRA current current_user @current_user || = User.find_by (auth_token: request.headers ['authorization']) Enddef request request End End
PDT: A bug exists with the RSPC Stub Controller Assistant method. More context
Comments
Post a Comment