Skip to content

Instantly share code, notes, and snippets.

@lchanmann
Last active May 29, 2018 21:13
Show Gist options
  • Save lchanmann/eb0816c3c81b37d1a9aa92c00081bf91 to your computer and use it in GitHub Desktop.
Save lchanmann/eb0816c3c81b37d1a9aa92c00081bf91 to your computer and use it in GitHub Desktop.
blogging
# 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