database_rewinder icon indicating copy to clipboard operation
database_rewinder copied to clipboard

`DatabaseRewinder.clean_all` is not working at rails 7.1.0

Open starfish719 opened this issue 2 years ago • 6 comments

spec/support/database_rewrider.rb

# frozen_string_literal: true

require 'rake'

RSpec.configure do |config|
  except_tables = %w[
   hoge
  ]

  config.before(:suite) do
    DatabaseRewinder.strategy = [except: except_tables]
    DatabaseRewinder.clean_all
  end

  config.after do
    DatabaseRewinder.clean
  end
end
# bundle exec rspec           

An error occurred in a `before(:suite)` hook.
Failure/Error: DatabaseRewinder.clean_all

NoMethodError:
  undefined method `table_name' for ActiveRecord::SchemaMigration:Class
# ./spec/support/database_rewinder.rb:12:in `block (2 levels) in <main>'

Active Record version is 7.1.0

irb(main):013> ActiveRecord::VERSION::STRING
=> "7.1.0"

ruby and rails version

$ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
$ bundle exec rails -v
Rails 7.1.0

This code was working at rails 7.0.8 . But not working when update rails 7.1.0 . I hope this code work at rails 7.1.0 .

starfish719 avatar Oct 10 '23 00:10 starfish719

Looks like support for Rails 7.1 was added in https://github.com/amatsuda/database_rewinder/commit/52c4d0c2317541a75cea08b579349a5a843b8212 and https://github.com/amatsuda/database_rewinder/commit/38702721d7299a23a945417c37d1f202e5e0aea7 but there has been no gem release since.

@amatsuda Are you able to release a new version of the gem with these changes now that Rails 7.1 is out?

dtcristo avatar Oct 17 '23 00:10 dtcristo

I'm still running into issues when using the version from master in a Rails 7.1 application. I still need to investigate further, but it seems DatabaseRewinder.clean (running after each spec) is not working correctly.

dtcristo avatar Oct 17 '23 06:10 dtcristo

@dtcristo Thank you for your comment. I hope release a new version.

starfish719 avatar Oct 18 '23 01:10 starfish719

@amatsuda Please release a new version of the gem. https://github.com/amatsuda/database_rewinder/issues/84#issuecomment-1765456421

starfish719 avatar Oct 27 '23 09:10 starfish719

Please, merge this - very valuable gem, but need it in Rails 7.1.1. 🙏

marisveide avatar Oct 31 '23 15:10 marisveide

This seems to be working in the latest release (0.9.9). I'm running Rails 7.1.2 and #clean_all is not raising the error.

shetty-tejas avatar Dec 12 '23 06:12 shetty-tejas