Created: 2008-04-14 13:27
Updated: 2019-02-26 17:32
License: mit

Shoulda Gem Version Build Status Downloads

Shoulda helps you write more understandable, maintainable Rails-specific tests using Minitest.

The shoulda gem doesn't contain any code of its own; it actually brings behavior from two other gems:

See the READMEs for these projects for more information.


require "test_helper"

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

  context "validations" do
    should validate_presence_of(:email)
    should allow_value("").for(:email)
    should_not allow_value("not-an-email").for(:email)

  context "#name" do
    should "consist of first and last name" do
      user = "John", last_name: "Smith")
      assert_equal "John Smith",

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


Shoulda is tested and supported against Ruby 2.2-2.4, Rails 4.2-5.0, and Minitest 5.


Shoulda is open source, and we are grateful for everyone who's contributed so far.

If you'd like to contribute, please take a look at the instructions for installing dependencies and crafting a good pull request.


Shoulda follows Semantic Versioning 2.0 as defined at


Shoulda is copyright © 2006-2017 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.

About thoughtbot


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

We are passionate about open source software. See our other projects. We are available for hire.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more