我们在红宝石中有标准类或宝石吗?我可以使用RSpec :: Matchers吗?

时间:2011-12-06 05:50:06

标签: ruby

我想从yaml文件中读取拒绝或接受数据的过滤器。标准类似于:greater_than,in_list,smaller_than,not_in_list等。

我们已经在RSpec中拥有一组很好的匹配器,我正在考虑使用它们。

require 'rspec/expectations'
include RSpec::Matchers
[1].should have(2).entries
  # raises: RSpec::Expectations::ExpectationNotMetError: expected 2 entries, got 1
[1,3].should have(2).entries
  # returns true

我不喜欢这样一个事实,即每个对象都会在其中包含should方法,并且当期望未满足时它会引发异常。

您是否有其他可以重复使用的开源项目的库或类的建议?

0 个答案:

没有答案