加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 22:58:31 所属栏目:百科 来源:网络整理
导读:我有这样的代码: @dns = "#{params[:domain].split('/').reverse.join('.')}.#{params[:zone]}"w = Whois::Client.new@r = w.query(@dns) 有路线: match "domains/:zone/*domain" = "domains#show" 我正在使用Whois Gem 我想测试一下,所以我有一个测试: i
我有这样的代码:
@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被调用

解决方法

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读