diff --git a/Gemfile b/Gemfile index f6b00c0..0bcc17a 100644 --- a/Gemfile +++ b/Gemfile @@ -75,6 +75,7 @@ group :development do gem 'spring' # Spring speeds up development by keeping your application running in the background gem 'rack-livereload' # Insert live reload script into the page gem 'guard-livereload', require: false # Guard plugin for a livereload server + gem 'parallel_tests' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index d85a253..a03da39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -242,6 +242,9 @@ GEM cocaine (~> 0.5.5) mime-types mimemagic (= 0.3.0) + parallel (1.6.1) + parallel_tests (1.6.0) + parallel pg (0.18.2) poltergeist (1.6.0) capybara (~> 2.1) @@ -420,6 +423,7 @@ DEPENDENCIES nokogiri nprogress-rails paperclip + parallel_tests pg poltergeist rack-livereload diff --git a/config/database.yml.example b/config/database.yml.example index ec325f6..2cd9bf8 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -9,7 +9,7 @@ development: test: adapter: postgresql encoding: unicode - database: factorio_mods_test + database: factorio_mods_test<%= ENV['TEST_ENV_NUMBER'] %> pool: 5 username: factorio_mods password: diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c308637..b1bf47d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,6 +1,5 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' -require 'spec_helper' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'capybara/rspec' @@ -9,6 +8,10 @@ require 'webmock/rspec' require 'vcr' require 'paperclip/matchers' require 'rspec/its' +require 'factory_girl' +require 'custom_logger' + +include ActionDispatch::TestProcess WebMock.disable_net_connect!(allow_localhost: true) # Capybara.default_driver = :selenium_phantomjs @@ -56,7 +59,16 @@ Spring.after_fork do Dir["app/inputs/*_input.rb"].each { |f| require File.basename(f) } end + RSpec.configure do |config| + LL.info '############################################################################################' + config.include FactoryGirl::Syntax::Methods + config.include JsonSpec::Helpers + config.before(:suite) { FactoryGirl.reload } + config.expect_with :rspec do |c| + c.syntax = [:should, :expect] + end + # This is so the backtrace is shorter and only shows the project code # You might need to comment this out if you're doing some really hardcore debugging config.backtrace_exclusion_patterns << /\/gems\// diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9f399ae..63f198b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,90 +1 @@ -require 'factory_girl' -require 'webmock/rspec' -require 'custom_logger' - -include ActionDispatch::TestProcess -# This file was generated by the `rails generate rspec:install` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause this -# file to always be loaded, without a need to explicitly require it in any files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, make a -# separate helper file that requires this one and then use it only in the specs -# that actually need it. -# -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - LL.info '############################################################################################' - config.include FactoryGirl::Syntax::Methods - config.include JsonSpec::Helpers - config.before(:suite) { FactoryGirl.reload } - config.expect_with :rspec do |c| - c.syntax = [:should, :expect] - end -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed - - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # Enable only the newer, non-monkey-patching expect syntax. - # For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - expectations.syntax = :expect - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Enable only the newer, non-monkey-patching expect syntax. - # For more details, see: - # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - mocks.syntax = :expect - - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended. - mocks.verify_partial_doubles = true - end -=end -end +require 'rails_helper'