Skip to content

Commit

Permalink
Add env var to run specs only for one database
Browse files Browse the repository at this point in the history
  • Loading branch information
codez committed Dec 3, 2024
1 parent a321802 commit d3b8c6b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(spec: %w[db:copy_credentials db:test:prepare]) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.rspec_opts = "--tag ~database:#{ENV['DB'] == 'pg' ? 'mysql' : 'postgresql'}" if ENV['DB'].present?
# spec.rspec_opts = '--order rand:47078'
end

Expand Down Expand Up @@ -59,6 +60,8 @@ namespace :postgres do

desc 'Build the PostgreSQL test databases'
task :build_db do
next if ENV['DB'] && ENV['DB'] != 'pg'

params = []
params << '-E UTF8'
params << pg_config['database']
Expand All @@ -77,6 +80,8 @@ namespace :postgres do

desc 'drop the PostgreSQL test database'
task :drop_db do
next if ENV['DB'] && ENV['DB'] != 'pg'

puts "dropping database #{pg_config['database']}"
params = []
params << pg_config['database']
Expand All @@ -93,6 +98,8 @@ namespace :mysql do

desc 'Build the MySQL test databases'
task :build_db do
next if ENV['DB'] && ENV['DB'] != 'mysql'

params = []
params << "-h #{my_config['host']}" if my_config['host']
params << "-u #{my_config['username']}" if my_config['username']
Expand All @@ -109,6 +116,8 @@ namespace :mysql do

desc 'drop the MySQL test database'
task :drop_db do
next if ENV['DB'] && ENV['DB'] != 'mysql'

puts "dropping database #{my_config['database']}"
params = []
params << "-h #{my_config['host']}" if my_config['host']
Expand Down

0 comments on commit d3b8c6b

Please sign in to comment.