Any_instance should_receive does not work correctly

I have a code like this:

@dns = "#{params[:domain].split('/').reverse.join('.')}.#{params[:zone]}"
w = Whois::Client.new
@r = w.query(@dns)

with route:

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

I am using whois gem

and I want to test, 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 could the problem be? I am 100% sure what .queryis called

+5
source share
1 answer

It looks like you can set the wait after you have already called the request method?

+11
source

All Articles