mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-20 02:36:25 -07:00
set up example scaffold with rspec + factorybot tests
This commit is contained in:
parent
533c921a6d
commit
d1e6fb1e39
23 changed files with 512 additions and 6 deletions
|
|
@ -1,10 +1,11 @@
|
|||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
require 'spec_helper'
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require_relative '../config/environment'
|
||||
require "spec_helper"
|
||||
ENV["RAILS_ENV"] ||= "test"
|
||||
require_relative "../spec/dummy/config/environment"
|
||||
# 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"
|
||||
|
||||
# Add additional requires below this line. Rails is not loaded until this point!
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc, in
|
||||
|
|
@ -29,12 +30,19 @@ begin
|
|||
rescue ActiveRecord::PendingMigrationError => e
|
||||
abort e.to_s.strip
|
||||
end
|
||||
|
||||
require "factory_bot_rails"
|
||||
|
||||
FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), "factories")
|
||||
FactoryBot.factories.clear
|
||||
FactoryBot.find_definitions
|
||||
|
||||
RSpec.configure do |config|
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_paths = [
|
||||
Rails.root.join('spec/fixtures')
|
||||
Rails.root.join("spec/fixtures")
|
||||
]
|
||||
|
||||
config.include FactoryBot::Syntax::Methods
|
||||
# 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
|
||||
# instead of true.
|
||||
|
|
@ -62,4 +70,9 @@ RSpec.configure do |config|
|
|||
config.filter_rails_from_backtrace!
|
||||
# arbitrary gems may also be filtered via:
|
||||
# config.filter_gems_from_backtrace("gem name")
|
||||
config.before(:example, type: :view) do
|
||||
view.class_eval do
|
||||
include Dashboard::Engine.routes.url_helpers
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue