Skip to content

Instantly share code, notes, and snippets.

@hosh
Created January 26, 2011 20:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save hosh/797396 to your computer and use it in GitHub Desktop.
Save hosh/797396 to your computer and use it in GitHub Desktop.
#http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/
describe User do
subject { user }
let(:user) { User.new }
context "when name empty" do
it { should_not be_valid }
specify { user.save.should be_false }
end
context "when name not empty" do
let(:user) { User.new(:name => 'Sam') }
it { should be_valid }
specify { user.save.should be_true }
end
describe :present do
subject { user.present }
context "when user is a W" do
let(:user) { User.new(:gender => 'W') }
it { should be_a Flower }
end
context "when user is a M" do
let(:user) { User.new(:gender => 'M') }
it { should be_an IMac }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment