mercredi 17 juillet 2019

Why Rspec is cleaning database on 'bundle exec rake spec'?

I don't understand strange thing. I have table in my Postgresql database with 200 items

psql: \c app_test; SELECT COUNT(*) FROM items -->200

After installing rspec rspec-rails gem in rails and executing

RAILS_ENV=test bundle exec rake spec

...

psql: \c app_test; SELECT COUNT(*) FROM items -->0

Seems to be it is cleaning (purge) DB. Why?

Gemfile

group :development, :test do
  gem 'pry-nav', '>= 0.2.3'
  gem 'pry-rails', '>= 0.2.2'
  gem 'letter_opener'
  gem 'factory_girl_rails', '4.2.1'
  gem 'awesome_print'
  gem 'byebug'
  gem 'rspec-rails', '~> 3.8'
end

rails_helper.rb

require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)

abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'


RSpec.configure do |config|

  config.fixture_path = "#{::Rails.root}/spec/fixtures"


  config.use_transactional_fixtures = true

  config.infer_spec_type_from_file_location!

  config.filter_rails_from_backtrace!

end

spec_helper.rb

RSpec.configure do |config|

  config.expect_with :rspec do |expectations|

    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  end

  config.mock_with :rspec do |mocks|

    mocks.verify_partial_doubles = true
  end

  config.shared_context_metadata_behavior = :apply_to_host_groups

end

Aucun commentaire:

Enregistrer un commentaire