Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

any_instance should_receive not working correctly

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

like image 223
Uko Avatar asked May 31 '12 15:05

Uko


1 Answers

It looks like you might be setting the expectation after you've already called the query method?

like image 110
Andy Waite Avatar answered Sep 25 '22 23:09

Andy Waite