Skip to content

Instantly share code, notes, and snippets.

@nruth
Created July 30, 2010 23:54
Show Gist options
  • Save nruth/501517 to your computer and use it in GitHub Desktop.
Save nruth/501517 to your computer and use it in GitHub Desktop.
rspec 1 before / let for context
describe "3 users exist"
let(:users) {(1..3).map {User.make}}
specify "user count should be 3" do
pending "this will fail because users hasn't been called" do
User.count.should == 3
end
end
specify "3 users should exist" do
users
User.count.should == 3
end
specify "ordering matches creation" do
users
User.all.should == users
end
end
#vs
describe "3 users exist"
let(:users) {(1..3).map {User.make}}
before(:each) { users.should be_present }
specify "user count should be 3" do
User.count.should == 3
end
specify "ordering matches creation" do
User.all.should == users
end
end
#vs
describe "3 users exist"
before(:each) { @users = (1..3).map {User.make} }
specify "user count should be 3" do
User.count.should == 3
end
specify "ordering matches creation" do
User.all.should == @users
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment