Created
December 7, 2016 21:20
-
-
Save memaker/18c23964e93ff92d5ae8073cc2b6b104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/models/person_spec.rb | |
require 'rails_helper' | |
RSpec.describe Person, type: :model do | |
it "has a valid factory" do | |
#person = FactoryGirl.build(:person) it is also valid | |
expect(FactoryGirl.build(:person)).to be_valid | |
end | |
it "is invalid without a name" do | |
person = FactoryGirl.build(:person, name: nil) | |
expect(person).not_to be_valid | |
end | |
it "is invalid without an age" do | |
person = FactoryGirl.build(:person, age: nil) | |
expect(person).not_to be_valid | |
end | |
it "returns a person's identifier as a string" do | |
person = FactoryGirl.build(:person, name: "Johnny", age: 12) | |
expect(person.identifier).to eq("Johnny 12") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment