Improve testing on docker

This commit is contained in:
wvengen 2020-07-27 17:39:56 +02:00
parent b96ce06d94
commit ef1903381b
6 changed files with 16 additions and 13 deletions

View file

@ -1,5 +1,7 @@
# Initializer to configure resque daemon
if ENV['REDIS_URL']
if Rails.env.test?
Resque.inline = true
elsif ENV['REDIS_URL']
Resque.redis = ENV['REDIS_URL']
else
puts 'WARNING: redis is not installed, so Resque is using inline method. (not recommended for production)'

View file

@ -66,7 +66,7 @@ Open a rails console
Setup the test database
docker-compose-dev run --rm foodsoft bundle exec rake db:setup RAILS_ENV=test DATABASE_URL=mysql2://root:secret@mariadb/test?encoding=utf8
docker-compose-dev run --rm foodsoft bundle exec rake db:create db:schema:load RAILS_ENV=test DATABASE_URL=mysql2://root:secret@mariadb/test?encoding=utf8
Run the tests

View file

@ -20,6 +20,7 @@ services:
- REDIS_URL=redis://redis:6379
- QUEUE=foodsoft_notifier
- TEST_DATABASE_URL=mysql2://root:secret@mariadb/test?encoding=utf8
- DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
mailcatcher:
image: tophfr/mailcatcher

View file

@ -53,16 +53,6 @@ RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end
module Faker
class Unit
class << self
def unit
['kg', '1L', '100ml', 'piece', 'bunch', '500g'].sample
end
end
end
end
# include default foodsoft scope in urls, so that *_path works
# https://github.com/rspec/rspec-rails/issues/255
class ActionDispatch::Routing::RouteSet

View file

@ -1,4 +1,4 @@
RSpec.configure do |config|
# load FactoryBot shortcuts create(), etc.
config.include FactoryBot::Syntax::Methods
end
end

10
spec/support/faker.rb Normal file
View file

@ -0,0 +1,10 @@
module Faker
class Unit
class << self
def unit
['kg', '1L', '100ml', 'piece', 'bunch', '500g'].sample
end
end
end
end