Using RSpec for Testing

Using RSpec for Testing

RSpec is a popular testing framework for Ruby and Rails.

  • Add gem rspec-rails to your Gemfile
  • Generate spec files with rails generate rspec:install
  • Write readable, behavior-driven tests

Example:

describe Article do
  it 'is valid with valid attributes' do
    expect(Article.new(title: 'Hello')).to be_valid
  end
end
← PrevNext →