在 Rails 中,我们可以通过以下语法使用 Minitest:
test "true" do
assert true
end
当我尝试在我的 gem 中使用此语法时,我得到一个 ArgumentError
(参数数量错误)。
明确地说,我不关心 rspec 语法(我更喜欢 assert
而不是 describe
block )。我只想写 test "foo"do
而不是 def test_foo
。
我该怎么做?
我的 test_helper.rb
几乎是空的:
gem 'minitest'
require 'minitest/autorun'
require 'foo/bar'
最佳答案
据我所知,这是一个 ActiveSupport 的东西,而不是一个 Minitest 的东西
https://github.com/rails/rails/blob/master/activesupport/lib/active_support/testing/declarative.rb
您可以快速做的事情是要求“minitest/spec”并将 it
别名为 test
关于ruby - 如何在 Minitest 中使用 block 语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27072598/