whois 5.0.1 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +6 -2
  3. data/.github/dependabot.yml +19 -0
  4. data/.github/workflows/codeql-analysis.yml +64 -0
  5. data/.github/workflows/release.yml +16 -0
  6. data/.github/workflows/tests.yml +30 -0
  7. data/.rubocop.yml +27 -0
  8. data/.rubocop_opinionated.yml +135 -0
  9. data/.rubocop_todo.yml +166 -0
  10. data/.simplecov +2 -0
  11. data/.tool-versions +1 -0
  12. data/CHANGELOG.md +86 -54
  13. data/CONTRIBUTING.md +12 -12
  14. data/Gemfile +6 -1
  15. data/LICENSE.txt +1 -1
  16. data/README.md +22 -22
  17. data/Rakefile +12 -17
  18. data/bin/console +1 -0
  19. data/bin/whoisrb +4 -3
  20. data/data/ipv4.json +1 -3
  21. data/data/tld.json +10 -103
  22. data/lib/whois/client.rb +4 -2
  23. data/lib/whois/errors.rb +4 -2
  24. data/lib/whois/record/part.rb +5 -4
  25. data/lib/whois/record.rb +4 -2
  26. data/lib/whois/server/adapters/afilias.rb +4 -1
  27. data/lib/whois/server/adapters/arin.rb +7 -4
  28. data/lib/whois/server/adapters/arpa.rb +20 -19
  29. data/lib/whois/server/adapters/base.rb +26 -40
  30. data/lib/whois/server/adapters/formatted.rb +4 -2
  31. data/lib/whois/server/adapters/none.rb +3 -1
  32. data/lib/whois/server/adapters/not_implemented.rb +3 -1
  33. data/lib/whois/server/adapters/standard.rb +4 -2
  34. data/lib/whois/server/adapters/verisign.rb +4 -1
  35. data/lib/whois/server/adapters/web.rb +3 -1
  36. data/lib/whois/server/socket_handler.rb +8 -6
  37. data/lib/whois/server.rb +41 -47
  38. data/lib/whois/version.rb +4 -2
  39. data/lib/whois.rb +15 -13
  40. data/spec/integration/whois_spec.rb +7 -7
  41. data/spec/spec_helper.rb +4 -4
  42. data/spec/support/helpers/connectivity_helper.rb +3 -3
  43. data/spec/support/helpers/spec_helper.rb +2 -0
  44. data/spec/whois/client_spec.rb +8 -9
  45. data/spec/whois/record/part_spec.rb +4 -4
  46. data/spec/whois/record_spec.rb +11 -9
  47. data/spec/whois/server/adapters/afilias_spec.rb +4 -4
  48. data/spec/whois/server/adapters/arin_spec.rb +9 -10
  49. data/spec/whois/server/adapters/arpa_spec.rb +2 -2
  50. data/spec/whois/server/adapters/base_spec.rb +13 -13
  51. data/spec/whois/server/adapters/formatted_spec.rb +8 -8
  52. data/spec/whois/server/adapters/none_spec.rb +2 -2
  53. data/spec/whois/server/adapters/not_implemented_spec.rb +4 -4
  54. data/spec/whois/server/adapters/standard_spec.rb +5 -5
  55. data/spec/whois/server/adapters/verisign_spec.rb +5 -5
  56. data/spec/whois/server/adapters/web_spec.rb +4 -4
  57. data/spec/whois/server/socket_handler_spec.rb +7 -5
  58. data/spec/whois/server_spec.rb +31 -29
  59. data/spec/whois/{errors_spec.rb → web_interface_error_spec.rb} +4 -4
  60. data/spec/whois/whois_spec.rb +3 -3
  61. data/whois.gemspec +10 -10
  62. metadata +16 -11
  63. data/.travis.yml +0 -18
  64. data/bin/setup +0 -8
  65. data/tasks/spec.rake +0 -199
@@ -1,14 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Client do
4
-
5
6
  describe "#initialize" do
6
7
  it "accepts a zero parameters" do
7
- expect { described_class.new }.to_not raise_error
8
+ expect { described_class.new }.not_to raise_error
8
9
  end
9
10
 
10
11
  it "accepts a settings parameter" do
11
- expect { described_class.new({ foo: "bar" }) }.to_not raise_error
12
+ expect { described_class.new({ foo: "bar" }) }.not_to raise_error
12
13
  end
13
14
 
14
15
 
@@ -111,7 +112,7 @@ describe Whois::Client do
111
112
  client = described_class.new(timeout: 5)
112
113
  expect {
113
114
  client.lookup("example.test")
114
- }.to_not raise_error
115
+ }.not_to raise_error
115
116
  end
116
117
 
117
118
  it "supports unlimited timeout" do
@@ -125,9 +126,8 @@ describe Whois::Client do
125
126
  client = described_class.new.tap { |c| c.timeout = nil }
126
127
  expect {
127
128
  client.lookup("example.test")
128
- }.to_not raise_error
129
+ }.not_to raise_error
129
130
  end
130
-
131
131
  end
132
132
 
133
133
  # FIXME: use RSpec metadata
@@ -135,10 +135,9 @@ describe Whois::Client do
135
135
  describe "#query" do
136
136
  it "sends a query for given domain" do
137
137
  record = described_class.new.lookup("weppos.it")
138
- assert record.match?(/Domain:\s+weppos\.it/)
139
- assert record.match?(/Created:/)
138
+ expect(record.match?(/Domain:\s+weppos\.it/)).to be(true)
139
+ expect(record.match?(/Created:/)).to be(true)
140
140
  end
141
141
  end
142
142
  end
143
-
144
143
  end
@@ -1,20 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Record::Part do
4
-
5
6
  describe "#initialize" do
6
7
  it "accepts an empty value" do
7
8
  expect {
8
9
  instance = described_class.new
9
10
  expect(instance.body).to be_nil
10
- }.to_not raise_error
11
+ }.not_to raise_error
11
12
  end
12
13
 
13
14
  it "accepts an empty hash" do
14
15
  expect {
15
16
  instance = described_class.new({})
16
17
  expect(instance.body).to be_nil
17
- }.to_not raise_error
18
+ }.not_to raise_error
18
19
  end
19
20
 
20
21
  it "initializes a new instance from given hash" do
@@ -34,5 +35,4 @@ describe Whois::Record::Part do
34
35
  expect(instance.host).to eq("whois.example.test")
35
36
  end
36
37
  end
37
-
38
38
  end
@@ -1,16 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Record do
4
-
5
6
  subject { described_class.new(server, parts) }
6
7
 
7
8
  let(:server) {
8
9
  Whois::Server.factory(:tld, ".foo", "whois.example.test")
9
10
  }
10
- let(:parts) {[
11
- Whois::Record::Part.new(body: "This is a record from foo.", host: "foo.example.test"),
12
- Whois::Record::Part.new(body: "This is a record from bar.", host: "bar.example.test")
13
- ]}
11
+ let(:parts) {
12
+ [
13
+ Whois::Record::Part.new(body: "This is a record from foo.", host: "foo.example.test"),
14
+ Whois::Record::Part.new(body: "This is a record from bar.", host: "bar.example.test"),
15
+ ]
16
+ }
14
17
  let(:content) {
15
18
  parts.map(&:body).join("\n")
16
19
  }
@@ -20,7 +23,7 @@ describe Whois::Record do
20
23
  it "requires a server and parts" do
21
24
  expect { described_class.new }.to raise_error(ArgumentError)
22
25
  expect { described_class.new(server) }.to raise_error(ArgumentError)
23
- expect { described_class.new(server, parts) }.to_not raise_error
26
+ expect { described_class.new(server, parts) }.not_to raise_error
24
27
  end
25
28
 
26
29
  it "sets server and parts from arguments" do
@@ -135,8 +138,8 @@ describe Whois::Record do
135
138
 
136
139
  describe "#match?" do
137
140
  it "calls match and checks for match" do
138
- expect(subject.match?(/record/)).to eq(true)
139
- expect(subject.match?(/nomatch/)).to eq(false)
141
+ expect(subject.match?(/record/)).to be(true)
142
+ expect(subject.match?(/nomatch/)).to be(false)
140
143
  end
141
144
  end
142
145
 
@@ -154,5 +157,4 @@ describe Whois::Record do
154
157
  expect(described_class.new(nil, []).content).to eq("")
155
158
  end
156
159
  end
157
-
158
160
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Afilias do
4
-
5
6
  let(:definition) { [:tld, ".test", "whois.afilias-grs.info", {}] }
6
7
  let(:server) { described_class.new(*definition) }
7
8
 
@@ -24,7 +25,7 @@ describe Whois::Server::Adapters::Afilias do
24
25
  it "follows all referrals" do
25
26
  referral = File.read(fixture("referrals/afilias.bz.txt"))
26
27
  response = "Match for example.test."
27
- expected = referral + "\n" + response
28
+ expected = "#{referral}\n#{response}"
28
29
  expect(server.query_handler).to receive(:call).with("example.test", "whois.afilias-grs.info", 43).and_return(referral)
29
30
  expect(server.query_handler).to receive(:call).with("example.test", "whois.belizenic.bz", 43).and_return(response)
30
31
 
@@ -38,12 +39,11 @@ describe Whois::Server::Adapters::Afilias do
38
39
  referral = File.read(fixture("referrals/afilias.bz.txt"))
39
40
  server.options[:referral] = false
40
41
  expect(server.query_handler).to receive(:call).with("example.test", "whois.afilias-grs.info", 43).and_return(referral)
41
- expect(server.query_handler).to receive(:call).with("example.test", "whois.belizenic.bz", 43).never
42
+ expect(server.query_handler).not_to receive(:call).with("example.test", "whois.belizenic.bz", 43)
42
43
 
43
44
  record = server.lookup("example.test")
44
45
  expect(record.parts.size).to eq(1)
45
46
  end
46
47
  end
47
48
  end
48
-
49
49
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Arin do
4
-
5
6
  let(:definition) { [:ipv4, "0.0.0.0/1", "whois.arin.net"] }
6
7
  let(:server) { described_class.new(*definition) }
7
8
 
@@ -22,7 +23,7 @@ describe Whois::Server::Adapters::Arin do
22
23
  it "follows whois:// referrals" do
23
24
  referral = File.read(fixture("referrals/arin_referral_whois.txt"))
24
25
  response = "Whois Response"
25
- expected = referral + "\n" + response
26
+ expected = "#{referral}\n#{response}"
26
27
  expect(server.query_handler).to receive(:call).with("n + 0.0.0.0", "whois.arin.net", 43).and_return(referral)
27
28
  expect(server.query_handler).to receive(:call).with("0.0.0.0", "whois.ripe.net", 43).and_return(response)
28
29
 
@@ -30,13 +31,13 @@ describe Whois::Server::Adapters::Arin do
30
31
  expect(record.to_s).to eq(expected)
31
32
  expect(record.parts.size).to eq(2)
32
33
  expect(record.parts).to eq([Whois::Record::Part.new(body: referral, host: "whois.arin.net"),
33
- Whois::Record::Part.new(body: response, host: "whois.ripe.net")])
34
+ Whois::Record::Part.new(body: response, host: "whois.ripe.net"),])
34
35
  end
35
36
 
36
37
  it "follows rwhois:// referrals" do
37
38
  referral = File.read(fixture("referrals/arin_referral_rwhois.txt"))
38
39
  response = "Whois Response"
39
- expected = referral + "\n" + response
40
+ expected = "#{referral}\n#{response}"
40
41
  expect(server.query_handler).to receive(:call).with("n + 0.0.0.0", "whois.arin.net", 43).and_return(referral)
41
42
  expect(server.query_handler).to receive(:call).with("0.0.0.0", "rwhois.servernap.net", 4321).and_return(response)
42
43
 
@@ -44,14 +45,14 @@ describe Whois::Server::Adapters::Arin do
44
45
  expect(record.to_s).to eq(expected)
45
46
  expect(record.parts.size).to eq(2)
46
47
  expect(record.parts).to eq([Whois::Record::Part.new(body: referral, host: "whois.arin.net"),
47
- Whois::Record::Part.new(body: response, host: "rwhois.servernap.net")])
48
+ Whois::Record::Part.new(body: response, host: "rwhois.servernap.net"),])
48
49
  end
49
50
 
50
51
  it "ignores referral if options[:referral] is false" do
51
52
  referral = File.read(fixture("referrals/arin_referral_whois.txt"))
52
53
  server.options[:referral] = false
53
54
  expect(server.query_handler).to receive(:call).with("n + 0.0.0.0", "whois.arin.net", 43).and_return(referral)
54
- expect(server.query_handler).to receive(:call).with("0.0.0.0", "whois.ripe.net", 43).never
55
+ expect(server.query_handler).not_to receive(:call).with("0.0.0.0", "whois.ripe.net", 43)
55
56
 
56
57
  record = server.lookup("0.0.0.0")
57
58
  expect(record.parts.size).to eq(1)
@@ -60,7 +61,7 @@ describe Whois::Server::Adapters::Arin do
60
61
  it "ignores referral (gracefully) if missing" do
61
62
  referral = File.read(fixture("referrals/arin_referral_missing.txt"))
62
63
  expect(server.query_handler).to receive(:call).with("n + 0.0.0.0", "whois.arin.net", 43).and_return(referral)
63
- expect(server.query_handler).to receive(:call).never
64
+ expect(server.query_handler).not_to receive(:call)
64
65
 
65
66
  record = server.lookup("0.0.0.0")
66
67
  expect(record.parts.size).to eq(1)
@@ -75,10 +76,8 @@ describe Whois::Server::Adapters::Arin do
75
76
  record = server.lookup("0.0.0.0")
76
77
  expect(record.parts.size).to eq(2)
77
78
  expect(record.parts).to eq([Whois::Record::Part.new(body: referral, host: "whois.arin.net"),
78
- Whois::Record::Part.new(body: response, host: "whois.apnic.net")])
79
+ Whois::Record::Part.new(body: response, host: "whois.apnic.net"),])
79
80
  end
80
81
  end
81
-
82
82
  end
83
-
84
83
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'whois/server/adapters/arin'
3
5
 
4
6
  describe Whois::Server::Adapters::Arpa do
5
-
6
7
  let(:definition) { [:tld, ".in-addr.arpa", nil, {}] }
7
8
 
8
9
  describe "#lookup" do
@@ -16,5 +17,4 @@ describe Whois::Server::Adapters::Arpa do
16
17
  expect(record.parts).to eq([Whois::Record::Part.new(body: response, host: "whois.arin.net")])
17
18
  end
18
19
  end
19
-
20
20
  end
@@ -1,19 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Base do
4
-
5
- let(:definition) { [:tld, ".test", "whois.test", { foo: "bar" }] }
6
+ let(:definition) { [:tld, ".test", "whois.test", { foo: "bar" }] }
6
7
 
7
8
 
8
9
  describe "#initialize" do
9
10
  it "requires type, allocation, and host parameters" do
10
11
  expect { described_class.new(:tld) }.to raise_error(ArgumentError)
11
12
  expect { described_class.new(:tld, ".test") }.to raise_error(ArgumentError)
12
- expect { described_class.new(:tld, ".test", "whois.test") }.to_not raise_error
13
+ expect { described_class.new(:tld, ".test", "whois.test") }.not_to raise_error
13
14
  end
14
15
 
15
16
  it "accepts an options parameter" do
