mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
commit
9565f23e68
50 changed files with 2463 additions and 323 deletions
37
spec/support/matchers/epp/have_result.rb
Normal file
37
spec/support/matchers/epp/have_result.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Matchers
|
||||
module EPP
|
||||
class HaveResultMatcher
|
||||
def initialize(expected)
|
||||
@expected = expected
|
||||
end
|
||||
|
||||
def matches?(target)
|
||||
@target = target
|
||||
|
||||
if @expected.message.present?
|
||||
@target.results.any? { |result| result.code == @expected.code && result.message == @expected.message }
|
||||
else
|
||||
@target.results.any? { |result| result.code == @expected.code }
|
||||
end
|
||||
end
|
||||
|
||||
def failure_message
|
||||
"expected #{@target.results} to have result #{@expected.inspect}"
|
||||
end
|
||||
|
||||
def failure_message_when_negated
|
||||
"expected #{@target.results} not to have result #{@expected.inspect}"
|
||||
end
|
||||
|
||||
def description
|
||||
"should have EPP code of #{@expected}"
|
||||
end
|
||||
end
|
||||
|
||||
def have_result(type, message = nil)
|
||||
code = ::EPP::Response::Result.codes.key(type)
|
||||
result = ::EPP::Response::Result.new(code, message)
|
||||
HaveResultMatcher.new(result)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,5 +7,9 @@ module Requests
|
|||
def valid_legal_document
|
||||
Base64.encode64('a' * 5000)
|
||||
end
|
||||
|
||||
def epp_response
|
||||
EPP::Response.from_xml(response.body)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue