views:

90

answers:

3

The cucumber test first makes an entry in the database and posts a form to a second server. This second server does some processing in background and then hits the first app (where the test is being run) with some data that the cucumber test needs to know about.

I've tried running the main server via script/server and script/server -e test while the cucumber test is running, but I can't seem to force the server to use the same database that cucumber is using when it runs its step definitions. That is, when the second server pushes some data to a controller in the main server, the main server doesn't know about any entries that cucumber has made in the database. How can I get cucumber and the main server to use the same database?

A: 

It appears that setting Cucumber::Rails::World.use_transactional_fixtures = false in env.rb has solved this problem.

Edit this is no longer working with the latest cucumber install. The rails server isn't finding data put in the database by the cucumber test.

James
+2  A: 

You can share environment settings like this.

config/database.yml

test: &test
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: baseproj_test
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

cucumber:
  <<: *test
jspooner
This is what cucumber does to this file when it's installed. The command I'm using to start the server: (script/server -e test) isn't working still isn't solving my problem.
James
A: 

You hit the solution on the head in your comment (don't have the karma to reply). The tests are run within a transaction, which is rolled back at the end. So, the external server is isolated from the effects of any queries Cucumber performs on the database. Disabling transactional fixtures is the way to go, but I don't know why it's not working.

Other solutions would be to a) rearchitect your code so you don't need a common database (that's bound to cause problems elsewhere), or b) have your Cucumber test reach into a the second server's database (via an HTTP request?).

Michael Melanson