Andy
Andy

Reputation: 778

Set up cucumber to test sinatra app using watir

I'm developing a sinatra app, and I'd like to test it using cucumber and watir. My problem is that I'm not sure how to set up my env.rb file to run the sinatra app, all the examples I've found use webrat or capybara or something else that isn't watir. Is there a way to start my sinatra app from cucumber without using webrat or another testing framework that isn't watir, or should I just start my sinatra app manually before running my tests?

Upvotes: 1

Views: 648

Answers (1)

Dima Korobskiy
Dima Korobskiy

Reputation: 1556

env.rb executes an arbitrary Ruby code as a part of Cucumber setup, so you should be able to start your app or do whatever else you need. Try:

require 'YourApp'
YourApp.run!

Having said that, it might not be the most logical place to do. An automated build cycle for a web app usually consists of the following steps:

  1. Build: compile, copy necessary files, package a binary, etc.
  2. Run unit tests
  3. Deploy: put the application on a target server
  4. Run integration/feature tests

Cucumber and Watir are all about Step 4; therefore, env.rb usually starts a browser. What you are trying to do belongs logically in Step 3, IMHO.

Upvotes: 1

Related Questions