Improve testing on docker
This commit is contained in:
parent
b96ce06d94
commit
ef1903381b
6 changed files with 16 additions and 13 deletions
|
@ -1,5 +1,7 @@
|
||||||
# Initializer to configure resque daemon
|
# 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']
|
Resque.redis = ENV['REDIS_URL']
|
||||||
else
|
else
|
||||||
puts 'WARNING: redis is not installed, so Resque is using inline method. (not recommended for production)'
|
puts 'WARNING: redis is not installed, so Resque is using inline method. (not recommended for production)'
|
||||||
|
|
|
@ -66,7 +66,7 @@ Open a rails console
|
||||||
|
|
||||||
Setup the test database
|
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
|
Run the tests
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ services:
|
||||||
- REDIS_URL=redis://redis:6379
|
- REDIS_URL=redis://redis:6379
|
||||||
- QUEUE=foodsoft_notifier
|
- QUEUE=foodsoft_notifier
|
||||||
- TEST_DATABASE_URL=mysql2://root:secret@mariadb/test?encoding=utf8
|
- TEST_DATABASE_URL=mysql2://root:secret@mariadb/test?encoding=utf8
|
||||||
|
- DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
|
||||||
|
|
||||||
mailcatcher:
|
mailcatcher:
|
||||||
image: tophfr/mailcatcher
|
image: tophfr/mailcatcher
|
||||||
|
|
|
@ -53,16 +53,6 @@ RSpec.configure do |config|
|
||||||
config.infer_spec_type_from_file_location!
|
config.infer_spec_type_from_file_location!
|
||||||
end
|
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
|
# include default foodsoft scope in urls, so that *_path works
|
||||||
# https://github.com/rspec/rspec-rails/issues/255
|
# https://github.com/rspec/rspec-rails/issues/255
|
||||||
class ActionDispatch::Routing::RouteSet
|
class ActionDispatch::Routing::RouteSet
|
||||||
|
|
10
spec/support/faker.rb
Normal file
10
spec/support/faker.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
module Faker
|
||||||
|
class Unit
|
||||||
|
class << self
|
||||||
|
def unit
|
||||||
|
['kg', '1L', '100ml', 'piece', 'bunch', '500g'].sample
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue