Last active
August 20, 2017 06:10
-
-
Save kazumalab/e19d605b37de9d4ab04b1a8b23330d72 to your computer and use it in GitHub Desktop.
ApplicationController.current_userをstubを使用した場合
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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