mirror of
https://github.com/internetee/registry.git
synced 2025-07-06 03:03:21 +02:00
parent
edf1e33260
commit
e31c68d43f
6 changed files with 56 additions and 18 deletions
35
spec/support/matchers/epp/code.rb
Normal file
35
spec/support/matchers/epp/code.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
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} (#{description})"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :xml
|
||||
attr_reader :expected
|
||||
|
||||
def actual
|
||||
xml_document.xpath('//xmlns:result').first['code'].to_i
|
||||
end
|
||||
|
||||
def description
|
||||
xml_document.css('result msg').text
|
||||
end
|
||||
|
||||
def xml_document
|
||||
@xml_document ||= Nokogiri::XML(xml)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue