spec/rubydns/transaction_spec.rb in rubydns-0.9.3 vs spec/rubydns/transaction_spec.rb in rubydns-0.9.4

- old
+ new

@@ -1,6 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env rspec # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -28,20 +28,20 @@ IN = Resolv::DNS::Resource::IN describe RubyDNS::Transaction do let(:server) { RubyDNS::Server.new } let(:query) { RubyDNS::Message.new(0) } - let(:question) { Resolv::DNS::Name.create("www.google.com") } + let(:question) { Resolv::DNS::Name.create("www.google.com.") } let(:response) { RubyDNS::Message.new(0) } let(:resolver) { RubyDNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]])} it "should append an address" do transaction = RubyDNS::Transaction.new(server, query, question, IN::A, response) transaction.respond!("1.2.3.4") - expect(transaction.response.answer[0][0].to_s).to be == question.to_s + expect(transaction.response.answer[0][0]).to be == question expect(transaction.response.answer[0][2].address.to_s).to be == "1.2.3.4" end it "should passthrough the request" do transaction = RubyDNS::Transaction.new(server, query, question, IN::A, response) @@ -81,8 +81,58 @@ transaction = RubyDNS::Transaction.new(server, query, question, IN::A, response) transaction.fail! :NXDomain expect(transaction.response.rcode).to be Resolv::DNS::RCode::NXDomain + end + + it "should return AAAA record" do + transaction = RubyDNS::Transaction.new(server, query, question, IN::AAAA, response) + + expect(transaction.response.answer.size).to be 0 + + transaction.passthrough!(resolver) + + expect(transaction.response.answer.first[2]).to be_kind_of IN::AAAA + end + + it "should return MX record" do + transaction = RubyDNS::Transaction.new(server,query,"google.com",IN::MX, response) + + expect(transaction.response.answer.size).to be 0 + + transaction.passthrough!(resolver) + + expect(transaction.response.answer.first[2]).to be_kind_of IN::MX + end + + it "should return NS record" do + transaction = RubyDNS::Transaction.new(server, query, "google.com", IN::NS, response) + + expect(transaction.response.answer.size).to be 0 + + transaction.passthrough!(resolver) + + expect(transaction.response.answer.first[2]).to be_kind_of IN::NS + end + + it "should return PTR record" do + transaction = RubyDNS::Transaction.new(server, query, "8.8.8.8.in-addr.arpa", IN::PTR, response) + + expect(transaction.response.answer.size).to be 0 + + transaction.passthrough!(resolver) + + expect(transaction.response.answer.first[2]).to be_kind_of IN::PTR + end + + it "should return SOA record" do + transaction = RubyDNS::Transaction.new(server, query, "google.com", IN::SOA, response) + + expect(transaction.response.answer.size).to be 0 + + transaction.passthrough!(resolver) + + expect(transaction.response.answer.first[2]).to be_kind_of IN::SOA end end end