我有
require 'minitest/spec'
require 'minitest/autorun'
require 'minitest/tags'
require 'rspec/expectations'
describe "One happy and one sad test", :happy do
include RSpec::Matchers
it "it is true" do
expect(true).to be true
end
it "it is false" do
expect(false).to be true
end
end
describe
标签有效,但我无法将标签添加到 it
,如
it "it is true", :happy do
expect(true).to be true
end
没有得到:
$ ruby 测试示例.rb
...1: from test_example.rb:9:in `block in <main>'
.../minitest-5.11.3/lib/minitest/spec.rb:212:in `it':
wrong number of arguments (given 2, expected 0..1) (ArgumentError)
我的 Gem 文件中有 minitest-tags gem 并且已经捆绑
minitest-tags gem 不接受标签作为附加参数,而是在标题文本中给出:
it "does stuff(some,tags)"
但是,如果您想要更多类似 describe
的标签,那么我认为您需要使用 minispec-metadata相反:
it "does stuff", :some, :tags
然后您可以使用 --tag
选项运行选定的测试:
$ ruby test_example.rb --tag some --tag tags
请注意,minitest-tags gem 已经过时了,如果同时安装,它会与 minispec-metadata 发生冲突!我建议卸载 minitest-tags,改用 minispec-metadata。
OP 的注释 - 所以我最终得到了:
require 'minitest/spec'
require 'minitest/autorun'
require 'minispec-metadata'
require 'rspec/expectations'
describe "One happy and one sad test" do
include RSpec::Matchers
it "is is true", :happy do
expect(true).to be true
end
it "it is false", :sad do
expect(true).to be true
end
end
我是一名优秀的程序员,十分优秀!