I have a code like this:
@dns = "#{params[:domain].split('/').reverse.join('.')}.#{params[:zone]}"
w = Whois::Client.new
@r = w.query(@dns)
with a route:
match "domains/:zone/*domain" => "domains#show"
I'm using Whois Gem
and I want to test is, so I have a test:
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
And as a result I get:
Exactly one instance should have received the following message(s) but didn't: query
Where can be the problem? I'm 100% sure that .query
is called
It looks like you might be setting the expectation after you've already called the query method?