Skip to content

Commit

Permalink
fix: persist metadata between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticspoon committed Apr 17, 2024
1 parent 3829473 commit 96f10fc
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ def self.capybara_tmp_path
end
end

module RSpec
module Core
def self.skipped_last
@@skipped_last ||= false
end

def self.skipped_last=(value)
@@skipped_last = value
end
end
end


RSpec.configure do |config|
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::ControllerHelpers, type: :view
Expand Down Expand Up @@ -212,15 +225,15 @@ def seed_base_data_for_tests
end

config.before(:all) do
unless self.class.metadata[:skip_seed]
seed_base_data_for_tests
define_global_variables
unless RSpec::Core.skipped_last
DatabaseCleaner.clean_with(:truncation)
end
end

config.after(:all) do
RSpec::Core.skipped_last = true
unless self.class.metadata[:skip_seed]
DatabaseCleaner.clean_with(:truncation)
seed_base_data_for_tests
define_global_variables
RSpec::Core.skipped_last = false
end
end

Expand Down

0 comments on commit 96f10fc

Please sign in to comment.