You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env rakebeginrequire'bundler/setup'rescueLoadErrorputs'You must `gem install bundler` and `bundle install` to run rake tasks'endAPP_RAKEFILE=File.expand_path("../spec/dummy/Rakefile",__FILE__)load'rails/tasks/engine.rake'Bundler::GemHelper.install_tasksDir[File.join(File.dirname(__FILE__),'tasks/**/*.rake')].each{|f| loadf}require'rspec/core'require'rspec/core/rake_task'desc"Run all specs in spec directory (excluding plugin specs)"RSpec::Core::RakeTask.new(:spec=>'app:db:test:prepare')task:default=>:spec
Create spec/spec_helper.rb
ENV['RAILS_ENV'] ||= 'test'requireFile.expand_path("../dummy/config/environment.rb",__FILE__)require'rspec/rails'require'factory_girl_rails'require'database_cleaner'require'faker'require'pry'Rails.backtrace_cleaner.remove_silencers!# Load support filesDir["#{File.dirname(__FILE__)}/support/**/*.rb"].each{ |f| requiref}RSpec.configuredo |config|
config.color=trueconfig.fail_fast=ENV['FAIL_FAST'] || falseconfig.fixture_path=File.join(File.expand_path(File.dirname(__FILE__)),"fixtures")config.infer_spec_type_from_file_location!config.mock_with:rspecconfig.raise_errors_for_deprecations!# If you're not using ActiveRecord, or you'd prefer not to run each of your# examples within a transaction, comment the following line or assign false# instead of true.config.use_transactional_fixtures=trueconfig.before:eachdoRails.cache.clearendconfig.includeFactoryGirl::Syntax::Methods# Clean out the database state before the tests runconfig.before(:suite)doDatabaseCleaner.clean_with(:truncation)DatabaseCleaner.strategy=:transactionend# Wrap all db isolated tests in a transactionconfig.around(db: :isolate)do |example|
DatabaseCleaner.cleaning(&example)endconfig.arounddo |example|
Timeout.timeout(20, &example)endend