Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cucumber capybara how does it work

I am using capybara and cucumber in my rails3 application. Everything is working just fine. However I don't understand how tests are working.

Let's say that I have a standard cucumber feature test. I am not using @selenium etc. It is a plain vanilla test. Now when I run

bundle exec cucumber

does that rails server start on a port? If yes then what's the port number? Also in the plain-vanilla case capybara uses rack-test. However rack-test is not responsible to running the server. So I am all confused how the whole thing works. What role cucumber is playing. What job rack-test is doing and what capybara is doing.

If you have links to articles then please share with me. I really want to know how things are working together.

like image 574
Nick Vanderbilt Avatar asked Jan 19 '11 22:01

Nick Vanderbilt


1 Answers

While I don't really know the deepest details of how this works. But I do enough to provide you some perspective.

Cucumber is a ruby acceptance testing framework, it lets you write acceptance in plain english. Now in general it sits on top of Webrat or Capybara which provide it its true power, ie Simulated Browser or Automated Browser testing.

Capybara or Webrat make it easy to run acceptance tests.Capybara makes it very simple to use various drivers to run acceptance testing. Drivers ie Selenium, celerity or rack-test. In a vanilla case, rack-test is used for simulated browser testing.

Rack-Test itself is just responsible for creating the session in which you run your tests in, the step definitions etc have been created by capybara. So basically there is no server running its a just session ( mock-session to be precise ) created by rack-test. Capybara now provides a finders methods and matchers etc on top of this session created by the driver ( rack-test or otherwise ) to help you create your own step definitions.

Cucumber runs the steps, ie the finders /matchers etc in them, on the session and so your tests.

like image 134
Rishav Rastogi Avatar answered Sep 30 '22 14:09

Rishav Rastogi