Skip to content

Instantly share code, notes, and snippets.

@sicktastic
Created May 14, 2016 02:24
Show Gist options
  • Save sicktastic/ba28c43be278e28ff31cd26c787d169c to your computer and use it in GitHub Desktop.
Save sicktastic/ba28c43be278e28ff31cd26c787d169c to your computer and use it in GitHub Desktop.
Sources from Good RSpec
# correct
describe User do
let (:user) { User.new }
context "when name is empty" do
it "should not be valid" do
expect(user.valid?).to be_false
end
it "should not save" do
expect(user.save).to be_false
end
end
context "when name is not empty" do
let (:user) { User.new(:name => "Alex") }
it "should be valid" do
expect(user.valid?).to be_true
end
it "should save" do
expect(user.save).to be_true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment