微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – any_instance should_receive无法正常工作

我有这样的代码
@dns = "#{params[:domain].split('/').reverse.join('.')}.#{params[:zone]}"
w = Whois::Client.new
@r = w.query(@dns)

有路线:

match "domains/:zone/*domain" => "domains#show"

我正在使用Whois Gem

我想测试一下,所以我有一个测试:

it "should query 'google.com.ua' from /ua/com/google" do
    get :show,:zone => 'ua',:domain => 'com/google'
    dns = "google.com.ua"
    Whois::Client.any_instance.should_receive(:query).with(dns)
end

结果我得到:

Exactly one instance should have received the following message(s) but didn't: query

哪里可以问题?我100%肯定.query被调用

解决方法

调用查询方法后,您可能会设置期望值?

原文地址:https://www.jb51.cc/ruby/265348.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