Skip to content

Commit

Permalink
Add configuration to supress active_record checks
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Mar 4, 2020
1 parent e23efbb commit 71934df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/generators/rspec/install/templates/spec/rails_helper.rb
Expand Up @@ -42,6 +42,20 @@
# instead of true.
config.use_transactional_fixtures = true

# You can uncomment this line to turn off active_record support entirely.
# config.use_active_record = false

<% else -%>
# Remove this line to enable support for active_record
config.use_active_record = false
# If you enable active_record support you shound unncomment these lines,
# note if you'd prefer not to run each example within a transaction, you
# should set use_transactional_fixtures to false.
#
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
# config.use_transactional_fixtures = true
<% end -%>
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
Expand Down
1 change: 1 addition & 0 deletions lib/rspec/rails/configuration.rb
Expand Up @@ -64,6 +64,7 @@ def self.initialize_configuration(config)
config.add_setting :infer_base_class_for_anonymous_controllers, default: true

# fixture support
config.add_setting :use_active_record, default: true
config.add_setting :use_transactional_fixtures, alias_with: :use_transactional_examples
config.add_setting :use_instantiated_fixtures
config.add_setting :global_fixtures
Expand Down
4 changes: 4 additions & 0 deletions lib/rspec/rails/fixture_support.rb
Expand Up @@ -10,6 +10,10 @@ module FixtureSupport
include ActiveRecord::TestFixtures

included do
FixtureSupport.setup if RSpec.configuration.use_active_record?
end

def self.setup
self.fixture_path = RSpec.configuration.fixture_path
if ::Rails::VERSION::STRING > '5'
self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
Expand Down

0 comments on commit 71934df

Please sign in to comment.