Connect With Us

Rspec Capybara

By Neha Suwal on Mar, 18, 2016

Rails makes it easier to write your tests. Rspec- rails extends Rails' built-in testing framework to support rspec for requests, controllers, models, views, helpers, mailers and routing.
To install rspec-rails in your rails project, you need to add “ gem rspec-rails ” in your development and test group. Then run bundle install. The “ rails generate rspec:install ” , this command adds spec folder with spec_helper.rb and rails_helper.rb which is used for configurations. For running the specs, “ bundle exec rspec ” is used. By default all _spec.rb files in the spec folder is run.

Rspec testing can be of various types such as controller, model, view, feature, routing, request.

Amongst these all feature testing are high-level tests that walk through your entire application ensuring that each of the components works together. For using feature test we use Capybara, which allow you to write tests that can interact with the web page.

For installing capybara in the project, add ‘gem capybara ’ in your test group. Then run bundle install. Then require capybara/ rails in your spec_helper.rb. To run the test via capybara, selenium-webdriver is required. So you need to add selenium-webdriver in the gem file and run bundle install.

Writing feature test via capybara is a fun element in rails for testing.

Presentation On Rspec Capybara

Share This:

Latest Posts


Integrating Afterpay Payment in a Rails Project By Umesh P Kafle on Sep, 07, 2018

Switching to React Native from Ruby on Rails By Kamal Pandey on Aug, 29, 2018

Jyaasa in IT Career Fair 2018 By Sonika Thapa on Jun, 12, 2018

Encrypted secrets in Ruby on Rails By Rasna Shakya on Apr, 20, 2018

Rails Payment Integration with zipPay (Buy Now and Pay Later) By Nelson Suwal on Mar, 23, 2018