rspec-dns 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +14 -6
- data/.travis.yml +7 -0
- data/LICENSE +1 -0
- data/README.md +51 -10
- data/Rakefile +10 -0
- data/lib/rspec-dns/have_dns.rb +81 -31
- data/rspec-dns.gemspec +5 -4
- data/spec/rspec-dns/have_dns_spec.rb +121 -0
- data/spec/spec_helper.rb +4 -0
- metadata +33 -12
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,15 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 2 | 
            +
            !binary "U0hBMQ==":
         | 
| 3 | 
            +
              metadata.gz: !binary |-
         | 
| 4 | 
            +
                ZjA1MGNlM2VlOWQ3N2M4OWI1MDMwN2ViNjc1ZmRhNDk0NTQ2NTBjNg==
         | 
| 5 | 
            +
              data.tar.gz: !binary |-
         | 
| 6 | 
            +
                YjAxNjUxYjEzZjM3YTg1YjA1MWVhMjdiMTM2NmU0ZjYzYmZhNDY2Yg==
         | 
| 7 | 
            +
            !binary "U0hBNTEy":
         | 
| 8 | 
            +
              metadata.gz: !binary |-
         | 
| 9 | 
            +
                OTA4ZWNlMWEwNTFmNWE1NWI0Nzk3NWIyYmI0MWIyNzlhNWRiNGJiZTQzZjA4
         | 
| 10 | 
            +
                NmNjZDljOWUxOThkMDliNzYwNTIyZTQwMWFkY2EzNTlmNDhmYzZhZGFiZmIy
         | 
| 11 | 
            +
                YWY5MTUzMzNmMTg3Mzk0ZjUxY2Q4Mzk4MzQ4NmUzN2Y1MDRkYzA=
         | 
| 12 | 
            +
              data.tar.gz: !binary |-
         | 
| 13 | 
            +
                NTFlMDk5YTJiNTAwMDQ5ZTkwNzYxNmU4N2FiYjc0MjI4NDI5ZjY4Zjc3YTcy
         | 
| 14 | 
            +
                NjAxY2IxNmVkZjM1YzUxM2FiYzUzZGRjMjhjOWQ4M2Q5YmU5OGQzNDA1Nzkx
         | 
| 15 | 
            +
                MDYwYTJkZmY1ZTMxYzFkY2QzYjM4YzdjNDEzYThiNTkzNzJkZmU=
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/LICENSE
    CHANGED
    
    | @@ -188,6 +188,7 @@ APPENDIX: How to apply the Apache License to your work. | |
| 188 188 |  | 
| 189 189 | 
             
            Copyright 2012-2013 Seth Vargo
         | 
| 190 190 | 
             
            Copyright 2012-2013 CustomInk, LLC
         | 
| 191 | 
            +
            Copyright 2013-2014 Spotify AB
         | 
| 191 192 |  | 
| 192 193 | 
             
            Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 193 194 | 
             
            you may not use this file except in compliance with the License.
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,6 +1,9 @@ | |
| 1 1 | 
             
            rspec-dns
         | 
| 2 2 | 
             
            =========
         | 
| 3 | 
            -
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            [](https://travis-ci.org/spotify/rspec-dns)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            rspec-dns is an rspec plugin for easy DNS testing. It uses dnsruby instead of the standard library for the name resolution.
         | 
| 4 7 |  | 
| 5 8 | 
             
            Installation
         | 
| 6 9 | 
             
            ------------
         | 
| @@ -42,13 +45,38 @@ Or group all your DNS tests into a single file or context: | |
| 42 45 | 
             
            require 'spec_helper'
         | 
| 43 46 |  | 
| 44 47 | 
             
            describe 'DNS tests' do
         | 
| 45 | 
            -
              ' | 
| 46 | 
            -
             | 
| 48 | 
            +
              it 'passes some tests' do
         | 
| 49 | 
            +
                'www.example.com'.should have_dns.with_type('TXT').and_ttl(300).and_data('a=b')
         | 
| 50 | 
            +
                'www.example.com'.should have_dns.with_type('A').and_ttl(300).and_address('1.2.3.4')
         | 
| 51 | 
            +
              end
         | 
| 47 52 | 
             
            end
         | 
| 48 53 | 
             
            ```
         | 
| 49 54 |  | 
| 50 55 | 
             
            ### Chain Methods
         | 
| 51 | 
            -
             | 
| 56 | 
            +
             | 
| 57 | 
            +
            Currently the following chaining methods are supported:
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            - at\_least
         | 
| 60 | 
            +
            - in\_authority
         | 
| 61 | 
            +
            - refuse\_request
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            Here's some usage examples:
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            ```ruby
         | 
| 66 | 
            +
              it 'checks if recursion is disabled' do
         | 
| 67 | 
            +
                'google.com'.should have_dns.refuse_request
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              it 'checks if gslb subdomain is delegated to dynect' do
         | 
| 71 | 
            +
                'gslb.example.com'.should have_dns.in_authority.with_type('NS').and_name(/dynect/).at_least(3)
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              it 'checks number of hosts in round robin' do
         | 
| 75 | 
            +
                'example.com'.should have_dns.with_type('A').at_least(3)
         | 
| 76 | 
            +
              end
         | 
| 77 | 
            +
            ```
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            The other method chains are actually [Dnsruby](http://dnsruby.rubyforge.org/classes/Dnsruby/RR.html) 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.
         | 
| 52 80 |  | 
| 53 81 | 
             
            Depending on the type of record, the following attributes may be available:
         | 
| 54 82 |  | 
| @@ -56,6 +84,7 @@ Depending on the type of record, the following attributes may be available: | |
| 56 84 | 
             
            - bitmap
         | 
| 57 85 | 
             
            - cpu
         | 
| 58 86 | 
             
            - data
         | 
| 87 | 
            +
            - domainname
         | 
| 59 88 | 
             
            - emailbx
         | 
| 60 89 | 
             
            - exchange
         | 
| 61 90 | 
             
            - expire
         | 
| @@ -81,8 +110,7 @@ If you try checking an attribute on a record that is non-existent (like checking | |
| 81 110 |  | 
| 82 111 | 
             
            ```text
         | 
| 83 112 | 
             
            Failure/Error: it { should have_dns.with_type('TXT').and_ftl(300).and_data('a=b') }
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                   undefined method `rmailbx' for #<Resolv::DNS::Resource::IN::A:0x007fb56302ed90>
         | 
| 113 | 
            +
              got 1 exception(s): undefined method `rmailbx' for #<Dnsruby::RR::IN::A:0x007f66a0339b00>
         | 
| 86 114 | 
             
            ```
         | 
| 87 115 |  | 
| 88 116 | 
             
            For this reason, you should always check the `type` attribute first in your chain.
         | 
| @@ -101,7 +129,19 @@ nameserver: | |
| 101 129 |  | 
| 102 130 | 
             
            If this file is missing Resolv will use the settings in /etc/resolv.conf.
         | 
| 103 131 |  | 
| 104 | 
            -
             | 
| 132 | 
            +
            The full list of configuration options can be found on the [Dnsruby docs](http://dnsruby.rubyforge.org/classes/Dnsruby/Config.html).
         | 
| 133 | 
            +
             | 
| 134 | 
            +
            ### Configuring connection timeout
         | 
| 135 | 
            +
             | 
| 136 | 
            +
            Connection timeout is to stop waiting for resolver.
         | 
| 137 | 
            +
            If you want to wait over default timeout `1`,
         | 
| 138 | 
            +
            you can change the timeout in spec files or spec_helpers like this:
         | 
| 139 | 
            +
             | 
| 140 | 
            +
            ```ruby
         | 
| 141 | 
            +
            RSpec.configuration.rspec_dns_connection_timeout = 5
         | 
| 142 | 
            +
            ```
         | 
| 143 | 
            +
             | 
| 144 | 
            +
            alternatively you can specify it in the `config/dns.yml` file:
         | 
| 105 145 |  | 
| 106 146 | 
             
            ```yaml
         | 
| 107 147 | 
             
            nameserver:
         | 
| @@ -110,8 +150,6 @@ nameserver: | |
| 110 150 | 
             
            timeouts: 3
         | 
| 111 151 | 
             
            ```
         | 
| 112 152 |  | 
| 113 | 
            -
            The full list of configuration options can be found on the [Resolv docs](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/resolv/rdoc/index.html).
         | 
| 114 | 
            -
             | 
| 115 153 | 
             
            Contributing
         | 
| 116 154 | 
             
            ------------
         | 
| 117 155 | 
             
            1. Fork the project on github
         | 
| @@ -120,11 +158,14 @@ Contributing | |
| 120 158 |  | 
| 121 159 | 
             
            License & Authors
         | 
| 122 160 | 
             
            -----------------
         | 
| 123 | 
            -
            -  | 
| 161 | 
            +
            - Seth Vargo (sethvargo@gmail.com)
         | 
| 162 | 
            +
            - Johannes Russek (jrussek@spotify.com)
         | 
| 163 | 
            +
            - Alexey Lapitsky (lex@realisticgroup.com)
         | 
| 124 164 |  | 
| 125 165 | 
             
            ```text
         | 
| 126 166 | 
             
            Copyright 2012-2013 Seth Vargo
         | 
| 127 167 | 
             
            Copyright 2012-2013 CustomInk, LLC
         | 
| 168 | 
            +
            Copyright 2013-2014 Spotify AB
         | 
| 128 169 |  | 
| 129 170 | 
             
            Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 130 171 | 
             
            you may not use this file except in compliance with the License.
         | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/rspec-dns/have_dns.rb
    CHANGED
    
    | @@ -1,37 +1,85 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            RSpec.configure do |c|
         | 
| 2 | 
            +
              c.add_setting :rspec_dns_connection_timeout, :default => 1
         | 
| 3 | 
            +
            end
         | 
| 2 4 |  | 
| 3 5 | 
             
            RSpec::Matchers.define :have_dns do
         | 
| 4 6 | 
             
              match do |dns|
         | 
| 5 7 | 
             
                @dns = dns
         | 
| 8 | 
            +
                @exceptions = []
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                if @authority
         | 
| 11 | 
            +
                  @records = _records.authority
         | 
| 12 | 
            +
                else
         | 
| 13 | 
            +
                  @records = _records.answer
         | 
| 14 | 
            +
                end
         | 
| 6 15 |  | 
| 7 | 
            -
                 | 
| 8 | 
            -
                  _options.all? do |option, value|
         | 
| 9 | 
            -
                     | 
| 10 | 
            -
             | 
| 11 | 
            -
                      record.class.name.split('::').last == value.to_s
         | 
| 12 | 
            -
                    else
         | 
| 16 | 
            +
                results = @records.find_all do |record|
         | 
| 17 | 
            +
                  matched = _options.all? do |option, value|
         | 
| 18 | 
            +
                    begin
         | 
| 19 | 
            +
                      # To distinguish types because not all Resolv returns have type
         | 
| 13 20 | 
             
                      if value.is_a? String
         | 
| 14 21 | 
             
                        record.send(option).to_s == value
         | 
| 22 | 
            +
                      elsif value.is_a? Regexp
         | 
| 23 | 
            +
                        record.send(option).to_s =~ value
         | 
| 15 24 | 
             
                      else
         | 
| 16 25 | 
             
                        record.send(option) == value
         | 
| 17 26 | 
             
                      end
         | 
| 27 | 
            +
                    rescue Exception => e
         | 
| 28 | 
            +
                      @exceptions << e.message
         | 
| 29 | 
            +
                      false
         | 
| 18 30 | 
             
                    end
         | 
| 19 31 | 
             
                  end
         | 
| 32 | 
            +
                  matched
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                @number_matched = results.count
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                fail_with('exceptions') if !@exceptions.empty?
         | 
| 38 | 
            +
                if @refuse_request
         | 
| 39 | 
            +
                  @refuse_request_received
         | 
| 40 | 
            +
                else
         | 
| 41 | 
            +
                  @number_matched >= (@at_least ? @at_least : 1)
         | 
| 20 42 | 
             
                end
         | 
| 21 43 | 
             
              end
         | 
| 22 44 |  | 
| 23 45 | 
             
              failure_message_for_should do |actual|
         | 
| 24 | 
            -
                 | 
| 46 | 
            +
                if !@exceptions.empty?
         | 
| 47 | 
            +
                  "tried to look up #{actual} but got #{@exceptions.size} exception(s): #{@exceptions.join(", ")}"
         | 
| 48 | 
            +
                elsif @refuse_request
         | 
| 49 | 
            +
                  "expected #{actual} to have request refused"
         | 
| 50 | 
            +
                elsif @at_least
         | 
| 51 | 
            +
                  "expected #{actual} to have: #{@at_least} records of #{_pretty_print_options}, but found #{@number_matched}. Other records were: #{_pretty_print_records}"
         | 
| 52 | 
            +
                else
         | 
| 53 | 
            +
                  "expected #{actual} to have: #{_pretty_print_options}, but did not. other records were: #{_pretty_print_records}"
         | 
| 54 | 
            +
                end
         | 
| 25 55 | 
             
              end
         | 
| 26 56 |  | 
| 27 57 | 
             
              failure_message_for_should_not do |actual|
         | 
| 28 | 
            -
                 | 
| 58 | 
            +
                if !@exceptions.empty?
         | 
| 59 | 
            +
                  "got #{@exceptions.size} exception(s):\n#{@exceptions.join("\n")}"
         | 
| 60 | 
            +
                elsif @refuse_request
         | 
| 61 | 
            +
                  "expected #{actual} not to be refused"
         | 
| 62 | 
            +
                else
         | 
| 63 | 
            +
                  "expected #{actual} not to have #{_pretty_print_options}, but it did. the records were: #{_pretty_print_records}"
         | 
| 64 | 
            +
                end
         | 
| 29 65 | 
             
              end
         | 
| 30 66 |  | 
| 31 | 
            -
              description | 
| 67 | 
            +
              def description
         | 
| 32 68 | 
             
                "have the correct dns entries with #{_options}"
         | 
| 33 69 | 
             
              end
         | 
| 34 70 |  | 
| 71 | 
            +
              chain :in_authority do
         | 
| 72 | 
            +
                @authority = true
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
              chain :at_least do |actual|
         | 
| 76 | 
            +
                @at_least = actual
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              chain :refuse_request do
         | 
| 80 | 
            +
                @refuse_request = true
         | 
| 81 | 
            +
              end
         | 
| 82 | 
            +
             | 
| 35 83 | 
             
              def method_missing(m, *args, &block)
         | 
| 36 84 | 
             
                if m.to_s =~ /(and\_with|and|with)?\_(.*)$/
         | 
| 37 85 | 
             
                  _options[$2.to_sym] = args.first
         | 
| @@ -44,7 +92,7 @@ RSpec::Matchers.define :have_dns do | |
| 44 92 | 
             
              def _config
         | 
| 45 93 | 
             
                @config ||= if File.exists?(_config_file)
         | 
| 46 94 | 
             
                  require 'yaml'
         | 
| 47 | 
            -
                   | 
| 95 | 
            +
                  _symbolize_keys(YAML::load(ERB.new(File.read(_config_file) ).result))
         | 
| 48 96 | 
             
                else
         | 
| 49 97 | 
             
                  nil
         | 
| 50 98 | 
             
                end
         | 
| @@ -73,32 +121,34 @@ RSpec::Matchers.define :have_dns do | |
| 73 121 | 
             
                @_options ||= {}
         | 
| 74 122 | 
             
              end
         | 
| 75 123 |  | 
| 76 | 
            -
              def _pretty_print_options
         | 
| 77 | 
            -
                "\n  (#{_options.sort.collect{ |k,v| "#{k}:#{v.inspect}" }.join(', ')})\n"
         | 
| 78 | 
            -
              end
         | 
| 79 | 
            -
             | 
| 80 124 | 
             
              def _records
         | 
| 81 125 | 
             
                @_records ||= begin
         | 
| 82 | 
            -
                   | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
                     | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
                   | 
| 126 | 
            +
                  config = _config || {}
         | 
| 127 | 
            +
                  # Backwards compatible config option for rspec-dnsruby
         | 
| 128 | 
            +
                  query_timeout = config[:timeouts] || RSpec.configuration.rspec_dns_connection_timeout
         | 
| 129 | 
            +
                  Timeout::timeout(query_timeout + 0.2) do
         | 
| 130 | 
            +
                    resolver =  Dnsruby::Resolver.new(config)
         | 
| 131 | 
            +
                    resolver.query_timeout = query_timeout
         | 
| 132 | 
            +
                    resolver.query(@dns, Dnsruby::Types.ANY)
         | 
| 133 | 
            +
                  end
         | 
| 134 | 
            +
                rescue Exception => e
         | 
| 135 | 
            +
                  if Dnsruby::NXDomain === e
         | 
| 136 | 
            +
                    @exceptions << "Have not received any records"
         | 
| 137 | 
            +
                  elsif Dnsruby::Refused === e && @refuse_request
         | 
| 138 | 
            +
                    @refuse_request_received = true
         | 
| 139 | 
            +
                  else
         | 
| 140 | 
            +
                    @exceptions << e.message
         | 
| 141 | 
            +
                  end
         | 
| 142 | 
            +
                  Dnsruby::Message.new
         | 
| 92 143 | 
             
                end
         | 
| 93 144 | 
             
              end
         | 
| 94 145 |  | 
| 95 | 
            -
              def  | 
| 96 | 
            -
                "\n | 
| 146 | 
            +
              def _pretty_print_options
         | 
| 147 | 
            +
                "\n  (#{_options.sort.map { |k, v| "#{k}:#{v.inspect}" }.join(', ')})\n"
         | 
| 97 148 | 
             
              end
         | 
| 98 149 |  | 
| 99 | 
            -
              def  | 
| 100 | 
            -
                 | 
| 101 | 
            -
                  "#{method}:#{record.send(method.to_sym).to_s.inspect}" if record.respond_to?(method.to_sym)
         | 
| 102 | 
            -
                end.compact.join(', ') + ')'
         | 
| 150 | 
            +
              def _pretty_print_records
         | 
| 151 | 
            +
                "\n" + @records.map { |r| r.to_s }.join("\n")
         | 
| 103 152 | 
             
              end
         | 
| 153 | 
            +
             | 
| 104 154 | 
             
            end
         | 
    
        data/rspec-dns.gemspec
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            Gem::Specification.new do |s|
         | 
| 2 | 
            -
              s.version       = '0.0 | 
| 2 | 
            +
              s.version       = '0.1.0'
         | 
| 3 3 | 
             
              s.name          = 'rspec-dns'
         | 
| 4 | 
            -
              s. | 
| 5 | 
            -
              s.email         = ' | 
| 4 | 
            +
              s.authors       = ['Seth Vargo', 'Alexey Lapitsky', 'Johannes Russek']
         | 
| 5 | 
            +
              s.email         = 'alexey@spotify.com'
         | 
| 6 6 | 
             
              s.description   = 'Easily test your DNS entries with RSpec'
         | 
| 7 7 | 
             
              s.summary       = 'rspec-dns provides an easy-to-use DSL for testing your DNS records are responding as they should.'
         | 
| 8 | 
            -
              s.homepage      = 'https://github.com/ | 
| 8 | 
            +
              s.homepage      = 'https://github.com/spotify/rspec-dns'
         | 
| 9 9 | 
             
              s.license       = 'Apache 2.0'
         | 
| 10 10 |  | 
| 11 11 | 
             
              s.files         = `git ls-files`.split($\)
         | 
| @@ -15,4 +15,5 @@ Gem::Specification.new do |s| | |
| 15 15 |  | 
| 16 16 | 
             
              s.add_dependency 'rake'
         | 
| 17 17 | 
             
              s.add_dependency 'rspec', '>= 2.9'
         | 
| 18 | 
            +
              s.add_dependency 'dnsruby', '~> 1.54'
         | 
| 18 19 | 
             
            end
         | 
| @@ -0,0 +1,121 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'dnsruby'
         | 
| 3 | 
            +
            require 'resolv'
         | 
| 4 | 
            +
            require_relative '../../lib/rspec-dns'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            def stub_records(strings)
         | 
| 7 | 
            +
              records = strings.map { |s| Dnsruby::RR.new_from_string(s) }
         | 
| 8 | 
            +
              resolver = Dnsruby::Resolver.new
         | 
| 9 | 
            +
              Dnsruby::Resolver.stub(:new) do
         | 
| 10 | 
            +
                yield if block_given?
         | 
| 11 | 
            +
                resolver
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
              resolver.stub_chain(:query, :answer).and_return(records)
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            describe 'rspec-dns matchers' do
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              describe '#have_dns' do
         | 
| 19 | 
            +
                context 'with a sigle record' do
         | 
| 20 | 
            +
                  it 'can evalutate an A record' do
         | 
| 21 | 
            +
                    stub_records(['example.com 86400 A 192.168.100.100'])
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    'example.com'.should have_dns.with_type('A')
         | 
| 24 | 
            +
                    'example.com'.should_not have_dns.with_type('TXT')
         | 
| 25 | 
            +
                    'example.com'.should have_dns.with_type('A').and_address(Resolv::IPv4.create('192.168.100.100'))
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  it 'can evalutate a AAAA record' do
         | 
| 29 | 
            +
                    stub_records(['example.com 86400 AAAA 2001:0002:6c::430'])
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    'example.com'.should have_dns.with_type('AAAA')
         | 
| 32 | 
            +
                    'example.com'.should_not have_dns.with_type('A')
         | 
| 33 | 
            +
                    'example.com'.should have_dns.with_type('AAAA')
         | 
| 34 | 
            +
                      .and_address(Resolv::IPv6.create('2001:0002:6c::430'))
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  it 'can evalutate a CNAME record' do
         | 
| 38 | 
            +
                    stub_records(['www.example.com 300 IN CNAME example.com'])
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                    'example.com'.should have_dns.with_type('CNAME')
         | 
| 41 | 
            +
                    'example.com'.should_not have_dns.with_type('AAAA')
         | 
| 42 | 
            +
                    'example.com'.should have_dns.with_type('CNAME').and_name('www.example.com')
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  it 'can evalutate an MX record' do
         | 
| 46 | 
            +
                    stub_records(['example.com. 7200 MX 40 mail.example.com.'])
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    'example.com'.should have_dns.with_type('MX')
         | 
| 49 | 
            +
                    'example.com'.should_not have_dns.with_type('CNAME')
         | 
| 50 | 
            +
                    'example.com'.should have_dns.with_type('MX').and_preference(40)
         | 
| 51 | 
            +
                    'example.com'.should have_dns.with_type('MX')
         | 
| 52 | 
            +
                      .and_preference(40).and_exchange('mail.example.com')
         | 
| 53 | 
            +
                    'example.com'.should_not have_dns.with_type('MX')
         | 
| 54 | 
            +
                      .and_preference(30).and_exchange('mail.example.com')
         | 
| 55 | 
            +
                    'example.com'.should_not have_dns.with_type('MX')
         | 
| 56 | 
            +
                      .and_preference(40).and_exchange('example.com')
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  it 'can evalutate an NS record' do
         | 
| 60 | 
            +
                    stub_records(['sub.example.com. 300 IN NS ns.sub.example.com.'])
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    'example.com'.should have_dns.with_type('NS')
         | 
| 63 | 
            +
                    'example.com'.should_not have_dns.with_type('MX')
         | 
| 64 | 
            +
                    'example.com'.should have_dns.with_type('NS').and_domainname('ns.sub.example.com')
         | 
| 65 | 
            +
                    'example.com'.should_not have_dns.with_type('NS').and_domainname('sub.example.com')
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                  it 'can evalutate a PTR record' do
         | 
| 69 | 
            +
                    stub_records(['ptrs.example.com. 300 IN PTR ptr.example.com.'])
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                    '192.168.100.100'.should have_dns.with_type('PTR')
         | 
| 72 | 
            +
                    '192.168.100.100'.should_not have_dns.with_type('MX')
         | 
| 73 | 
            +
                    '192.168.100.100'.should have_dns.with_type('PTR').and_domainname('ptr.example.com')
         | 
| 74 | 
            +
                    '192.168.100.100'.should_not have_dns.with_type('PTR').and_domainname('ptrs.example.com')
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  it 'can evalutate an SOA record' do
         | 
| 78 | 
            +
                    stub_records(['example.com 210 IN SOA ns.example.com a.example.com. 2014030712 60 25 3628800 900'])
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                    'example.com'.should have_dns.with_type('SOA')
         | 
| 81 | 
            +
                    'example.com'.should_not have_dns.with_type('PTR')
         | 
| 82 | 
            +
                    'example.com'.should have_dns.with_type('SOA')
         | 
| 83 | 
            +
                      .and_mname('ns.example.com')
         | 
| 84 | 
            +
                      .and_rname('a.example.com')
         | 
| 85 | 
            +
                      .and_serial('2014030712')
         | 
| 86 | 
            +
                      .and_refresh(60)
         | 
| 87 | 
            +
                      .and_retry(25)
         | 
| 88 | 
            +
                      .and_expire(3628800)
         | 
| 89 | 
            +
                      .and_minimum(900)
         | 
| 90 | 
            +
                    'example.com'.should_not have_dns.with_type('SOA')
         | 
| 91 | 
            +
                      .and_mname('nstest.example.com')
         | 
| 92 | 
            +
                  end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                  it 'can evalutate a TXT record' do
         | 
| 95 | 
            +
                    stub_records(['example.com. 300 IN TXT "v=spf1 a:example.com ~all"'])
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                    'example.com'.should have_dns.with_type('TXT')
         | 
| 98 | 
            +
                    'example.com'.should_not have_dns.with_type('SOA')
         | 
| 99 | 
            +
                    'example.com'.should have_dns.with_type('TXT').and_data('v=spf1 a:example.com ~all')
         | 
| 100 | 
            +
                    'example.com'.should_not have_dns.with_type('TXT').and_data('v=spf2 a:example.com ~all')
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                context 'with changable connection timeout' do
         | 
| 105 | 
            +
                  it 'should timeout within 3 seconds in default' do
         | 
| 106 | 
            +
                    stub_records(['example.com 86400 A 192.168.100.100']) do
         | 
| 107 | 
            +
                      sleep 3
         | 
| 108 | 
            +
                    end
         | 
| 109 | 
            +
                    'example.com'.should_not have_dns.with_type('A')
         | 
| 110 | 
            +
                  end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                  it 'should not timeout within 3 seconds when timeout is 5' do
         | 
| 113 | 
            +
                    RSpec.configuration.rspec_dns_connection_timeout = 5
         | 
| 114 | 
            +
                    stub_records(['example.com 86400 A 192.168.100.100']) do
         | 
| 115 | 
            +
                      sleep 3
         | 
| 116 | 
            +
                    end
         | 
| 117 | 
            +
                    'example.com'.should have_dns.with_type('A')
         | 
| 118 | 
            +
                  end
         | 
| 119 | 
            +
                end
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,51 +1,68 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rspec-dns
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0 | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Seth Vargo
         | 
| 8 | 
            +
            - Alexey Lapitsky
         | 
| 9 | 
            +
            - Johannes Russek
         | 
| 8 10 | 
             
            autorequire: 
         | 
| 9 11 | 
             
            bindir: bin
         | 
| 10 12 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 13 | 
            +
            date: 2014-03-19 00:00:00.000000000 Z
         | 
| 12 14 | 
             
            dependencies:
         | 
| 13 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 16 | 
             
              name: rake
         | 
| 15 17 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 18 | 
             
                requirements:
         | 
| 17 | 
            -
                - - '>='
         | 
| 19 | 
            +
                - - ! '>='
         | 
| 18 20 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 21 | 
             
                    version: '0'
         | 
| 20 22 | 
             
              type: :runtime
         | 
| 21 23 | 
             
              prerelease: false
         | 
| 22 24 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 25 | 
             
                requirements:
         | 
| 24 | 
            -
                - - '>='
         | 
| 26 | 
            +
                - - ! '>='
         | 
| 25 27 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 28 | 
             
                    version: '0'
         | 
| 27 29 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 30 | 
             
              name: rspec
         | 
| 29 31 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 32 | 
             
                requirements:
         | 
| 31 | 
            -
                - - '>='
         | 
| 33 | 
            +
                - - ! '>='
         | 
| 32 34 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 35 | 
             
                    version: '2.9'
         | 
| 34 36 | 
             
              type: :runtime
         | 
| 35 37 | 
             
              prerelease: false
         | 
| 36 38 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 39 | 
             
                requirements:
         | 
| 38 | 
            -
                - - '>='
         | 
| 40 | 
            +
                - - ! '>='
         | 
| 39 41 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 42 | 
             
                    version: '2.9'
         | 
| 43 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 44 | 
            +
              name: dnsruby
         | 
| 45 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 46 | 
            +
                requirements:
         | 
| 47 | 
            +
                - - ~>
         | 
| 48 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            +
                    version: '1.54'
         | 
| 50 | 
            +
              type: :runtime
         | 
| 51 | 
            +
              prerelease: false
         | 
| 52 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 53 | 
            +
                requirements:
         | 
| 54 | 
            +
                - - ~>
         | 
| 55 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 56 | 
            +
                    version: '1.54'
         | 
| 41 57 | 
             
            description: Easily test your DNS entries with RSpec
         | 
| 42 | 
            -
            email:  | 
| 58 | 
            +
            email: alexey@spotify.com
         | 
| 43 59 | 
             
            executables: []
         | 
| 44 60 | 
             
            extensions: []
         | 
| 45 61 | 
             
            extra_rdoc_files: []
         | 
| 46 62 | 
             
            files:
         | 
| 47 63 | 
             
            - .gitignore
         | 
| 48 64 | 
             
            - .rvmrc
         | 
| 65 | 
            +
            - .travis.yml
         | 
| 49 66 | 
             
            - Gemfile
         | 
| 50 67 | 
             
            - LICENSE
         | 
| 51 68 | 
             
            - README.md
         | 
| @@ -53,7 +70,9 @@ files: | |
| 53 70 | 
             
            - lib/rspec-dns.rb
         | 
| 54 71 | 
             
            - lib/rspec-dns/have_dns.rb
         | 
| 55 72 | 
             
            - rspec-dns.gemspec
         | 
| 56 | 
            -
             | 
| 73 | 
            +
            - spec/rspec-dns/have_dns_spec.rb
         | 
| 74 | 
            +
            - spec/spec_helper.rb
         | 
| 75 | 
            +
            homepage: https://github.com/spotify/rspec-dns
         | 
| 57 76 | 
             
            licenses:
         | 
| 58 77 | 
             
            - Apache 2.0
         | 
| 59 78 | 
             
            metadata: {}
         | 
| @@ -63,20 +82,22 @@ require_paths: | |
| 63 82 | 
             
            - lib
         | 
| 64 83 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 65 84 | 
             
              requirements:
         | 
| 66 | 
            -
              - - '>='
         | 
| 85 | 
            +
              - - ! '>='
         | 
| 67 86 | 
             
                - !ruby/object:Gem::Version
         | 
| 68 87 | 
             
                  version: '0'
         | 
| 69 88 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 70 89 | 
             
              requirements:
         | 
| 71 | 
            -
              - - '>='
         | 
| 90 | 
            +
              - - ! '>='
         | 
| 72 91 | 
             
                - !ruby/object:Gem::Version
         | 
| 73 92 | 
             
                  version: '0'
         | 
| 74 93 | 
             
            requirements: []
         | 
| 75 94 | 
             
            rubyforge_project: 
         | 
| 76 | 
            -
            rubygems_version: 2. | 
| 95 | 
            +
            rubygems_version: 2.0.3
         | 
| 77 96 | 
             
            signing_key: 
         | 
| 78 97 | 
             
            specification_version: 4
         | 
| 79 98 | 
             
            summary: rspec-dns provides an easy-to-use DSL for testing your DNS records are responding
         | 
| 80 99 | 
             
              as they should.
         | 
| 81 | 
            -
            test_files: | 
| 100 | 
            +
            test_files:
         | 
| 101 | 
            +
            - spec/rspec-dns/have_dns_spec.rb
         | 
| 102 | 
            +
            - spec/spec_helper.rb
         | 
| 82 103 | 
             
            has_rdoc: 
         |