我试图测试一个方法接收带有包含子字符串的字符串的参数。
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"