Skip to content

Instantly share code, notes, and snippets.

@fabiokr
Created July 9, 2012 18:43
Show Gist options
  • Save fabiokr/3078157 to your computer and use it in GitHub Desktop.
Save fabiokr/3078157 to your computer and use it in GitHub Desktop.
# Current version
# - before block runs before each example
# - isolated examples
describe "GET show" do
before do
@customer = create_customer
get :show, id: @customer.id
end
it { should respond_with(:success) }
it { should render_template(:show) }
it { should assign_to(:customer).with(@customer) }
end
# Proposal
# - before block runs once - for customer controller spec
# time went from 8 to 3 seconds
describe "GET show" do
before do
@customer = create_customer
get :show, id: @customer.id
end
it "is successfull" do
subject.should respond_with(:success)
subject.should render_template(:show)
subject.should assign_to(:customer).with(@customer)
end
end
@itspriddle
Copy link

I agree with @tfwright and @jmazzi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment