Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Created August 24, 2011 19:21
Show Gist options
  • Save jeffreyiacono/1168937 to your computer and use it in GitHub Desktop.
Save jeffreyiacono/1168937 to your computer and use it in GitHub Desktop.
A sample user spec for Fernando / Dallas.rb
describe User do
it { should validate_presence_of :email }
describe :full_name do
subject { User.new(:email => "[email protected]") }
context "when first and last name are present" do
before { subject.first_name, subject.last_name = "Jeff", "Iacono" }
its(:full_name) { should eq("Jeff Iacono") }
end
context "when only first name is present" do
before { subject.first_name = "Jeff" }
its(:full_name) { should eq("Jeff") }
end
context "when only last name is present" do
before { subject.last_name = "Iacono" }
its(:full_name) { should eq("Iacono") }
end
context "when first and last are not present" do
its(:full_name) { should eq("[email protected]") }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment