Giter Site home page Giter Site logo

databasecleaner_issue_564's Introduction

Example repo to demonstrate database_cleaner issue 564

Original issue comment

I tried with sqlite to ease up the project setup, and I recreated the bug as well. So it is not tied to mysql specifically

Setup:

  • bundle install
  • bundle exec rails db:create db:migrate
  • bundle exec rake db:test:prepare
  • bundle exec rspec

I put the failing test in "pending" state, so the command rspec is not failing.

RSpec.describe 'DatabaseCleaner issue 564' do
  include_context 'a_user_exist'

  # below test failing
  # switch me from "pending" to "it" when I pass :)
  pending 'user should not get cleaned' do
    expect(User.count).to_not eq 0
  end
end

We can see that the expected value is !=0, yet we got 0 in the test, as if the record was deleted

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) DatabaseCleaner issue 564 user should not get cleaned
     # No reason given
     Failure/Error: expect(User.count).to_not eq 0

       expected: value != 0
            got: 0

       (compared using ==)
     # ./spec/models/database_cleaner_spec.rb:9:in `block (2 levels) in <top (required)>'

Finished in 0.05944 seconds (files took 7.39 seconds to load)
1 example, 0 failures, 1 pending

We can uncomment this code to make the test pass (so rspec will fail because it expects a pending test to fail)

config.before(:suite) do
     DatabaseCleaner.strategy = :transaction
     DatabaseCleaner.clean_with(:truncation)
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.