【问题标题】:How can I use block syntax with Minitest?如何在 Minitest 中使用块语法?
【发布时间】:2014-11-22 00:23:37
【问题描述】:

在 Rails 中,我们可以通过以下语法使用 Minitest:

test "true" do
  assert true
end

当我尝试在我的 gem 中使用此语法时,我得到一个 ArgumentError(参数数量错误)。

明确地说,我不关心 rspec 语法(我更喜欢 assert 而不是 describe 块)。我只想写test "foo" do 而不是def test_foo

我该怎么做?

我的test_helper.rb 几乎是空的:

gem 'minitest'
require 'minitest/autorun'
require 'foo/bar'

【问题讨论】:

    标签: ruby testing gem minitest


    【解决方案1】:

    据我所知,这是 ActiveSupport 的事情,而不是 Minitest 的事情

    https://github.com/rails/rails/blob/master/activesupport/lib/active_support/testing/declarative.rb

    您可以做的一个快速的事情是要求 'minitest/spec' 和别名 it as test

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多