How To Setup Up Rspec In A Rails Application For Testing  – A Lean Version

Setup Up Rspec In A Rails Application

RSpec is the most popular testing framework among Ruby community and we also use it extensively. Let’s see how to set up it quickly in any Rails application without getting into many details.

Lean Version

Step 1 - Setting up Rails Application

New Rails App

$ rails new myapp -T

Existing Rails App

Remove app/test directory if present

Step 2  -  Install gems

Configure Gemfile as per the below gist and bundle

Step 3  -  Install and Configuring RSpec

Run the following command

$ rails generate rspec:install

Configure .rspec

Add following lines in .rspec

-- require spec_helper

-- order rand

-- format documentation

Configure Database Cleaner

Add the following in rails_helper.rb

Now, run rspec to ensure setup complete

That’s it!!

Click here for more details…

Consulting is free – let us help you grow!

Related posts

Top 8 Essential Features of Ruby on Rails Web Development

by Shardul Bhatt
3 years ago

7 Reasons to Consider React Native for Mobile App Development

by Sanjay Prajapati
5 years ago

How Shopify App Development helps Small Businesses and Startups in COVID19

by Parth Barot
5 years ago
Exit mobile version