Update rspec
This commit is contained in:
parent
c96f8d2894
commit
a0728e80e3
2 changed files with 65 additions and 78 deletions
|
@ -4,20 +4,18 @@ require 'simplecov'
|
||||||
SimpleCov.start
|
SimpleCov.start
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||||
ENV['RAILS_ENV'] ||= 'test'
|
|
||||||
require File.expand_path('../config/environment', __dir__)
|
|
||||||
# Prevent database truncation if the environment is production
|
|
||||||
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
ENV['RAILS_ENV'] ||= 'test'
|
||||||
|
require File.expand_path('../../config/environment', __FILE__)
|
||||||
|
# Prevent database truncation if the environment is production
|
||||||
|
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
||||||
require 'rspec/rails'
|
require 'rspec/rails'
|
||||||
require 'devise'
|
|
||||||
# Add additional requires below this line. Rails is not loaded until this point!
|
# Add additional requires below this line. Rails is not loaded until this point!
|
||||||
|
require 'devise'
|
||||||
require 'support/factory_bot'
|
require 'support/factory_bot'
|
||||||
require 'support/date_time'
|
require 'support/date_time'
|
||||||
require 'timecop'
|
require 'timecop'
|
||||||
require 'delayed_job'
|
|
||||||
require 'support/contexts'
|
require 'support/contexts'
|
||||||
Delayed::Worker.delay_jobs = false
|
|
||||||
# Requires supporting ruby files with custom matchers and macros, etc, in
|
# Requires supporting ruby files with custom matchers and macros, etc, in
|
||||||
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
||||||
# run as spec files by default. This means that files in spec/support that end
|
# run as spec files by default. This means that files in spec/support that end
|
||||||
|
@ -31,16 +29,24 @@ Delayed::Worker.delay_jobs = false
|
||||||
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
||||||
# require only the support files necessary.
|
# require only the support files necessary.
|
||||||
#
|
#
|
||||||
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
||||||
|
|
||||||
|
# Checks for pending migrations and applies them before tests are run.
|
||||||
|
# If you are not using ActiveRecord, you can remove these lines.
|
||||||
|
begin
|
||||||
|
ActiveRecord::Migration.maintain_test_schema!
|
||||||
|
rescue ActiveRecord::PendingMigrationError => e
|
||||||
|
puts e.to_s.strip
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||||
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||||
|
|
||||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||||
# examples within a transaction, remove the following line or assign false
|
# examples within a transaction, remove the following line or assign false
|
||||||
# instead of true.
|
# instead of true.
|
||||||
# config.use_transactional_fixtures = true
|
config.use_transactional_fixtures = true
|
||||||
|
|
||||||
# RSpec Rails can automatically mix in different behaviours to your tests
|
# RSpec Rails can automatically mix in different behaviours to your tests
|
||||||
# based on their file location, for example enabling you to call `get` and
|
# based on their file location, for example enabling you to call `get` and
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
# 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`.
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
||||||
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
||||||
|
@ -15,16 +12,11 @@
|
||||||
# the additional setup, and require it from the spec files that actually need
|
# the additional setup, and require it from the spec files that actually need
|
||||||
# it.
|
# 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
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||||
|
|
||||||
require 'support/expect'
|
require 'support/expect'
|
||||||
require 'support/mock_helpers'
|
require 'support/mock_helpers'
|
||||||
require 'action_mailer_matchers'
|
require 'action_mailer_matchers'
|
||||||
|
|
||||||
include Expect
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
# rspec-expectations config goes here. You can use an alternate
|
# rspec-expectations config goes here. You can use an alternate
|
||||||
# assertion/expectation library such as wrong or the stdlib/minitest
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
||||||
|
@ -57,53 +49,55 @@ RSpec.configure do |config|
|
||||||
# triggering implicit auto-inclusion in groups with matching metadata.
|
# triggering implicit auto-inclusion in groups with matching metadata.
|
||||||
config.shared_context_metadata_behavior = :apply_to_host_groups
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
||||||
|
|
||||||
# The settings below are suggested to provide a good initial experience
|
# The settings below are suggested to provide a good initial experience
|
||||||
# with RSpec, but feel free to customize to your heart's content.
|
# with RSpec, but feel free to customize to your heart's content.
|
||||||
# # This allows you to limit a spec run to individual examples or groups
|
=begin
|
||||||
# # you care about by tagging them with `:focus` metadata. When nothing
|
# This allows you to limit a spec run to individual examples or groups
|
||||||
# # is tagged with `:focus`, all examples get run. RSpec also provides
|
# you care about by tagging them with `:focus` metadata. When nothing
|
||||||
# # aliases for `it`, `describe`, and `context` that include `:focus`
|
# is tagged with `:focus`, all examples get run. RSpec also provides
|
||||||
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
# aliases for `it`, `describe`, and `context` that include `:focus`
|
||||||
# config.filter_run_when_matching :focus
|
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
||||||
#
|
config.filter_run_when_matching :focus
|
||||||
# # Allows RSpec to persist some state between runs in order to support
|
|
||||||
# # the `--only-failures` and `--next-failure` CLI options. We recommend
|
# Allows RSpec to persist some state between runs in order to support
|
||||||
# # you configure your source control system to ignore this file.
|
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
||||||
# config.example_status_persistence_file_path = "spec/examples.txt"
|
# you configure your source control system to ignore this file.
|
||||||
#
|
config.example_status_persistence_file_path = "spec/examples.txt"
|
||||||
# # Limits the available syntax to the non-monkey patched syntax that is
|
|
||||||
# # recommended. For more details, see:
|
# Limits the available syntax to the non-monkey patched syntax that is
|
||||||
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
# recommended. For more details, see:
|
||||||
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
||||||
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
||||||
# config.disable_monkey_patching!
|
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
||||||
#
|
config.disable_monkey_patching!
|
||||||
# # 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
|
# Many RSpec users commonly either run the entire suite or an individual
|
||||||
# # individual spec file.
|
# file, and it's useful to allow more verbose output when running an
|
||||||
# if config.files_to_run.one?
|
# individual spec file.
|
||||||
# # Use the documentation formatter for detailed output,
|
if config.files_to_run.one?
|
||||||
# # unless a formatter has already been configured
|
# Use the documentation formatter for detailed output,
|
||||||
# # (e.g. via a command-line flag).
|
# unless a formatter has already been configured
|
||||||
# config.default_formatter = 'doc'
|
# (e.g. via a command-line flag).
|
||||||
# end
|
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
|
# Print the 10 slowest examples and example groups at the
|
||||||
# # particularly slow.
|
# end of the spec run, to help surface which specs are running
|
||||||
# config.profile_examples = 10
|
# 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
|
# Run specs in random order to surface order dependencies. If you find an
|
||||||
# # the seed, which is printed after each run.
|
# order dependency and want to debug it, you can fix the order by providing
|
||||||
# # --seed 1234
|
# the seed, which is printed after each run.
|
||||||
# config.order = :random
|
# --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
|
# Seed global randomization in this process using the `--seed` CLI option.
|
||||||
# # test failures related to randomization by passing the same `--seed` value
|
# Setting this allows you to use `--seed` to deterministically reproduce
|
||||||
# # as the one that triggered the failure.
|
# test failures related to randomization by passing the same `--seed` value
|
||||||
# Kernel.srand config.seed
|
# as the one that triggered the failure.
|
||||||
|
Kernel.srand config.seed
|
||||||
|
=end
|
||||||
config.include ActionMailerMatchers
|
config.include ActionMailerMatchers
|
||||||
config.before(:suite) do
|
config.before(:suite) do
|
||||||
DatabaseCleaner.strategy = :transaction
|
DatabaseCleaner.strategy = :transaction
|
||||||
|
@ -116,16 +110,3 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '1.9'
|
|
||||||
module Kernel
|
|
||||||
alias __at_exit at_exit
|
|
||||||
def at_exit
|
|
||||||
__at_exit do
|
|
||||||
exit_status = $ERROR_INFO.status if $ERROR_INFO.is_a?(SystemExit)
|
|
||||||
yield
|
|
||||||
exit exit_status if exit_status
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in a new issue