Reputation: 24406
I try to run this simplest unit test:
test "the truth" do
assert true
end
like this:
ruby -Itest test/unit/my_model_test.rb
(there is the only one test in the file, and actually in the whole site)
it fails with this message:
ActiveRecord::RecordNotUnique: SQLite3::ConstraintException: column email is not unique: INSERT INTO "users"... [some values to insert here]
now I do have a table named "users" but other than that I have never asked to do any tests on it nor do I even have such tests. Where does this error come from? How do I run just my test?
EDIT: the "users" table comes from the devise gem if that helps
Upvotes: 1
Views: 2743
Reputation: 837
Quote from http://guides.rubyonrails.org/testing.html
Rails by default automatically loads all fixtures from the test/fixtures folder for your unit and functional test. Loading involves three steps:
- Remove any existing data from the table corresponding to the fixture
- Load the fixture data into the table
- Dump the fixture data into a variable in case you want to access it directly
So I think you need to check those fixtures. Also I suggest you to read that tutorial. It is very well written.
Upvotes: 10