Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Database cleaner with multiple DBs

Đang mở
#3 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
ruby
Lĩnh vực
databases, testing

Hướng nghiên cứu

Bắt đầu với cấu hình DatabaseCleaner[:sequel] trong spec helper được cung cấp và kết nối model Sequel cho CameraActivity, sau đó tái hiện lỗi bằng cách trỏ cả hai URL cơ sở dữ liệu vào cùng một cơ sở dữ liệu. Xem xét bộ kiểm thử hiện có để xác định nhiều cơ sở dữ liệu Sequel đang hoạt động được phát hiện và cấu hình như thế nào; được coi là hoàn thành khi thiết lập kiểm thử dọn dẹp các kết nối cơ sở dữ liệu dự định mà không xảy ra lỗi runtime.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I have been using DB cleaner with my only db but now I have 2 of them, and I am getting this error in testing mode as

RuntimeError:
  As you have more than one active sequel database you have to specify the one to use manually!

At first my whole sequel models were using only one db but now i have connected my one model with a separate Db as

class CameraActivity < Sequel::Model(Sequel.connect(ENV['SNAPSHOT_DATABASE_URL'])[:camera_activities])

and in spec helper I have these configurations

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] = 'test'
ENV["DATABASE_URL"] = "postgres://localhost/evercam_tst"
ENV["RACK_ENV"]  = ENV["RAILS_ENV"]
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'webmock/rspec'
require 'factory_girl'
require 'rack_session_access/capybara'
require "simplecov"
SimpleCov.start

Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

require 'database_cleaner'
require 'capybara/poltergeist'
require 'simplecov'

SimpleCov.start 'rails'

#Capybara.server_port = 3001
#Capybara.app_host = "http://local.evercam.io:3001"
Capybara.javascript_driver = :poltergeist

RSpec.configure do |config|
  config.infer_spec_type_from_file_location!

  config.filter_run :focus => true
  config.run_all_when_everything_filtered = true

  # Configure factory girl stuff.
  config.include FactoryGirl::Syntax::Methods

  # Configure database cleaner.
  config.before(:suite) do
    WebMock.allow_net_connect!
    DatabaseCleaner[:sequel].strategy = :truncation, {except: %w[spatial_ref_sys]}
    DatabaseCleaner[:sequel].clean_with(:truncation, except: %w[spatial_ref_sys])
  end

  config.before(:each) do
    DatabaseCleaner[:sequel].start
  end

  config.after(:each) do
    DatabaseCleaner[:sequel].clean
  end
end

# Load up factories.
FactoryGirl.find_definitions
```


my other DB is `ENV['SNAPSHOT_DATABASE_URL']` But for testing purposes both DB URLs are directed to one database. How is that possible to tell DB Cleaner to handle that case?
Ngôn ngữ chính
Ruby
Star
19
Fork
11
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DatabaseCleaner/database_cleaner-sequel

Tất cả issue của DatabaseCleaner/database_cleaner-sequel

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.