mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
54f37563cd
The `default:` option of `mattr_accessor` wasn't added until Rails 5.2, which means it has no effect on older versions and the default value of `FactoryBot.use_parent_strategy` in 5.0.0.rc1 is nil on those versions.
42 lines
933 B
Ruby
42 lines
933 B
Ruby
require "rspec"
|
|
require "rspec/its"
|
|
|
|
require "simplecov"
|
|
|
|
require "factory_bot"
|
|
require "timecop"
|
|
|
|
Dir["spec/support/**/*.rb"].each { |f| require File.expand_path(f) }
|
|
|
|
RSpec.configure do |config|
|
|
config.mock_with :rspec do |mocks|
|
|
# Prevents you from mocking or stubbing a method that does not exist on a
|
|
# real object. This is generally recommended, and will default to `true` in
|
|
# RSpec 4.
|
|
mocks.verify_partial_doubles = true
|
|
end
|
|
|
|
config.include DeclarationMatchers
|
|
|
|
config.before do
|
|
FactoryBot.reload
|
|
end
|
|
|
|
config.after do
|
|
Timecop.return
|
|
end
|
|
|
|
config.around do |example|
|
|
begin
|
|
previous_use_parent_strategy = FactoryBot.use_parent_strategy
|
|
example.run
|
|
ensure
|
|
FactoryBot.use_parent_strategy = previous_use_parent_strategy
|
|
end
|
|
end
|
|
|
|
config.order = :random
|
|
Kernel.srand config.seed
|
|
|
|
config.example_status_persistence_file_path = "tmp/rspec_examples.txt"
|
|
end
|