Created
January 30, 2020 12:51
-
-
Save botandrose/5dc4c20e5f3d63cee191cbf336f3a542 to your computer and use it in GitHub Desktop.
Attempt to reproduce database cleaner bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_record" | |
require "database_cleaner" | |
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" | |
ActiveRecord::Schema.define do | |
create_table :models do |t| | |
t.string :name | |
end | |
end | |
class Model < ActiveRecord::Base | |
end | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with :truncation | |
DatabaseCleaner.strategy = :transaction | |
Model.create! name: "test" | |
end | |
config.around do |example| | |
DatabaseCleaner.start | |
example.run | |
DatabaseCleaner.clean | |
end | |
end | |
RSpec.describe do | |
it "works" do | |
expect(Model.first.name).to eq "test" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment