Skip to content

Commit

Permalink
Fixed RSpec configuration
Browse files Browse the repository at this point in the history
Necessary to utilize all of what RSpec provides for us. link:https://alchemists.io/articles/rspec_configuration[Details]. More work is needed here to make this better but this is a good start.
  • Loading branch information
bkuhlmann committed Feb 17, 2025
1 parent a060191 commit 2435d2a
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,37 @@
require 'database_cleaner/active_record'
require_relative '../app'

# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
SPEC_ROOT = Pathname(__dir__).realpath.freeze

ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Schema.verbose = false
load 'db/schema.rb'

RSpec.configure do |config|
config.include Rack::Test::Methods

ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Schema.verbose = false
load 'db/schema.rb'
config.color = true
config.disable_monkey_patching!
config.example_status_persistence_file_path = "./tmp/rspec-examples.txt"
config.filter_run_when_matching :focus
config.formatter = ENV.fetch("CI", false) == "true" ? :progress : :documentation
config.order = :random
config.pending_failure_output = :no_backtrace
config.shared_context_metadata_behavior = :apply_to_host_groups
config.warnings = true

config.expect_with :rspec do |expectations|
expectations.syntax = :expect
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.mock_with :rspec do |mocks|
mocks.verify_doubled_constant_names = true
mocks.verify_partial_doubles = true
end

config.shared_context_metadata_behavior = :apply_to_host_groups

DatabaseCleaner.strategy = :truncation
config.after do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean
end

Expand Down

0 comments on commit 2435d2a

Please sign in to comment.