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 Jan 21, 2020
1 parent e23efbb commit 02dfffb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/generators/rspec/install/templates/spec/rails_helper.rb
Expand Up @@ -42,6 +42,13 @@
# 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
<% 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
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 02dfffb

Please sign in to comment.