rspec-dns 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +0 -1
- data/Gemfile +1 -1
- data/README.md +6 -0
- data/lib/rspec-dns/have_dns.rb +6 -0
- data/rspec-dns.gemspec +1 -1
- data/spec/rspec-dns/have_dns_spec.rb +19 -3
- data/spec/spec_helper.rb +2 -2
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZmE3YmFlOWVlYjM3ZWFhMDc5NGI0NmI4ZmFjODVlYzA2Yzk5ODIwZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e6188ddbf09f62ebb6ab252bbd881a6d471f0ed
|
4
|
+
data.tar.gz: 0c510ca61771ab1c2b18d2c68594056358802311
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NzQ0YjRlMDYzZGZhYjI1YTU4ZTA3MTRmNjY3YTY0OTljOGQxMmRjNDQxOGQy
|
11
|
-
ZjgzMTU3OGQxYzg4ZTFlYzU1MGVlMDQ0NzUzNzRlMzQ5NTQ2MTA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjQ0NTc3YjQ4MWU4N2RmMzFlYzJkYzdiYmQwZmRkODk1ZjgxZjFmYzU3ZjFm
|
14
|
-
YmQ2MDQ5ZjIyMDVmYTAzYjYyYzE3YWZlMjhjOGFhYTgzZjBlNDg2OTI1YzMy
|
15
|
-
Yzc2YjEwZWRmNjY3ZTJiN2Y3NjdkNzA3NGNkZGEyNTU1N2Q1ZGM=
|
6
|
+
metadata.gz: 78ba4e13de20f10011ce5a372d18c3935acb058be7996369b3299651e964a9e4a2e9e70b61bfd4a806a9d971282b9f8c72463c00ca13ef39e889ea0547b1ead2
|
7
|
+
data.tar.gz: bd0fd445bf5d20367f111b9d2908b61a167913151e039548ef410df1acd14be59a36c099b01a858bed4d8cef0b57f08b13d43b0827a8b528e603d1cef609b045
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -64,6 +64,7 @@ Currently the following chaining methods are supported:
|
|
64
64
|
- refuse\_request
|
65
65
|
- config
|
66
66
|
- in\_zone\_file
|
67
|
+
- in\_additional
|
67
68
|
|
68
69
|
Here's some usage examples:
|
69
70
|
|
@@ -87,6 +88,11 @@ Here's some usage examples:
|
|
87
88
|
it 'checks zone file("example.zone") with specified origin("example.com.")' do
|
88
89
|
expect('example.com').to have_dns.with_type('A').in_zone_file('example.zone', 'example.com.')
|
89
90
|
end
|
91
|
+
|
92
|
+
it 'checks if "sub" subdomain is delegated to "ns.sub.example.com (192.0.2.5)",' do
|
93
|
+
expect('ns.sub.example.com').to have_dns.config(nameserver: 'ns.example.com', recurse: false)
|
94
|
+
.in_additional.with_type('A').and_address('192.0.2.5')
|
95
|
+
end
|
90
96
|
```
|
91
97
|
|
92
98
|
The other method chains are actually [Dnsruby](http://www.rubydoc.info/gems/dnsruby/Dnsruby/RR) attributes on the record. You can prefix them with `and_`, `with_`, `and_with` or whatever your heart desires. The predicate is what is checked. The rest is syntactic sugar.
|
data/lib/rspec-dns/have_dns.rb
CHANGED
@@ -9,6 +9,8 @@ RSpec::Matchers.define :have_dns do
|
|
9
9
|
|
10
10
|
if @authority
|
11
11
|
@records = _records.authority
|
12
|
+
elsif @additional
|
13
|
+
@records = _records.additional
|
12
14
|
else
|
13
15
|
@records = _records.answer
|
14
16
|
end
|
@@ -74,6 +76,10 @@ RSpec::Matchers.define :have_dns do
|
|
74
76
|
@authority = true
|
75
77
|
end
|
76
78
|
|
79
|
+
chain :in_additional do
|
80
|
+
@additional = true
|
81
|
+
end
|
82
|
+
|
77
83
|
chain :at_least do |actual|
|
78
84
|
@at_least = actual
|
79
85
|
end
|
data/rspec-dns.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
def stub_records(strings)
|
3
|
+
def stub_records(strings, section=:answer)
|
4
4
|
records = strings.map { |s| Dnsruby::RR.new_from_string(s) }
|
5
5
|
resolver = Dnsruby::Resolver.new
|
6
6
|
allow(Dnsruby::Resolver).to receive(:new) do
|
7
7
|
yield if block_given?
|
8
8
|
resolver
|
9
9
|
end
|
10
|
-
allow(resolver).to receive_message_chain(:query,
|
10
|
+
allow(resolver).to receive_message_chain(:query, section).and_return(records)
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'rspec-dns matchers' do
|
14
14
|
|
15
15
|
describe '#have_dns' do
|
16
|
-
context 'with a
|
16
|
+
context 'with a single record' do
|
17
17
|
it 'can evalutate an A record' do
|
18
18
|
stub_records(['example.com 86400 A 192.0.2.4'])
|
19
19
|
|
@@ -195,5 +195,21 @@ describe 'rspec-dns matchers' do
|
|
195
195
|
expect('example.com').to have_dns.with_type('A')
|
196
196
|
end
|
197
197
|
end
|
198
|
+
context 'with in_authority chain' do
|
199
|
+
it 'can evalutate an NS record' do
|
200
|
+
stub_records(['sub.example.com. 300 IN NS ns.sub.example.com.'], :authority)
|
201
|
+
|
202
|
+
expect('sub.example.com').to have_dns.with_type('NS').in_authority
|
203
|
+
expect('sub.example.com').to have_dns.with_type('NS').in_authority.and_domainname('ns.sub.example.com')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
context 'with in_additional chain' do
|
207
|
+
it 'can evalutate an A record' do
|
208
|
+
stub_records(['ns.sub.example.com. 86400 A 192.0.2.5'], :additional)
|
209
|
+
|
210
|
+
expect('ns.sub.example.com').to have_dns.in_additional.with_type('A')
|
211
|
+
expect('ns.sub.example.com').to have_dns.in_additional.with_type('A').and_address('192.0.2.5')
|
212
|
+
end
|
213
|
+
end
|
198
214
|
end
|
199
215
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-dns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
@@ -11,48 +11,48 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '2.9'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '2.9'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: dnsruby
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- - ~>
|
48
|
+
- - "~>"
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '1.54'
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- - ~>
|
55
|
+
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '1.54'
|
58
58
|
description: Easily test your DNS entries with RSpec
|
@@ -61,9 +61,9 @@ executables: []
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
-
- .gitignore
|
65
|
-
- .rvmrc
|
66
|
-
- .travis.yml
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rvmrc"
|
66
|
+
- ".travis.yml"
|
67
67
|
- Gemfile
|
68
68
|
- LICENSE
|
69
69
|
- README.md
|
@@ -85,12 +85,12 @@ require_paths:
|
|
85
85
|
- lib
|
86
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|