Sha256: ebfa0cb3fe3d430cb7014fb0284d48b0a1f13e7a524ea15cab20ce5b9e6bc8d0

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require "spec/helper/all"

describe "Asynchronous WHOIS" do

  it "should not use synchronous socket methods" do
    
    EM.synchrony do
      Whois::Server::Adapters::Base.any_instance.should_not_receive(:orig_ask_the_socket)

      whois = Whois.whois("google.com")
      whois.should_not be_available # Sanity check

      whois = Whois.whois("#{rand(Time.now.to_i)}-alskdjflkasjd.com")
      whois.should be_available # Sanity check

      EM.stop
    end

  end

  it "should match synchronous WHOIS results" do
    async_whois = nil
    sync_whois = nil

    EM.synchrony do
      async_whois = Whois.whois("github.com")
      EM.stop
    end

    sync_whois = Whois.whois("github.com")

    async_whois.properties.should == sync_whois.properties
  end

end

describe "Synchronous WHOIS" do

  it "should not use asynchronous socket methods" do
    Whois::Server::Adapters::Base.any_instance.should_not_receive(:em_ask_the_socket)

    whois = Whois.whois("google.com")
    whois.should_not be_available # Sanity check

    whois = Whois.whois("#{rand(Time.now.to_i)}-alskdjflkasjd.com")
    whois.should be_available # Sanity check
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
em-whois-0.3.0 spec/em-whois_spec.rb
em-whois-0.2.0 spec/em-whois_spec.rb
em-whois-0.1.1 spec/em-whois_spec.rb