我怎样才能检查"""方法包括一些特定的字符串

时间:2017-11-07 14:30:14

标签: testing rspec

我试图测试一个方法接收带有包含子字符串的字符串的参数。

class Foo
  def to_test
    called_method “it includes paypal.com“
  end
end

我尝试了所有这些不同的方式:

expect(Foo).to receive(:called_method)).with(include('paypal'))
expect(Foo).to receive(:called_method)).with('paypal')
expect(Foo).to receive(:called_method).with /paypal.com/

subject.to_test

但输出总是失败的测试,如下所示:

expected include('paypal')
got “it includes paypal.com"

expected 'paypal'
got “it includes paypal.com"

expected /paypal/ 
got “it includes paypal.com"

0 个答案:

没有答案
相关问题