gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 06:57:36 25 4
gpt4 key购买 nike

我有这样的代码:

@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

最佳答案

看起来您可能是在调用查询方法之后设置期望值?

关于ruby-on-rails - any_instance should_receive 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10836551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com