Rails is using fixtures without my permission -


i've started simple test:

class usertest < activesupport::testcase   test 'should not create user without email'     user = user.new     assert_not user.save   end end 

and rails auto-generated fixtures:

one:   email: mystring   login_token: mystring   token_generated_at: 2017-09-10 17:24:55  two:   email: mystring   login_token: mystring   token_generated_at: 2017-09-10 17:24:55 

so can see didn't use fixtures test. when executing test, rails throws exception:

error: usertest#test_should_not_create_user_without_email: activerecord::recordnotunique: sqlite3::constraintexception: unique constraint failed: users.email: insert "users" ("email", "login_token", "token_date", "created_at", "updated_at", "id") values ('mystring', 'mystring', '2017-09-10 17:24:55', '2017-09-10 15:48:11.483364', '2017-09-10 15:48:11.483364', 298486374) 

at first thougt delete fixtures. later there should fixtures example non-unique email.

in order load fixtures rails don't need permissions. documentation:

the testing environment will automatically load fixtures database before each test. ensure consistent data, environment deletes fixtures before running load.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -