百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

shoulda

> 编程语言
开源

使测试对手指和眼睛来说变得轻松

2.2K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

使测试对手指和眼睛来说变得轻松

Shoulda Gem 版本 构建状态 总下载次数 下载次数

Shoulda 可以帮助您编写更易于理解、可维护的 Rails 专用测试 在 Minitest 和 Test::Unit 中。

快速链接

[查看最近版本的变更。][变更记录]

概述

作为一个 umbrella gem, shoulda gem 本身不包含任何代码,但它提供了一个接口, 而是从另外两个宝石中引入了行为:

  • [Shoulda 上下文]
  • [Shoulda 判断器] 例如:
ruby
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 protected]").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

这里的 context 和 should 方法来自 Shoulda Context; 相匹配器 (例如 have_many, allow_value) 来自 Shoulda Matchers。

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言