1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/spec/unit_spec_helper.rb
Elliot Winkler 6cc7fd8ca2 Remove warnings shown when running tests
* For some reason, ActiveRecord was printing a warning saying that
  "active_record/base" was already being loaded and there was a possible
  circular dependency. We fix this by explicitly requiring
  "active_record/base" before `$VERBOSE` is set to true.
* We were getting warnings when re-defining Kernel.capture,
  Kernel.silence_stream and Kernel.silence_stderr, so undefine them
  first.
2015-12-13 20:22:21 -07:00

60 lines
1.8 KiB
Ruby

require_relative 'support/tests/current_bundle'
Tests::CurrentBundle.instance.assert_appraisal!
#---
require File.expand_path('../support/unit/rails_application', __FILE__)
$test_app = UnitTests::RailsApplication.new
$test_app.create
$test_app.load
require 'active_record/base'
ENV['BUNDLE_GEMFILE'] ||= app.gemfile_path
ENV['RAILS_ENV'] = 'test'
require 'rspec/rails'
require 'shoulda-matchers'
require 'spec_helper'
Dir[ File.join(File.expand_path('../support/unit/**/*.rb', __FILE__)) ].sort.each do |file|
require file
end
RSpec.configure do |config|
if config.respond_to?(:infer_spec_type_from_file_location!)
config.infer_spec_type_from_file_location!
end
config.before(:all, type: :controller) do
self.class.controller(ApplicationController) { }
end
UnitTests::ActiveModelHelpers.configure_example_group(config)
UnitTests::ActiveModelVersions.configure_example_group(config)
UnitTests::ActiveResourceBuilder.configure_example_group(config)
UnitTests::ClassBuilder.configure_example_group(config)
UnitTests::ControllerBuilder.configure_example_group(config)
UnitTests::I18nFaker.configure_example_group(config)
UnitTests::MailerBuilder.configure_example_group(config)
UnitTests::ModelBuilder.configure_example_group(config)
UnitTests::RailsVersions.configure_example_group(config)
UnitTests::ActiveRecordVersions.configure_example_group(config)
UnitTests::ActiveModelVersions.configure_example_group(config)
UnitTests::DatabaseHelpers.configure_example_group(config)
UnitTests::ColumnTypeHelpers.configure_example_group(config)
config.include UnitTests::Matchers
end
ActiveSupport::Deprecation.behavior = :stderr
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end