How can I get the rails server to use the same database cucumber uses during the test?

The cucumber test first makes an entry in the database and submits the form to the second server. This second server does some processing in the background and then ends up in the first application (where the test is running) with some data that the cucumber test needs to know about.

I've tried starting the main server through script/server

and script/server -e test

during cucumber validation, but I can't seem to get the server to use the same database as the cucumber when it does its defining step. That is, when the second server pushes some data to the controller on the master server, the master server is unaware of any entries that the cucumber has made in the database. How can I get cucumber and main server to use the same database?

+2


a source to share


3 answers


You bang the solution over the head in your comment (you have no karma to answer). Tests are executed inside a transaction that is returned at the end. In this way, the front-end server is insulated from the consequences of any queries that cucumber makes to the database. Disabling transactional lights is the way to go, but I don't know why it doesn't work.



Other solutions are to: a) rebuild your code so you don't need a shared database (which might cause problems elsewhere), or b) so that your Cucumber test hits the second server database (via an HTTP request? ).

0


a source


You can exchange environment settings as follows.

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

      

+2


a source


It looks like setting Cucumber::Rails::World.use_transactional_fixtures = false

in has env.rb

solved this problem.

Edit this doesn't work anymore with the latest cucumber installation. Rails server does not find data put into database by cucumber dough.

0


a source







All Articles