16
- expect { described_class.new(:tld, ".test", "whois.test", { foo: "bar" }) }.to_not raise_error
17
+ expect { described_class.new(:tld, ".test", "whois.test", { foo: "bar" }) }.not_to raise_error
17
18
  end
18
19
 
19
20
  it "sets instance variables from arguments" do
@@ -78,22 +79,22 @@ describe Whois::Server::Adapters::Base do
78
79
 
79
80
  describe "#configure" do
80
81
  it "merges settings with current options" do
81
- a = described_class.new(:tld, ".test", "whois.test", { :hello => "world" })
82
+ a = described_class.new(:tld, ".test", "whois.test", { hello: "world" })
82
83
  a.configure(foo: "bar")
83
- expect(a.options).to eq({ :hello => "world", foo: "bar" })
84
+ expect(a.options).to eq({ hello: "world", foo: "bar" })
84
85
  end
85
86
 
86
87
  it "gives higher priority to settings argument" do
87
88
  a = described_class.new(:tld, ".test", "whois.test", { foo: "bar" })
88
89
  expect(a.options).to eq({ foo: "bar" })
89
- a.configure(:foo => "baz")
90
- expect(a.options).to eq({ :foo => "baz" })
90
+ a.configure(foo: "baz")
91
+ expect(a.options).to eq({ foo: "baz" })
91
92
  end
92
93
 
93
94
  it "overrides @host if :host option exists" do
94
- a = described_class.new(:tld, ".test", "whois.test", { :hello => "world" })
95
+ a = described_class.new(:tld, ".test", "whois.test", { hello: "world" })
95
96
  a.configure(foo: "bar", host: "whois.example.com")
96
- expect(a.options).to eq({ :hello => "world", foo: "bar", host: "whois.example.com" })
97
+ expect(a.options).to eq({ hello: "world", foo: "bar", host: "whois.example.com" })
97
98
  expect(a.host).to eq("whois.example.com")
98
99
  end
99
100
  end
@@ -127,7 +128,7 @@ describe Whois::Server::Adapters::Base do
127
128
  end
128
129
 
129
130
  context "with :bind_host and :bind_port options" do
130
- let(:server) { described_class.new(:tld, ".test", "whois.test", { :bind_host => "192.168.1.1", :bind_port => 3000 }) }
131
+ let(:server) { described_class.new(:tld, ".test", "whois.test", { bind_host: "192.168.1.1", bind_port: 3000 }) }
131
132
 
132
133
  it "binds the WHOIS query to given host and port" do
133
134
  expect(described_class.query_handler).to receive(:call).with("example.test", "whois.test", 43, "192.168.1.1", 3000)
@@ -137,7 +138,7 @@ describe Whois::Server::Adapters::Base do
137
138
  end
138
139
 
139
140
  context "with :bind_port and without :bind_host options" do
140
- let(:server) { described_class.new(:tld, ".test", "whois.test", { :bind_port => 3000 }) }
141
+ let(:server) { described_class.new(:tld, ".test", "whois.test", { bind_port: 3000 }) }
141
142
 
142
143
  it "binds the WHOIS query to given port and defaults host" do
143
144
  expect(described_class.query_handler).to receive(:call).with("example.test", "whois.test", 43, described_class::DEFAULT_BIND_HOST, 3000)
@@ -146,5 +147,4 @@ describe Whois::Server::Adapters::Base do
146
147
  end
147
148
  end
148
149
  end
