Skip to content

Instantly share code, notes, and snippets.

@kazumalab
Last active August 20, 2017 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazumalab/e19d605b37de9d4ab04b1a8b23330d72 to your computer and use it in GitHub Desktop.
Save kazumalab/e19d605b37de9d4ab04b1a8b23330d72 to your computer and use it in GitHub Desktop.
ApplicationController.current_userをstubを使用した場合
require 'rails_helper'
RSpec.describe "UserController", type: :request do
describe "#index" do
let(:user) { FactoryGirl.create(:user) }
context 'success' do
before do
allow_instance_of(ApplicationController).to receive(:current_user).and_return(user)
get user_path user
end
it { expect(response).to render_template :show }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment