Last active
May 29, 2018 21:13
-
-
Save lchanmann/eb0816c3c81b37d1a9aa92c00081bf91 to your computer and use it in GitHub Desktop.
blogging
This file contains hidden or 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
# spec/controllers/home_controller_spec.rb | |
require 'rails_helper' | |
RSpec.describe HomeController, type: :controller do | |
before do | |
allow(REDIS).to receive(:incr).with('user_count').and_return(1) | |
end | |
describe 'GET #index' do | |
it "assigns username" do | |
expect { | |
get :index | |
}.to change { cookies.signed[:current_username] }.to eq("User1") | |
end | |
it "does not assign username when already has one" do | |
cookies.signed[:current_username] = 'test' | |
expect { | |
get :index | |
}.not_to change { cookies.signed[:current_username] } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment