Skip to content

Commit

Permalink
tech: Tweak RSpec config
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkerz committed Aug 2, 2018
1 parent 6251499 commit 585d7d9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -45,6 +45,7 @@ solr/development
solr/test
solr/pids
sunspot-solr.pid
spec/examples.txt

# Files generated by IDEs etc
.ackrc
Expand Down
4 changes: 1 addition & 3 deletions features/support/selectors.rb
Expand Up @@ -79,6 +79,4 @@ def selector_for locator
end

World HtmlSelectorsHelpers

# To avoid typing `FactoryBot.create` all the time (use `create`).
World FactoryBot::Syntax::Methods
World FactoryBot::Syntax::Methods # To avoid typing `FactoryBot.create`.
2 changes: 1 addition & 1 deletion spec/services/taxa/advanced_search_spec.rb
Expand Up @@ -197,7 +197,7 @@
end
end

describe "Searching type fields", :focus do
describe "Searching type fields" do
let!(:one) { create :species, published_type_information: 'one' }
let!(:two) { create :species, additional_type_information: 'one two' }
let!(:three) { create :species, type_notes: 'one two three' }
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -6,8 +6,12 @@
require 'rspec/rails'
require 'paper_trail/frameworks/rspec'

abort "The Rails environment is running in production mode!" if Rails.env.production?

Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

ActiveRecord::Migration.maintain_test_schema!

Feed.enabled = false

# TODO extra curricular: split this and support files into spec_helper/rails_helper.
23 changes: 17 additions & 6 deletions spec/support/rspec.rb
@@ -1,10 +1,24 @@
RSpec::Expectations.configuration.warn_about_potential_false_positives = false

RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = true
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end

config.order = :random # Run `rspec --seed 1234` for debugging order dependency.
config.fail_fast = false
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
config.filter_run_when_matching :focus unless ENV['TRAVIS']
config.use_transactional_fixtures = true
Kernel.srand config.seed
# TODO enable? `config.disable_monkey_patching!`
# TODO maybe add `config.render_views = true`.
# config.profile_examples = 10 # Uncommen to show slow specs.

# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options.
config.example_status_persistence_file_path = "spec/examples.txt"

config.before :suite do
DatabaseCleaner.strategy = :transaction
Expand Down Expand Up @@ -33,9 +47,6 @@
Feed.enabled = false
end

config.infer_spec_type_from_file_location!
config.include Devise::Test::ControllerHelpers, type: :controller

# To avoid typing `FactoryBot.create` all the time (use `create`).
config.include FactoryBot::Syntax::Methods
config.include FactoryBot::Syntax::Methods # To avoid typing `FactoryBot.create`.
end
1 change: 1 addition & 0 deletions spec/support/webmock.rb
@@ -1,2 +1,3 @@
require 'webmock/rspec'

WebMock.disable_net_connect! allow_localhost: true

0 comments on commit 585d7d9

Please sign in to comment.