Commit 6003b3f2 authored by Colin Shea's avatar Colin Shea

add record? helper for conditions in zones

parent 37ea71b6
......@@ -197,6 +197,12 @@ class Zone
push :txt, "@", ttl, text: text
end
def record?(type, name)
return @zonefile.records[type].any? do |record|
record[:name] == name
end
end
protected
# evaluates a file
......
......@@ -191,4 +191,16 @@ describe Zone do
subject.zonefile.spf[0][:text].must_equal "v=spf1 include:_spf.google.com include:acmeemailmarketing.com ~all"
end
end
describe "record? helper" do
it "should return true for existing records" do
subject.cname 'www', "other-server."
assert subject.record?(:cname, 'www')
end
it "should return false for missing records" do
subject.cname 'blog', "other-server."
refute subject.record?(:cname, 'www')
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment