Cucumber, Capybara & Rails 2.3.2 - FactoryGirl not committing records to database, but works from console?

I have a strange problem, when I run my (only / first) cucumber test, part of which creates a new entry in my Countries table using:


the models don't get committed to my database (MySql 5) & my test fails as the view tries to load this data. Here is a snippet from my test.log

  [4;36;1mSQL (0.1ms)[0m   [0;1mSAVEPOINT active_record_1[0m
  [4;35;1mCountry Create (0.1ms)[0m   [0mINSERT INTO `countries` (`name`, `country_code`, `currency_code`) VALUES('Ireland', 'IE', 'EUR')[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1mRELEASE SAVEPOINT active_record_1[0m
  [4;35;1mSQL (0.1ms)[0m   [0mSAVEPOINT active_record_1[0m

However when I load up the rails console and run exactly the same command i.e. Factory.create(:country), the records get committed to the database. Here is the output from test.log

[4;36;1mSQL (3.5ms)[0m   [0;1mBEGIN[0m
  [4;35;1mCountry Create (0.2ms)[0m   [0mINSERT INTO `countries` (`name`, `country_code`, `currency_code`) VALUES('Ireland', 'IE', 'EUR')[0m
  [4;36;1mSQL (1.1ms)[0m   [0;1mCOMMIT[0m

From env.rb

Cucumber::Rails::World.use_transactional_fixtures = false

Any advise is very much appreciated, I've spent the last two days trying to figure this out but had no success.


The second line of what you posted from your test.log file shows the record being inserted. I see that you've turned off transactional fixtures, which is fine.

Are you using the database_cleaner gem by chance? If so, it's going to essentially roll your database back to its original state after the tests are done. This means that, unless you pause your tests while they're running, and after data is inserted, you'll never see it in the DB because it gets removed after the test suite is run.

I don't know that this is what's causing the issue at the root of the thing, but it would definitely explain why, when you run just that one command from the console, that you see it in the DB, but you don't after you run your tests. The test data is supposed to be removed after the test suite executes, so your tests have a fresh, consistent starting point for each run. It's an important part of making sure that your tests run in the same environment every time, and therefore can be counted upon to give you reliable results.

Need Your Help

How to find out how many items fit in the QTreeView (number of rows visible on the screen)?

qt qtreeview

I'm sure there's an easy way to get this number, but can't find any.

Nokia Qt Mobility: Close Application On click listwidget item

qt nokia

i am new to Nokia Qt Mobility.. and i have just started to develop an Application. My Question is:: How can i close my Application on listwidgets item click...? Thanks..

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.