Shoulda helps you write more understandable, maintainable Rails-specific tests under Minitest and Test::Unit.
As an umbrella gem, the
shoulda gem doesn't contain any code of its own but
rather brings in behavior from two other gems:
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("email@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
should methods come from Shoulda Context; matchers
allow_value) come from Shoulda Matchers.
See the READMEs for these projects for more information.
Shoulda is tested and supported against Ruby 2.4+, Rails 4.2+, RSpec 3.x, Minitest 4.x, and Test::Unit 3.x.
Shoulda follows Semantic Versioning 2.0 as defined at http://semver.org.
The names and logos for thoughtbot are trademarks of thoughtbot, inc.