Created
July 9, 2012 18:43
-
-
Save fabiokr/3078157 to your computer and use it in GitHub Desktop.
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
# 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 | |
I prefer the format of the top example. There would need to be a > 30% average speed increase for me to really consider changing everything.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't like this. Having multiple assertions speeds up tests, but it also makes fixing fails/error more difficult, because they cascade and mix state