Can anyone tell me the difference between rspec, capybara and cucumber?
group :development, :test do gem 'rspec-rails', '~> 2.0' end group :test do gem 'capybara', '~>2.1.0' end
In JavaScript, I see Jasmine as my Unit-test framework. What do these three gems do in Ruby environment?
The main difference between RSpec and Cucumber are the business readability factor. Cucumber's main draw is that the specification (features) are separate from the test code, so your product owners can provide or review the specification without having to dig through code.
capybara allows us to interact with web browser using ruby code, eg: click_link 'Go to next page' . webdrivers is responsible for downloading the driver needed to control the web browser (eg: chromedriver), and we will use this driver to launch and run automated action on the web browser.
RSpec is a testing tool for Ruby, created for behavior-driven development (BDD). It is the most frequently used testing library for Ruby in production applications. Even though it has a very rich and powerful DSL (domain-specific language), at its core it is a simple tool which you can start using rather quickly.
Capybara is a web-based test automation software that simulates scenarios for user stories and automates web application testing for behavior-driven software development. It is written in the Ruby programming language.
rspec
is a full-featured testing framework that will let you write what Rails considers unit tests, functional tests, and integration tests. All of these exercise Ruby code through various layers of your Rails application. All of these tests simulate requests to your Rails application, but don't actually run the application end-to-end over the network.
cucumber
is a browser based integration testing framework, which allows writing automated tests that run against the entire Rails application accessed from within an automated web browser. This allows you to write automated tests about in-browser behavior for JS or CSS. Cucumber provides a unique angle on integration testing that uses plain english specification mapped to code via regular expressions. This allows a more natural "Behavior Driven Development" model - describing what a web application should do, in plain language, from the perspective of the user.
capybara
is a particular web driver powering the cucumber
integration testing framework, that uses headless webkit. This allows running a headless (without UI) Chrome/Webkit browser for automated testing. This is very useful both in development, but especially on a remote test/continuous integration server.
So rspec
and cucumber
are similar in being testing frameworks with their own way of specifying things. rspec
has a nice DSL that's very readable while being actual code. cucumber
maps plain text descriptions to real code.
Though cucumber
is usually used on top of capybara, you can also use rspec
to drive capybara
integration tests. The tests are written in either rspec or cucumber, but capybara
is an integration engine underneath.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With