パラメータやその他のものを含むテーブルがいくつかありますが、変更されることはありません。
しかし、このデータを保持するようにdatabase_cleanerに指示することはできません。各テストの後で、すべてのデータベースが切り捨てられます。
宝石
gem "cucumber-rails", "~> 1.3.0", require: false
gem 'factory_girl_rails'
gem 'database_cleaner'
Config / cucumber.yml
enter code here
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
機能/サポート/環境
require 'cucumber/rails'
require 'database_cleaner'
require 'database_cleaner/cucumber'
require 'factory_girl_rails'
Capybara.default_selector = :css
ActionController::Base.allow_rescue = false
begin
DatabaseCleaner.logger = Rails.logger
DatabaseCleaner.clean_with(:truncation, :except => %w[regions departements villes positions levels footballtypes genders publicies types])
DatabaseCleaner.strategy = :truncation, {:except => %w[regions departements villes positions levels footballtypes genders publicies types]}
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Cucumber::Rails::World.use_transactional_fixtures = false
Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
DatabaseCleaner.clean_with(:truncation, :except => %w[regions departements villes positions levels footballtypes genders publicies types])
DatabaseCleaner.strategy = :truncation, {:except => %w[regions departements villes positions levels footballtypes genders publicies types]}
end
Before do
DatabaseCleaner.strategy = :truncation, {:except => %w[regions departements villes positions levels footballtypes genders publicies types]}
DatabaseCleaner.clean_with(:truncation, :except => %w[regions departements villes positions levels footballtypes genders publicies types])
DatabaseCleaner.start
end
After do |scenario|
DatabaseCleaner.clean_with(:truncation, :except => %w[regions departements villes positions levels footballtypes genders publicies types])
DatabaseCleaner.strategy = :truncation, {:except => %w[regions departements villes positions levels footballtypes genders publicies types]}
DatabaseCleaner.clean
end
手がかりはありますか?ありがとう、ネルソン