Occurrence of Sequel::DatabaseDisconnectError at puma worker, even though the db is disconnected in puma's before_fork-hook - ruby

I have a hanami 1.3 app, but the issue should be unrelated to hanami. I want to connect to a second db with plain Sequel-gem. Therefore I define the connection in hanami's config/environment.rb:
# config/environment.rb
# ...
DWH = Sequel.connect(ENV['DWH'], :loggers => [Logger.new($stdout)])
#...
In production I have a puma-config like that:
# config/puma.rb
require_relative './environment'
workers 5
threads_count = 1
threads threads_count, threads_count
daemonize true
preload_app!
rackup DefaultRackup
port 2300
environment 'production'
before_fork do
DWH.disconnect
end
on_worker_boot do
Hanami.boot
end
I used the before_fork hook to disconnect the db (http://sequel.jeremyevans.net/rdoc/files/doc/fork_safety_rdoc.html). But after some time I get errors like that:
Sequel::DatabaseDisconnectError: PG::UnableToSend: SSL SYSCALL error: EOF detected
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:166:in `async_exec'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:166:in `block in execute_query'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/database/logging.rb:49:in `log_connection_yield'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:166:in `execute_query'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:153:in `block in execute'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:129:in `check_disconnect_errors'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:153:in `execute'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:515:in `_execute'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:327:in `block (2 levels) in execute'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:537:in `check_database_errors'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:327:in `block in execute'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/database/connecting.rb:301:in `block in synchronize'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/connection_pool/threaded.rb:107:in `hold'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/database/connecting.rb:301:in `synchronize'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:327:in `execute'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/dataset/actions.rb:1135:in `execute'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/adapters/postgres.rb:680:in `fetch_rows'
/home/usr/vendor/bundle/ruby/2.6.0/gems/sequel-4.49.0/lib/sequel/dataset/actions.rb:155:in `each'
/home/usr/app/lib/repositories/dwh_repository.rb:39:in `to_a'

I had a conversation with the author of Sequel. It seems, that the puma config and the connection-approach is correct.
It seems, the DB-connections are dropped by another network-part (i.e. tcp-timeout, firewall, ...).
In such a case this is the expected behavior of Sequel:
The application lost connection to the database. When this happens, a DatabaseDisconnectError is raised and Sequel removes the connection from the connection pool. New connection will be created as needed up to the maximum pool size.
The best way to solve the issue, is to fix the reason for the connection-dropping (change setup [DB, server]). A pragmatic solution could be putting DB and application on same server.
If that is not possible, there's a Sequel-extension, which could be a workaround:
https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/connection_validator_rb.html

I had the same problem, to fix it just increase the number or threads in config, I go with preloaded 32 and 0 workers (actualy one but not in cluster mode, that would be enabled if I used workers 1)
In short, you need this
workers 0
threads 32, 32
My full puma config for custom rack app
# set app root
Dir.chdir File.expand_path("../..", __FILE__)
# load RACK_ENV
require 'dotenv'
Dotenv.load
require 'bundler/setup'
Bundler.require
plugin :tmp_restart
port 3000
log_requests false
nakayoshi_fork true
pidfile './tmp/puma.pid'
state_path './tmp/puma.state'
# activate_control_app('tcp://127.0.0.1:9000', no_token: true)
if ENV['RACK_ENV'] == 'production'
stdout_redirect './log/puma.log', './log/puma_errros.log'
environment 'production'
workers 0
threads 32, 32
# restart if there is no response on /ok, check every 10 seconds
Thread.new do
loop do
sleep 10
unless `curl -si -m 5 http://localhost:3000/ok`.include?('200 OK')
Logger.new('log/app_boot.log').error 'http://localhost:3000/ok fail, restarting'
`touch tmp/restart.txt`
end
end
end
end

Related

undefined method `query_options' for nil:NilClass, resque, unicorn, Rails 4, mysql

I get this error when i try to send an update mail.
undefined method `query_options' for nil:NilClass
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/connection_adapters/mysql2_adapter.rb:218:in `execute'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:300:in `execute_and_free'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:461:in `columns'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:114:in `block in prepare_default_proc'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:in `yield'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:in `default'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:in `columns'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:208:in `columns'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:217:in `columns_hash'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `block in valid?'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `each'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `all?'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `valid?'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:18:in `method_missing'
/home/user_name/work/app_name/app/mailers/user_mailer.rb:12:in `update_message'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:189:in `process_action'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__1485230712795781007__process_action__callbacks'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:136:in `process'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/actionpack-4.0.0/lib/abstract_controller/rendering.rb:44:in `process'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:503:in `process'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:497:in `initialize'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:48:in `new'
/home/user_name/.rvm/gems/ruby-1.9.3-p551#app_name/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:48:in `perform'
We are using Rails 4, unicorn 4.7 and resque 1.25.
For sending emails on the application we use different mailer.
The recovery email that uses the object to send the emails, works fine, but the email that sends the profile update, which queries the user by id, does not work and throws the above error.
This is the unicorn config:
worker_processes 1
working_directory "correct/path" # available in 0.94.0+
listen "correct/path", :backlog => 64
timeout 30
pid "correct/path"
stderr_path "correct/path"
stdout_path "correct/path"
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
old_pid = "#{server.config[:pid]}.oldbin"
if old_pid != server.pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
end
end
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
I have tried various answer from stack overflow, or Github issues with no result.
I finally fixed the problem, I had to restart the worker(s) after removing the octopus gem.
That error message is because octopus does not work very well out of the box with unicorn so I did configured it, but I forgot to close the worker, and it kept the octopus setting thus throwing this error.
Unfortunately I could not find a good way to use octopus with our applications because we got this error, that as far as I could see is related to Resque, more precisely when any of the workers forks a process, it fails to connect to an outside database, ex: x model connecting to y database., which works well for the application using octopus_connect, but not for the workers.
Our solution was to use instead taskrabbit/makara as the connection proxy.

how to run one program and check the existence of output periodically while running the program

I want to run a script which is generating some files and want check the existence of the script genrated file in every 3 min.
I did the following,
def periodic_method time, block
t = EventMachine::PeriodicTimer.new(time) {eval(block)}
begin
yield
ensure
t.cancel
end
end
periodic_method(60, "if File.exists(file1.txt) then puts 'done with step 1' else puts 'running generator'") do
generator.rb
end
While running i am getting error wrong no of arguments.
Here is the stacktrace:-
wrong number of arguments (1 for 0)
/tools/simulation/simulation_assemble/test.rb:652:in `eval'
(eval):1:in `block in periodic_block'
/tools/simulation/simulation_assemble/test.rb:652:in `eval'
/tools/simulation/simulation_assemble/test.rb:652:in `block in periodic_block'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4
/lib/em/timers.rb:52:in `call'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/em/timers.rb:52:in `fire'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:206:in `call'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:206:in `run_machine'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:206:in `run'
generator.rb:195:in `block in run'
generator.rb:168:in `standard_exception_handling'
generator:191:in `run'
generator:28:in `< main>'
Can anyone help in achieving my task?
Is there any other way to do this task?
I would use rufus-scheduler for that
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
scheduler.every '3m' do
# run script here; would this do?
puts "running generator..."
`ruby generator.rb`
puts "done generating..."
# now when the script is done,
# check if File.exists?
end
scheduler.every '3m' do
# do other things in another thread
end
scheduler.join
sleep 1 while true # in order for your program to stay alive

Sinatra, Mongoid, Heroku, MongoHQ: connecting to Mongodb

Trying to get Mongoid up and running with Sinatra on Heroku (MongoHQ). Previous experience with Rails but first time with the stack and Sinatra.
Started with one of the simple examples on the web (app.rb):
require 'rubygems'
require 'sinatra'
require 'mongo'
require 'mongoid'
configure do
Mongoid.load!('mongoid.yml')
Mongoid.configure do |config|
if ENV['MONGOHQ_URL']
conn = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
uri = URI.parse(ENV['MONGOHQ_URL'])
# problem happens here
config.master = conn.db(uri.path.gsub(/^\//, ''))
else
config.master = Mongo::Connection.from_uri("mongodb://localhost:27017").db('test')
end
end
end
# Models
class Counter
include Mongoid::Document
field :count, :type => Integer
def self.increment
c = first || new({:count => 0})
c.inc(:count, 1)
c.save
c.count
end
end
# Controllers
get '/' do
"Hello visitor n" + Counter.increment.to_s
end
For reference, mongoid.yml looks like:
development:
sessions:
default:
database: localhost
production:
sessions:
default:
uri: <%= ENV['MONGOHQ_URL'] %>
As per app.rb (# problem happens here), my logs say:
/app/app.rb:15:in `block (2 levels) in <top (required)>': undefined method `master=' for Mongoid::Config:Module (NoMethodError)
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.3/lib/mongoid.rb:112:in `configure'
from /app/app.rb:11:in `block in <top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1273:in `configure'
from /app/app.rb:8:in `<top (required)>'
I have also tried variants, including:
config.master = Mongo::Connection.from_uri(ENV['MONGOHQ_URL']).db('appXXXXX')
Mongoid.database = Mongo::Connection.from_uri(ENV['MONGOHQ_URL']).db('appXXXXXXX')
But get the same error:
undefined method `master` for Mongoid::Config:Module (NoMethodError)
or:
undefined method `database=` for Mongoid::Config:Module (NoMethodError)
What am I missing?
Shouldn't be
configure do
Mongoid.load!('mongoid.yml')
end
enough?
That's what the mongid docs are saying. The MONGOHQ_URL environment variable already contains every information to initialize the connection to the db.
So was using Mongoid 3.x ... which:
Doesn't use 10gen driver: uses Moped
Doesn't use config.master
The canonical sample code above which is all over the web works out of the box with Mongoid 2.x so have dropped back to that for the time being.
Thanks!

Rake task not running

Every time I call my rake task it say:
[2012-07-12 15:50:01] ERROR IOError: An existing connection was forcibly closed by the remote host
C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpresponse.rb:324:in `_write_data'
C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpresponse.rb:180:in `send_header'
C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpresponse.rb:103:in `send_response'
C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpserver.rb:79:in `run'
C:/jruby-1.3.1/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
C:/jruby-1.3.1/lib/ruby/1.8/webrick/server.rb:162:in `start'
[2012-07-12 15:50:29] ERROR IOError: An existing connection was forcibly closed by the remote host
C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpserver.rb:55:in `run'
C:/jruby-1.3.1/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
C:/jruby-1.3.1/lib/ruby/1.8/webrick/server.rb:162:in `start'
I have tryed different options thinking that it could be the call to the rake task but apparently isn't, also I have tryed with Mongrel and WEBRick in case that it could be the server.
I'm using Jruby 1.3.1
The task it's not been executed.
This is part of my code:
application_controller.rb
def call_rake(task, options = {})
options[:rails_env] ||= Rails.env
args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
system "C:/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake #{task} #{args.join(' ')} start"
end
forbidden_file.rake
desc "Process CSV file"
task :process_file => :environment do
forbidden_file = ForbiddenFile.find(ENV["csv"])
forbidden_file.upload_file
end
Controller
...
call_rake :process_file, :csv => params[:files]
redirect_to forbidden_files_url
...
It's working now, I just removed the word start from the command.
system "rake #{task} #{args.join(' ')}"

rails 3.1.3 / cucumber / database_cleaner / mongo_mapper

does anybody have also trouble running the cucumber tests in that envirounment?
Error
Exception encountered by DatabaseCleaner in Cucumber After block: ActiveRecord::ConnectionNotEstablished
ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `retrieve_connection'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-rails-1.2.1/lib/cucumber/rails/hooks/active_record.rb:6:in `connection'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/active_record/truncation.rb:130:in `clean'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/base.rb:77:in `clean'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/configuration.rb:56:in `block in clean'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/configuration.rb:56:in `each'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.7.1/lib/database_cleaner/configuration.rb:56:in `clean'
/home/jonas/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-rails-1.2.1/lib/cucumber/rails/hooks/database_cleaner.rb:9:in `After'
features/support/env.rb
7 require 'cucumber/rails'
8 require 'database_cleaner'
9 require 'database_cleaner/cucumber'
10 require 'database_cleaner/mongo_mapper/truncation'
...
41 # Remove/comment out the lines below if your app doesn't have a database.
42 # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
43 begin
44 DatabaseCleaner.strategy = :truncation
45 rescue NameError
46 raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
47 end
I got no idea what to do.
I'm getting the same problem, all my 'steps' pass but my Scenario fails due to the ActiveRecord mixup with Database Cleaner.
Scenario: User is not signed up # features/users/sign_in.feature:6
Given I am not logged in # features/step_definitions/user_steps.rb:86
And no user exists with an email of "user#invalidemail.com" # features/step_definitions/user_steps.rb:1
When I go to the sign in page # features/step_definitions/web_steps.rb:48
And I sign in as "user#invalidemail.com/please" # features/step_definitions/user_steps.rb:61
Then I should see "Invalid email or password." # features/step_definitions/web_steps.rb:105
And I go to the home page # features/step_definitions/web_steps.rb:48
And I should be signed out # features/step_definitions/user_steps.rb:81
ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/cucumber-rails-1.3.0/lib/cucumber/rails/hooks/active_record.rb:6:in `connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner-0.7.2/lib/database_cleaner/active_record/truncation.rb:130:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner-0.7.2/lib/database_cleaner/base.rb:77:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner-0.7.2/lib/database_cleaner/configuration.rb:56:in `block in clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner-0.7.2/lib/database_cleaner/configuration.rb:56:in `each'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/database_cleaner- 0.7.2/lib/database_cleaner/configuration.rb:56:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0#travel/gems/cucumber-rails- 1.3.0/lib/cucumber/rails/hooks/database_cleaner.rb:9:in `After'
Failing Scenarios:
cucumber features/users/sign_in.feature:6 # Scenario: User is not signed up
1 scenario (1 failed)
7 steps (7 passed)
I am getting what may be a hint when executing my cucumber tests:
$bundle exec cucumber --verbose features/users/sign_in.feature:15
WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb).
https://rspec.lighthouseapp.com/projects/16211/tickets/165 (related ticket)
Oddly it doesn't fail on the Before step.
spec_helper.rb
RSpec.configure do |config|
# == Mock Framework
config.mock_with :rspec
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
...
end
...
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
...
end
features/support/config.rb
Class ...
...
End
begin
DatabaseCleaner.strategy = :truncation, { :except => %w[oauth_tokens client_applications] }
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
I had to remove DatebaseCleaner

Resources