Dobra, już wiem skąd ten problem. Otóż uruchamiając rspec tylko dla modelu w logach mam:
(0.1ms) SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('johnkowalski') LIMIT 1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
SQL (3.4ms) INSERT INTO "users" ("created_at", "email", "fullname", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["created_at", Thu, 28 Jul 2011 13:26:38 UTC +00:00], ["email", "kowalski@example.com"], ["fullname", "John Kowalski"], ["name", "johnkowalski"], ["password_digest", "$2a$10$ZjQ4VIEHazv3Pg7tvl8DludmxPq4ZwVV7Iafb8ewlDi1DPUIDVhci"], ["updated_at", Thu, 28 Jul 2011 13:26:38 UTC +00:00]]
(0.1ms) RELEASE SAVEPOINT active_record_1
(0.1ms) SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('johnkowalski') LIMIT 1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
SQL (0.3ms) INSERT INTO "users" ("created_at", "email", "fullname", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["created_at", Thu, 28 Jul 2011 13:26:38 UTC +00:00], ["email", "kowalski@example.com"], ["fullname", "John Kowalski"], ["name", "johnkowalski"], ["password_digest", "$2a$10$q2nkzJ.yJJQkPiZgHJ6uhO9fsZHYXGx56nmHr6ZKes2STBO/netiu"], ["updated_at", Thu, 28 Jul 2011 13:26:38 UTC +00:00]]
(0.0ms) RELEASE SAVEPOINT active_record_1
(0.1ms) SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('johnkowalski') LIMIT 1
(0.0ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
SQL (0.3ms) INSERT INTO "users" ("created_at", "email", "fullname", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["created_at", Thu, 28 Jul 2011 13:26:38 UTC +00:00], ["email", "kowalski@example.com"], ["fullname", "John Kowalski"], ["name", "johnkowalski"], ["password_digest", "$2a$10$lZA8z3pCtclp71AOhw.88.cISKqeBKRO/Vg9V7mOKQwuUTsY1wXsC"], ["updated_at", Thu, 28 Jul 2011 13:26:38 UTC +00:00]]
(0.0ms) RELEASE SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('testowy') LIMIT 1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
(0.1ms) SELECT COUNT(*) FROM "users"
(0.1ms) SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('johnkowalski') LIMIT 1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
SQL (0.3ms) INSERT INTO "users" ("created_at", "email", "fullname", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["created_at", Thu, 28 Jul 2011 13:26:39 UTC +00:00], ["email", "kowalski@example.com"], ["fullname", "John Kowalski"], ["name", "johnkowalski"], ["password_digest", "$2a$10$zVYlkQkPrDhwOJCLJ7HkSu2eBbI0c9QIFoxC7Tt5xHMLuAjM9ARZq"], ["updated_at", Thu, 28 Jul 2011 13:26:39 UTC +00:00]]
(0.0ms) RELEASE SAVEPOINT active_record_1
Podczas gdy uruchamiając wszystkie testy, tzn. model + ten 1 integration test to wtedy w logu mam:
Started GET "/signup" for 127.0.0.1 at 2011-07-28 15:27:49 +0200
(0.1ms) SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('johnkowalski') LIMIT 1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
SQL (3.4ms) INSERT INTO "users" ("created_at", "email", "fullname", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["created_at", Thu, 28 Jul 2011 13:27:49 UTC +00:00], ["email", "kowalski@example.com"], ["fullname", "John Kowalski"], ["name", "johnkowalski"], ["password_digest", "$2a$10$DtzBctUHfPFqYhtPA268l.aKgLw2pVEzC.fr74IQrV3lfJeNqPQqC"], ["updated_at", Thu, 28 Jul 2011 13:27:49 UTC +00:00]]
(0.1ms) RELEASE SAVEPOINT active_record_1
(0.0ms) SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('johnkowalski') LIMIT 1
(0.0ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
SQL (0.3ms) INSERT INTO "users" ("created_at", "email", "fullname", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["created_at", Thu, 28 Jul 2011 13:27:49 UTC +00:00], ["email", "kowalski@example.com"], ["fullname", "John Kowalski"], ["name", "johnkowalski"], ["password_digest", "$2a$10$DxJ64G70jafdCiTpvMP6He8FPhpupgyL9G.ANW3Gx2cCsohueMSva"], ["updated_at", Thu, 28 Jul 2011 13:27:49 UTC +00:00]]
(0.0ms) RELEASE SAVEPOINT active_record_1
(0.0ms) SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('johnkowalski') LIMIT 1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
SQL (0.3ms) INSERT INTO "users" ("created_at", "email", "fullname", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["created_at", Thu, 28 Jul 2011 13:27:49 UTC +00:00], ["email", "kowalski@example.com"], ["fullname", "John Kowalski"], ["name", "johnkowalski"], ["password_digest", "$2a$10$kEEOByyUOMIpUr2XHqxeouy49XFXs.hIS0LcsYEW.GKZhVaUztPA."], ["updated_at", Thu, 28 Jul 2011 13:27:49 UTC +00:00]]
(0.0ms) RELEASE SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('testowy') LIMIT 1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
(0.1ms) SELECT COUNT(*) FROM "users"
(0.0ms) SAVEPOINT active_record_1
(0.1ms) SELECT 1 FROM "users" WHERE LOWER("users"."name") = LOWER('johnkowalski') LIMIT 1
CACHE (0.0ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") = LOWER('kowalski@example.com') LIMIT 1
(0.0ms) ROLLBACK TO SAVEPOINT active_record_1
Czyli niewiadomo dlaczego, wartość dla ostatniego testu jest brana nie z bazy danych ale z cache. Dalej nie rozumiem dlaczego akurat ta wartość jest brana z cache i dlaczego tylko jeśli wysypie się jakiś integration test ale może teraz uda się rozwiązać ten problem.
O ile wiem cache jest domyślnie wyłączony dla “test”. To jak wymusić aby nic z cache nie brał?
EDIT:
Ustawienie config.cache_classes na false rozwiązuje problem. Jednak jeśli ktoś umiał mi wytłumaczyć dlaczego wcześniej brał te dane z cache to chętnie się dowiem.