I am very green for this TDD business, so any help would be fantastic!
So I have a factory with the following:
FactoryGirl.define do factory :account do email "example@example.com" url "teststore" end end
And the Rspec test with:
it "fails validation without unique email" do account1 = FactoryGirl.create(:account) account2 = FactoryGirl.create(:account) account2.should have(1).error_on(:email) end
I get an error with the following message:
1) Account fails validation without unique email Failure/Error: account2 = FactoryGirl.create(:account) ActiveRecord::RecordInvalid: Validation failed: Email taken, please choose another, Url taken, please choose another # ./spec/models/account_spec.rb:11:in `block (2 levels) in <top (required)>'
Is this the right way to create new plants? Any ideas what I'm doing wrong here (I have no doubt that I'm doing something completely wrong!)
EDIT: I think, instead of using "create" in the second account, I can use .build and use ss instead?
ruby-on-rails tdd ruby-on-rails-3 rspec factory-bot
Galaxy
source share