Questions tagged [database-cleaner]

Database Cleaner is a set of strategies for cleaning your database in Ruby, primarily for testing purposes.

Database Cleaner is a set of strategies for cleaning your database in Ruby.

The original use case was to ensure a clean state during tests. Each strategy is a small amount of code but is code that is usually needed in any ruby app that is testing with a database.

ActiveRecord, DataMapper, Sequel, MongoMapper, Mongoid, CouchPotato, Ohm and Redis are supported.

https://github.com/DatabaseCleaner/database_cleaner

145 questions
0
votes
0 answers

Rails rspec tests are failing in Docker and CI

When I run rspec localy all specs pass. When I run all specs in Docker or CI, they fail. However, when I run them in isolation, they pass. Another thing to mention is that every time I have different set of specs failing. Environment setup: ruby…
0
votes
1 answer

RSpec, Postgres, and DatabaseClearer: is it possible to reset ids with transaction strategy?

I know that I shouldn't be coding to specific ids, but sometimes it just makes life a lot easier. I am using DatabaseCleaner with RSpec and Postgres and I am wondering if it is possible to reset ids in between specs when using the transaction…
Eli Duke
  • 454
  • 1
  • 3
  • 14
0
votes
0 answers

Remove Rspec testing data after testing using database_cleaner

I am using Rspec to test my rails application. This application uses some preloaded data and some customized data. now i want to test this application in the same development environment without changing the state of the database. I use the…
Atif Hussain
  • 880
  • 12
  • 19
0
votes
1 answer

How to have Database Cleaner reset the insert ID to 1?

I switched from using truncation to transaction strategy for Database Cleaner. It is much faster (2.5x, to be precise). The issue now is that I have some tests that expect the first insert ID to be 1. These tests are for paging responses. They…
B Seven
  • 44,484
  • 66
  • 240
  • 385
0
votes
1 answer

Can't fabricate many items with Fabrication-gem and Mongoid

I'm using Fabrication-gem gem, with DatabaseCleaner and Mongoid ORM on RSpec tests. Here are my scripts: spec/support/database_cleaner.rb RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.strategy = :truncation …
Hassen
  • 6,966
  • 13
  • 45
  • 65
0
votes
1 answer

Database cleaner not working with vim-rspec plugin

I use vim-rspec plugin to be able to run rspec tests from within vim, and it was working very well so far. But suddenly the database_cleaner gem stopped working. Here is my configuration: # spec/rspec_rails.rb Rspec.configure do |config| …
Nafaa Boutefer
  • 2,169
  • 19
  • 26
0
votes
1 answer

RSpec tests with Factory Girl creating image

In a rails 4.2.0 app I'm using RSpec and Factory Girl for tests. In the app I am using Paperclip for image uploads. When I run the tests with a blank image the image is being placed in the public folder. Is there any way I can use the…
Koxzi
  • 1,021
  • 1
  • 10
  • 21
0
votes
1 answer

rails ActiveRecord transactional Integrity / Data not committing mid scenario spec?

I know i'm mis-understanding how ActiveRecord maintains integrity/works: hoping someone can clarify for me explaining why the following is not working? We have an abnormal situation: our rails app calls a compiled binary that accesses (and creates…
Ben
  • 1,292
  • 1
  • 13
  • 21
0
votes
1 answer

Instance created in db but not showed in page. Test cleaning in Rspec

I'm trying to clean my db between specs. So I decided to use the popular gem database_cleaner. The problem now is that when I create a new instance of a model with FactoryGirl, it is created but not showed in the page. Here is my…
hcarreras
  • 4,442
  • 2
  • 23
  • 32
0
votes
1 answer

Is the database trucation strategy will force every thread to use the same database?

In reference to this thread here, does this mean a truncation strategy will force every thread to use the same database, or does it mean Capybara + Rspec will run in the same thread?
Nona
  • 5,302
  • 7
  • 41
  • 79
0
votes
1 answer

Spring Data Neo4j - Unit Test - cleandb NullPointerException

I am building an application using spring-boot (1.1.8.RELEASE), spring-data-neo4j (3.2.0.RELEASE) in order to connect to a stand alone neo4j server via rest api. I am using spring-test in order to test the application. I would like to clean the…
0
votes
1 answer

Selenium with Capybara failing test

I'm having a problem with my Selenium test, it looks like the test data is not getting added to the right environment or Selenium is trying to read from the wrong one. The below test passes without :js => true but with it it fails it "allows the…
0
votes
1 answer

Rspec and Capybara: saving results to database?

I'm fairly new to RSpec and have been trying to create some tests for my website, on which a user can post a reservation to the website, which is then saved to our database. I've been trying, using Rspec and Capybara, to simulate a user posting a…
0
votes
1 answer

Database not cleaning when testing Controllers with RSpec

When testing my Models with RSpec I use the following code to clean my database: config.before(:suite) do begin DatabaseCleaner.start ensure DatabaseCleaner.clean end end config.after(:suite) do …
Harbinger
  • 115
  • 9
0
votes
1 answer

Rspec does not save records to DB

I'm writing tests for my rails_4 applicatation. I use rspec, selenium, capybara, database_cleaner, site_prism and factory girl. I use 2 databases in my app, and in me tests I need to check that records in 1st DB are equal records in 2nd DB... But…
bmalets
  • 3,207
  • 7
  • 35
  • 64
1 2 3
9
10