thoughtbot/shoulda

Makes tests easy on the fingers and the eyes

Ruby

2,204

434 commits

updated May 23, 2025

See the code

README

Shoulda Gem Version Build Status Total Downloads Downloads

Shoulda helps you write more understandable, maintainable Rails-specific tests under Minitest and Test::Unit.

📢 See what's changed in recent versions.

Overview

As an umbrella gem, the shoulda gem doesn't contain any code of its own but rather brings in behavior from two other gems:

For instance:

require "test_helper"

class UserTest < ActiveSupport::TestCase
  context "associations" do
    should have_many(:posts)
  end

  context "validations" do
    should validate_presence_of(:email)
    should allow_value("user@example.com").for(:email)
    should_not allow_value("not-an-email").for(:email)
  end

  context "#name" do
    should "consist of first and last name" do
      user = User.new(first_name: "John", last_name: "Smith")
      assert_equal "John Smith", user.name
    end
  end
end

Here, the context and should methods come from Shoulda Context; matchers (e.g. have_many, allow_value) come from Shoulda Matchers.

See the READMEs for these projects for more information.

Compatibility

Shoulda is tested and supported against Ruby 3.0+, Rails 6.1+, RSpec 3.x, Minitest 4.x, and Test::Unit 3.x.

  • For Ruby < 3 and Rails < 6.1 compatibility, please use v4.0.0.

Versioning

Shoulda follows Semantic Versioning 2.0 as defined at http://semver.org.

Team

Shoulda is currently maintained by Pedro Paiva. Previous maintainers include Elliot Winkler, Jason Draper, Gabe Berke-Williams, Ryan McGeary, Joe Ferris, Dan Croaky, and Tammer Saleh.

Copyright/License

Shoulda is copyright © Tammer Saleh and thoughtbot, inc. It is free and opensource software and may be redistributed under the terms specified in the LICENSE file.

About thoughtbot

thoughtbot

This repo is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See our other projects. We are available for hire.

thoughtbot/shoulda

Makes tests easy on the fingers and the eyes

Ruby

2,204

434 commits

updated May 23, 2025

See the code

README

Shoulda Gem Version Build Status Total Downloads Downloads

Shoulda helps you write more understandable, maintainable Rails-specific tests under Minitest and Test::Unit.

📢 See what's changed in recent versions.

Overview

As an umbrella gem, the shoulda gem doesn't contain any code of its own but rather brings in behavior from two other gems:

For instance:

require "test_helper"

class UserTest < ActiveSupport::TestCase
  context "associations" do
    should have_many(:posts)
  end

  context "validations" do
    should validate_presence_of(:email)
    should allow_value("user@example.com").for(:email)
    should_not allow_value("not-an-email").for(:email)
  end

  context "#name" do
    should "consist of first and last name" do
      user = User.new(first_name: "John", last_name: "Smith")
      assert_equal "John Smith", user.name
    end
  end
end

Here, the context and should methods come from Shoulda Context; matchers (e.g. have_many, allow_value) come from Shoulda Matchers.

See the READMEs for these projects for more information.

Compatibility

Shoulda is tested and supported against Ruby 3.0+, Rails 6.1+, RSpec 3.x, Minitest 4.x, and Test::Unit 3.x.

  • For Ruby < 3 and Rails < 6.1 compatibility, please use v4.0.0.

Versioning

Shoulda follows Semantic Versioning 2.0 as defined at http://semver.org.

Team

Shoulda is currently maintained by Pedro Paiva. Previous maintainers include Elliot Winkler, Jason Draper, Gabe Berke-Williams, Ryan McGeary, Joe Ferris, Dan Croaky, and Tammer Saleh.

Copyright/License

Shoulda is copyright © Tammer Saleh and thoughtbot, inc. It is free and opensource software and may be redistributed under the terms specified in the LICENSE file.

About thoughtbot

thoughtbot

This repo is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See our other projects. We are available for hire.

Project health

Overall

3.6/10

Maintained

0/10

Code review

1/10
OpenSSF Scorecard

RubyGems

Latest release

4.0.0 · Jun 13, 2020

Releases this year

0

Significant stargazers

Jay Feldblum

118 followers · starred Dec 2009

Carlos Antonio da Silva

1,129 followers · starred Sep 2008

Andrew White

356 followers · starred Apr 2008

Peter Zhu

255 followers · starred Apr 2020