Yes this works. Thanks But I started getting an error as 

# 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


 In the above respec file DB Cleaner has started giving error while test is 
running as 

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


How can we tell DB Cleaner only one DB? for Sequel
On Saturday, 7 January 2017 23:12:32 UTC+5, Jeremy Evans wrote:
>
> On Saturday, January 7, 2017 at 9:36:01 AM UTC-8, Junaid Farooq wrote:
>>
>> We have added Sequel as PostgreSQL adapter in our Rails app. and 
>> initialized it in initializers as
>>
>> require 'evercam_misc'
>>
>> DB = Sequel::Model.db = Sequel.connect(ENV['DATABASE_URL'], 
>> max_connections: 100)
>> Sequel::Model.db.sql_log_level = Rails.application.config.log_level || 
>> :debug
>>
>> if ARGV.any? {|parameter| parameter =~ /(--sandbox|-s)/}
>>    # Do everything inside a transaction when using rails c --sandbox (or 
>> -s).
>>    DB.pool.after_connect = proc do |connection|
>>       DB.send(:add_transaction, connection, {})
>>       DB.send(:begin_transaction, connection, {})
>>    end
>> end
>>
>> # Connection created, pull in the model classes.
>> require 'evercam_models'
>>
>>
>> But there is another model for which I want  it to connect to separate 
>> DB. Is that possible to do that for only one Sequel model which is
>>
>>
>> require 'active_support/core_ext/object/blank'
>> class CameraActivity < Sequel::Model
>> end
>>
>> The DB to which i want it to connect is 
>>
>> ENV['SNAPSHOT_DATABASE_URL']
>>
>
> This should work:
>
>   class CameraActivity < 
> Sequel::Model(Sequel.connect(ENV['SNAPSHOT_DATABASE_URL'])[:camera_activities])
>   end
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to