Skip to content

Commit 568b86c

Browse files
committed
use a new db for every rake spec variant (instead of using TRAVIS_JOB_NUMBER)
1 parent 8c8bb2e commit 568b86c

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

spec/db/database.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
common: &common
2-
database: closure_tree_test<%= ENV['TRAVIS_JOB_NUMBER'].to_s.gsub(/\W/, '_') %>
2+
database: <%= db_name %>
33
host: localhost
44
pool: 50
55
timeout: 5000

spec/spec_helper.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
Thread.abort_on_exception = true
1515

16-
ENV['TRAVIS_JOB_NUMBER'] ||= rand(1..2**31).to_s
17-
1816
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
1917

2018
RSpec.configure do |config|

spec/support/database.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def sqlite?
1212
ActiveRecord::Migration.verbose = false
1313
ActiveRecord::Base.table_name_prefix = ENV['DB_PREFIX'].to_s
1414
ActiveRecord::Base.table_name_suffix = ENV['DB_SUFFIX'].to_s
15+
16+
def db_name
17+
@db_name ||= "closure_tree_test_#{rand(1..2**31)}"
18+
end
19+
1520
ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read("#{database_folder}/database.yml")).result)
1621

1722
config = ActiveRecord::Base.configurations[database_adapter]
@@ -39,8 +44,8 @@ def sqlite?
3944
def count_queries(&block)
4045
count = 0
4146
counter_fn = ->(name, started, finished, unique_id, payload) do
42-
count += 1 unless payload[:name].in? %w[ CACHE SCHEMA ]
47+
count += 1 unless payload[:name].in? %w[CACHE SCHEMA]
4348
end
44-
ActiveSupport::Notifications.subscribed(counter_fn, "sql.active_record", &block)
49+
ActiveSupport::Notifications.subscribed(counter_fn, 'sql.active_record', &block)
4550
count
4651
end

0 commit comments

Comments
 (0)