internetee-registry/spec/support/matchers/epp/code.rb
2017-06-26 02:14:08 +03:00

39 lines
744 B
Ruby

module Matchers
module EPP
class Code
def initialize(expected)
@expected = expected
end
def matches?(response)
@xml = response.body
actual == expected
end
def failure_message
"Expected EPP code of #{expected}, got #{actual} (#{code_description})"
end
def description
"should have EPP code of #{expected}"
end
private
attr_reader :xml
attr_reader :expected
def actual
xml_document.xpath('//xmlns:result').first['code'].to_i
end
def code_description
xml_document.css('result msg').text
end
def xml_document
@xml_document ||= Nokogiri::XML(xml)
end
end
end
end