From d747d92d2b549cc588b39bb18a42957d9291466c Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 14 Aug 2014 14:44:58 +0300 Subject: [PATCH] Refactor domain info request to builder --- spec/epp/epp_helper_spec.rb | 38 +++++++++++++++++++++++++++++++++++++ spec/support/epp.rb | 19 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb index e4da4c20e..39e027907 100644 --- a/spec/epp/epp_helper_spec.rb +++ b/spec/epp/epp_helper_spec.rb @@ -105,5 +105,43 @@ describe 'EPP Helper', epp: true do generated = Nokogiri::XML(xml).to_s.squish expect(generated).to eq(expected) end + + it 'creates valid info request' do + expected = Nokogiri::XML(' + + + + + example.ee + + + ABC-12345 + + + ').to_s.squish + + + generated = Nokogiri::XML(domain_info_xml).to_s.squish + expect(generated).to eq(expected) + + expected = Nokogiri::XML(' + + + + + one.ee + + + ABC-12345 + + + ').to_s.squish + + + generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub')).to_s.squish + expect(generated).to eq(expected) + end end end diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 58a2b3631..29b2d52f5 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -124,6 +124,25 @@ module Epp end end end + + def domain_info_xml(xml_params={}) + xml_params[:name_value] = xml_params[:name_value] || 'example.ee' + xml_params[:name_hosts] = xml_params[:name_hosts] || 'all' + + xml = Builder::XmlMarkup.new + + xml.instruct!(:xml, :standalone => 'no') + xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do + xml.command do + xml.info do + xml.tag!('domain:info', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do + xml.tag!('domain:name', xml_params[:name_value], 'hosts' => xml_params[:name_hosts]) if xml_params[:name] != false + end + end + xml.clTRID 'ABC-12345' + end + end + end end RSpec.configure do |c|