Skip to content

Instantly share code, notes, and snippets.

Creating a Happy Git Environment on OS X

Step 1: Install Git

Configure things:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global alias.co checkout

git config --global apply.whitespace nowarn

@LanceOlsen
LanceOlsen / context.rb
Created December 1, 2015 05:07
Using Context
describe Invoice do
subject { described_class.new(user: user, items: items) }
let(:user) { FactoryGirl.create(:user) }
let(:items) { 2.times.map { FactoryGirl.create(:item, price: 100) } }
describe '#sales_tax' do
it 'charges sales tax when the user is in CA' do
user.state = 'CA'
expect(subject.sales_tax).to eq(200 * 0.0875)
end
@LanceOlsen
LanceOlsen / unexpressive.rb
Last active December 1, 2015 05:12
Unexpressive Specs
describe Invoice do
subject { described_class.new(user: user, items: items) }
let(:user) { FactoryGirl.create(:user) }
let(:items) { 2.times.map { FactoryGirl.create(:item, price: 100) } }
describe '#sales_tax' do
it 'charges sales tax when the user is in CA' do
user.state = 'CA'
invoice.finalize!
expect(subject.sales_tax).to eq(200 * 0.0875)
@LanceOlsen
LanceOlsen / mp_expected.rb
Created December 1, 2015 05:44
RSpec Expected Monkey Patch
module RSpec
module Core
module MemoizedHelpers
module ClassMethods
alias_method :expected, :let
end
end
end
end
@LanceOlsen
LanceOlsen / using_context.rb
Last active December 1, 2015 05:49
Using Context
describe Invoice do
subject { described_class.new(user: user, items: items) }
let(:user) { FactoryGirl.create(:user, state: state) }
let(:items) { 2.times.map { FactoryGirl.create(:item, price: 100) } }
let(:state) { 'NY' }
describe '#sales_tax' do
context 'in CA' do
let(:state) { 'CA' }
@LanceOlsen
LanceOlsen / separated.rb
Created December 1, 2015 05:51
Sameness and Differences Separated
describe Invoice do
subject { described_class.new(user: user, items: items) }
let(:user) { FactoryGirl.create(:user, state: state) }
let(:items) { 2.times.map { FactoryGirl.create(:item, price: 100) } }
let(:state) { 'NY' }
describe '#sales_tax' do
shared_examples_for 'calculates sales tax' do
it 'calculates sales tax' do
invoice.finalize!
@LanceOlsen
LanceOlsen / 0_reuse_code.js
Created April 21, 2016 22:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console