149
-
150
150
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Formatted do
4
-
5
- let(:definition) { [:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s" }] }
6
+ let(:definition) { [:tld, ".de", "whois.denic.de", { format: "-T dn,ace -C US-ASCII %s" }] }
6
7
 
7
8
 
8
9
  describe "#lookup" do
@@ -19,8 +20,8 @@ describe Whois::Server::Adapters::Formatted do
19
20
 
20
21
  context "without format option" do
21
22
  it "raises an error" do
22
- server = described_class.new(*[:tld, ".de", "whois.denic.de", {}])
23
- expect(server.query_handler).to receive(:call).never
23
+ server = described_class.new(:tld, ".de", "whois.denic.de", {})
24
+ expect(server.query_handler).not_to receive(:call)
24
25
 
25
26
  expect {
26
27
  server.lookup("domain.de")
@@ -31,7 +32,7 @@ describe Whois::Server::Adapters::Formatted do
31
32
  context "with port option" do
32
33
  it "sends the request to given port" do
33
34
  response = "Whois Response"
34
- server = described_class.new(:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s", :port => 20 })
35
+ server = described_class.new(:tld, ".de", "whois.denic.de", { format: "-T dn,ace -C US-ASCII %s", port: 20 })
35
36
  expect(server.query_handler).to receive(:call).with("-T dn,ace -C US-ASCII domain.de", "whois.denic.de", 20).and_return(response)
36
37
 
37
38
  server.lookup("domain.de")
@@ -41,13 +42,12 @@ describe Whois::Server::Adapters::Formatted do
41
42
  context "with bind option" do
42
43
  it "binds the request to given host and port" do
43
44
  response = "Whois Response"
44
- server = described_class.new(:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s" })
45
- server.configure(:bind_host => "192.168.1.1", :bind_port => 3000)
45
+ server = described_class.new(:tld, ".de", "whois.denic.de", { format: "-T dn,ace -C US-ASCII %s" })
46
+ server.configure(bind_host: "192.168.1.1", bind_port: 3000)
46
47
  expect(server.query_handler).to receive(:call).with("-T dn,ace -C US-ASCII domain.de", "whois.denic.de", 43, "192.168.1.1", 3000).and_return(response)
47
48
 
48
49
  server.lookup("domain.de")
49
50
  end
50
51
  end
51
52
  end
52
-
53
53
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::None do
4
-
5
6
  describe "#lookup" do
6
7
  it "raises Whois::NoInterfaceError" do
7
8
  expect {
@@ -19,5 +20,4 @@ describe Whois::Server::Adapters::None do
19
20
  }.to raise_error(Whois::NoInterfaceError, /ipv4/)
20
21
  end
21
22
  end
22
-
23
23
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::NotImplemented do
4
-
5
- before(:each) do
6
- @definition = [:ipv6, "2001:0000::/32", "teredo", { :adapter => Whois::Server::Adapters::NotImplemented }]
6
+ before do
7
+ @definition = [:ipv6, "2001:0000::/32", "teredo", { adapter: Whois::Server::Adapters::NotImplemented }]
7
8
  end
8
9
 
9
10
 
@@ -20,5 +21,4 @@ describe Whois::Server::Adapters::NotImplemented do
20
21
  }.to raise_error(Whois::ServerNotImplemented, /teredo/)
21
22
  end
22
23
  end
23
-
24
24
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Standard do
4
-
5
6
  let(:definition) { [:tld, ".test", "whois.test", {}] }
6
7
 
7
8
 
@@ -20,7 +21,7 @@ describe Whois::Server::Adapters::Standard do
20
21
  context "with port option" do
21
22
  it "sends the request to given port" do
22
23
  response = "Whois Response"
23
- server = described_class.new(:tld, ".test", "whois.test", { :port => 20 })
24
+ server = described_class.new(:tld, ".test", "whois.test", { port: 20 })
24
25
  expect(server.query_handler).to receive(:call).with("domain.test", "whois.test", 20).and_return(response)
25
26
 
26
27
  server.lookup("domain.test")
@@ -30,13 +31,12 @@ describe Whois::Server::Adapters::Standard do
30
31
  context "with bind option" do
31
32
  it "binds the request to given host and port" do
32
33
  response = "Whois Response"
33
- server = described_class.new(:tld, ".test", "whois.test", { :port => 20 })
34
- server.configure(:bind_host => "192.168.1.100", :bind_port => 3000)
34
+ server = described_class.new(:tld, ".test", "whois.test", { port: 20 })
35
+ server.configure(bind_host: "192.168.1.100", bind_port: 3000)
35
36
  expect(server.query_handler).to receive(:call).with("domain.test", "whois.test", 20, "192.168.1.100", 3000).and_return(response)
36
37
 
37
38
  server.lookup("domain.test")
38
39
  end
39
40
  end
40
41
  end
41
-
42
42
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Verisign do
4
-
5
6
  let(:definition) { [:tld, ".test", "whois.test", {}] }
6
7
  let(:server) { described_class.new(*definition) }
7
8
 
@@ -24,7 +25,7 @@ describe Whois::Server::Adapters::Verisign do
24
25
  it "follows all referrals" do
25
26
  referral = File.read(fixture("referrals/crsnic.com.txt"))
26
27
  response = "Match for example.test."
27
- expected = referral + "\n" + response
28
+ expected = "#{referral}\n#{response}"
28
29
  expect(server.query_handler).to receive(:call).with("=example.test", "whois.test", 43).and_return(referral)
29
30
  expect(server.query_handler).to receive(:call).with("example.test", "whois.markmonitor.com", 43).and_return(response)
30
31
 
@@ -38,7 +39,7 @@ describe Whois::Server::Adapters::Verisign do
38
39
  referral = File.read(fixture("referrals/crsnic.com.txt"))
39
40
  server.options[:referral] = false
40
41
  expect(server.query_handler).to receive(:call).with("=example.test", "whois.test", 43).and_return(referral)
41
- expect(server.query_handler).to receive(:call).never
42
+ expect(server.query_handler).not_to receive(:call)
42
43
 
43
44
  record = server.lookup("example.test")
44
45
  expect(record.parts.size).to eq(1)
@@ -49,12 +50,11 @@ describe Whois::Server::Adapters::Verisign do
49
50
  it "ignores referral (gracefully) if missing" do
50
51
  referral = File.read(fixture("referrals/crsnic.com_referral_missing.txt"))
51
52
  expect(server.query_handler).to receive(:call).with("=example.test", "whois.test", 43).and_return(referral)
52
- expect(server.query_handler).to receive(:call).never
53
+ expect(server.query_handler).not_to receive(:call)
53
54
 
54
55
  record = server.lookup("example.test")
55
56
  expect(record.parts.size).to eq(1)
56
57
  end
57
58
  end
58
59
  end
59
-
60
60
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Web do
4
-
5
- before(:each) do
6
- @definition = [:tld, ".test", nil, { :url => "http://whois.test" }]
6
+ before do
7
+ @definition = [:tld, ".test", nil, { url: "http://whois.test" }]
7
8
  end
8
9
 
9
10
 
@@ -20,5 +21,4 @@ describe Whois::Server::Adapters::Web do
20
21
  }.to raise_error(Whois::WebInterfaceError, /whois\.test/)
21
22
  end
22
23
  end
23
-
24
24
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'whois/server/socket_handler'
3
5
 
4
6
  describe Whois::Server::SocketHandler do
5
-
6
7
  describe "#call" do
7
- [ Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE, SocketError ].each do |error|
8
+ [Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE, SocketError].each do |error|
8
9
  it "re-raises #{error} as Whois::ConnectionError" do
9
10
  expect(subject).to receive(:execute).and_raise(error)
10
11
  expect {
@@ -13,15 +14,16 @@ describe Whois::Server::SocketHandler do
13
14
  end
14
15
 
15
16
  it "executes a socket connection for given args" do
16
- socket = double("Handler")
17
+ socket = instance_double(TCPSocket)
17
18
  expect(socket).to receive(:write).with("example.test\r\n")
18
19
  expect(socket).to receive(:read)
19
20
  expect(socket).to receive(:close)
20
21
 
21
- expect(TCPSocket).to receive(:new).with("whois.test", 43).and_return(socket)
22
+ expect(TCPSocket).to receive(:new)
23
+ .with("whois.test", 43)
24
+ .and_return(socket)
22
25
  subject.call("example.test", "whois.test", 43)
23
26
  end
24
27
  end
25
28
  end
26
-
27
29
  end