spec/lita/handlers/whois_spec.rb in lita-whois-0.1.0 vs spec/lita/handlers/whois_spec.rb in lita-whois-1.1.0

- old
+ new

@@ -1,14 +1,14 @@ require 'spec_helper' describe Lita::Handlers::Whois, lita_handler: true do - it { routes_command('whois example.com').to(:whois_domain) } - it { routes_command('whois .io').to(:whois_tld) } - it { routes_command('whois 8.8.8.8').to(:whois_ip) } - it { routes_command('whois 2001:418:141e:196::fc4').to(:whois_ip) } + it { is_expected.to route_command('whois example.com').to(:whois) } + it { is_expected.to route_command('whois .io').to(:whois) } + it { is_expected.to route_command('whois 8.8.8.8').to(:whois) } + it { is_expected.to route_command('whois 2001:418:141e:196::fc4').to(:whois) } - describe '#whois_domain' do + describe '#whois' do let(:domain_good) do client = double expect(client).to receive(:lookup) { 'Generic response example.com' } client end @@ -38,15 +38,13 @@ end it 'shows an error when the domain does not have a WHOIS' do expect(Whois::Client).to receive(:new) { domain_err } send_command('whois asdf.sdf') - expect(replies.last).to eq('Cannot find a WHOIS server for asdf.sdf') + expect(replies.last).to eq('Error looking up WHOIS data for asdf.sdf') end - end - describe '#whois_tld' do let(:tld_good) do client = double expect(client).to receive(:lookup) { 'Generic TLD response .io' } client end @@ -66,13 +64,11 @@ it 'shows an error when the tld does not exist' do expect(Whois::Client).to receive(:new) { tld_bad } send_command('whois .wtf') expect(replies.last).to eq('Invalid TLD response .wtf') end - end - describe '#whois_ipv4' do let(:ipv4_good) do client = double expect(client).to receive(:lookup) { 'Generic IPv4 response 8.8.8.8' } client end @@ -102,11 +98,11 @@ end it 'shows an error when the IP is invalid' do expect(Whois::Client).to receive(:new) { ipv4_err } send_command('whois 0.0.0.0') - expect(replies.last).to eq('Cannot find a WHOIS server for 0.0.0.0') + expect(replies.last).to eq('Error looking up WHOIS data for 0.0.0.0') end it 'shows results for the IPv6 address' do expect(Whois::Client).to receive(:new) { ipv6_good } send_command('whois 2001:418:141e:196::fc4') @@ -114,9 +110,9 @@ end it 'shows an error when the IP is invalid' do expect(Whois::Client).to receive(:new) { ipv6_err } send_command('whois ::') - expect(replies.last).to eq('Cannot find a WHOIS server for ::') + expect(replies.last).to eq('Error looking up WHOIS data for ::') end end end