Skip to content

Instantly share code, notes, and snippets.

@cmeiklejohn
Forked from hosh/spec_examples.rb
Created October 3, 2011 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmeiklejohn/1258546 to your computer and use it in GitHub Desktop.
Save cmeiklejohn/1258546 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