Connect With Us

Rspec Capybara

By Neha Suwal on Oct, 16, 2016 in rails, testing, rspec, capybara

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:


Awesome Like to read similar post on future
 August 24, 2016

Add a new comment

Latest Posts

Getting started with React Native: Core Architecture of React Native By Aman Maharjan on Dec, 15, 2017

First Step to Software Development: Design Thinking Process By Rasna Shakya on Nov, 03, 2017

Bourbon By Rasna Shakya on Oct, 20, 2017

Design Sprint By Neha Suwal on Aug, 14, 2017

3 years of helping startups and entrepreneurs with technology By Neha Suwal on Aug, 04, 2017