database-cleaner

Cleaning database after tests in node.js

一个人想着一个人 提交于 2020-01-01 09:32:07
问题 How I can clean database after each it ? In rails I use https://github.com/bmabey/database_cleaner, but I did't find something similar for node.js node.js (v0.10.26), PostgreSQL (9.3.3), mocha, restify and knex. 回答1: The easy way I have found to clean the database between test is to DROP SCHEMA public CASCADE; CREATE SCHEMA public AUTHORIZATION my_test_user; Once the public schema belongs to the test user, he is able to drop and re-create the schema when needed. Be aware that drop everything

database_cleaner is wiping my development database

泪湿孤枕 提交于 2019-12-22 07:02:40
问题 I have database-cleaner configured for my rails 4 application, Each time I run the test, I discovered that my database gets wiped out in both the test and development environment. My configurations are in rails_helper as follow: ENV["RAILS_ENV"] ||= 'test' # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'database_cleaner' Rails.env = "test" # Add

MiniTest, Capybara, Fixture, Database_Cleaner not passing at second time

五迷三道 提交于 2019-12-21 21:43:54
问题 The following test passed first time (after rake db:test:prepare ) but failed gave error on subsequent run. Capybara::ElementNotFound: Unable to find css "#sale_payment_btn" require "test_helper" DatabaseCleaner.strategy = :transaction class SaleFeatureTest < Capybara::Rails::TestCase include Warden::Test::Helpers Warden.test_mode! self.use_transactional_fixtures = false setup do login_as users(:admin), scope: :user Capybara.current_driver = :selenium #:webkit DatabaseCleaner.start end

Rails minitest, database cleaner how to turn use_transactional_fixtures = false

自闭症网瘾萝莉.ら 提交于 2019-12-20 02:56:19
问题 i would like to disable use_transactional_fixtures = false in ministest to catch after_commit callback. What and where should i set-up? 回答1: You have a few options. One is to create a test without transactional fixtures and hope that the changes you make to the test database isn't going to break any other tests. class SomethingTest < ActiveSupport::TestCase self.use_transactional_fixtures = false def test_something_with_after_commit # do work here, which will change your test database end end

Sudden inexplicable active record connection timeouts while testing with RSPEC

我们两清 提交于 2019-12-07 07:15:04
问题 This is an area I know almost nothing about, so apologies in advance. I have a suite of over 800 rspec tests. Suddenly and inexplicably when running the whole set or just particular test files, after just a few of these, (say 20 or so, although it's never exactly the same number), every single test begins to fail with the same error: Failure/Error: Unable to find matching line from backtrace ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5.000 seconds

Sudden inexplicable active record connection timeouts while testing with RSPEC

删除回忆录丶 提交于 2019-12-05 17:47:49
This is an area I know almost nothing about, so apologies in advance. I have a suite of over 800 rspec tests. Suddenly and inexplicably when running the whole set or just particular test files, after just a few of these, (say 20 or so, although it's never exactly the same number), every single test begins to fail with the same error: Failure/Error: Unable to find matching line from backtrace ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5.000 seconds (waited 5.000 seconds) In a typical run, I'll start getting these errors after 20 or so request tests, and

Rspec extremely slow

依然范特西╮ 提交于 2019-12-05 02:23:25
问题 My rspec tests seem to run extremely slow even with guard & spork. Finished in 5.36 seconds 13 examples, 2 failures I understand that there are several things I can do to optimize my tests & reduce interaction with the database, but I strongly suspect that the spec_helper has been improperly setup. I'm on rails 3.2.11 with mongoid. Database cleaner cleans up after every run. spec_helper.rb require 'rubygems' require 'spork' Spork.prefork do ENV["RAILS_ENV"] ||= 'test' require File.expand_path

Database Cleaner issue with Capybara webkit

爷,独闯天下 提交于 2019-12-03 13:29:12
问题 I am using Cucumber to write my integration tests and Database Cleaner to keep my db clean. Everything perfectly works as my tests don't require Javascript. I can make these last tests pass using Capybara webkit, but then my db is not cleaned at all. Here is my features/support/env.rb file: require 'simplecov' SimpleCov.start 'rails' require 'cucumber/rails' Capybara.default_selector = :css Capybara.javascript_driver = :webkit begin require 'database_cleaner' require 'database_cleaner

Is DatabaseCleaner still necessary with Rails system specs?

我的未来我决定 提交于 2019-12-03 05:40:35
问题 From all that I've read about Rails 5.1 new system specs my understanding was that Rails now handles database transactions internally. From Rspec's blog: "[previously] your tests and your code under test cannot share a database transaction, and so you cannot use RSpec's built in mechanism to roll back database changes, instead requiring a gem like database cleaner. With system tests, the Rails team has done the hard work to ensure that this is not the case, and so you can safely use RSpec's

Database Cleaner issue with Capybara webkit

北城余情 提交于 2019-12-03 02:51:07
I am using Cucumber to write my integration tests and Database Cleaner to keep my db clean. Everything perfectly works as my tests don't require Javascript. I can make these last tests pass using Capybara webkit , but then my db is not cleaned at all. Here is my features/support/env.rb file: require 'simplecov' SimpleCov.start 'rails' require 'cucumber/rails' Capybara.default_selector = :css Capybara.javascript_driver = :webkit begin require 'database_cleaner' require 'database_cleaner/cucumber' DatabaseCleaner[:active_record].strategy = :transaction rescue NameError raise "You need to add