mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Add xml output for epp_request in specs
This commit is contained in:
parent
4615e99527
commit
d95224cf9c
3 changed files with 44 additions and 2 deletions
|
@ -22,6 +22,12 @@ if Rails.env.test? || Rails.env.development?
|
||||||
t.rspec_opts = '--tag ~feature'
|
t.rspec_opts = '--tag ~feature'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc 'Generate EPP doc from specs'
|
||||||
|
RSpec::Core::RakeTask.new('test:epp_doc') do |t|
|
||||||
|
ENV['EPP_DOC'] = 'true'
|
||||||
|
t.rspec_opts = '--tag epp --require support/epp_doc.rb --format EppDoc'
|
||||||
|
end
|
||||||
|
|
||||||
Rake::Task[:default].prerequisites.clear
|
Rake::Task[:default].prerequisites.clear
|
||||||
task default: :test
|
task default: :test
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,16 @@ module Epp
|
||||||
server = server_zone
|
server = server_zone
|
||||||
server = server_elkdata if args.include?(:elkdata)
|
server = server_elkdata if args.include?(:elkdata)
|
||||||
|
|
||||||
return parse_response(server.request(data)) if args.include?(:xml)
|
res = parse_response(server.request(data)) if args.include?(:xml)
|
||||||
return parse_response(server.request(read_body(data)))
|
if res
|
||||||
|
log(data, res[:parsed])
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
|
res = parse_response(server.request(read_body(data)))
|
||||||
|
log(data, res[:parsed])
|
||||||
|
return res
|
||||||
|
|
||||||
rescue => e
|
rescue => e
|
||||||
e
|
e
|
||||||
end
|
end
|
||||||
|
@ -202,6 +210,12 @@ module Epp
|
||||||
xml_params = defaults.deep_merge(xml_params)
|
xml_params = defaults.deep_merge(xml_params)
|
||||||
EppXml::Domain.transfer(xml_params, op)
|
EppXml::Domain.transfer(xml_params, op)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def log(req, res)
|
||||||
|
return unless ENV['EPP_DOC']
|
||||||
|
puts "\nREQUEST: #{Nokogiri(req)}\n"
|
||||||
|
puts "RESPONSE: #{res}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
|
|
22
spec/support/epp_doc.rb
Normal file
22
spec/support/epp_doc.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
class EppDoc
|
||||||
|
RSpec::Core::Formatters.register self, :example_started, :example_passed, :example_failed
|
||||||
|
|
||||||
|
def initialize(output)
|
||||||
|
@output = output
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_started(notification)
|
||||||
|
desc = notification.example.full_description
|
||||||
|
@output.puts '-' * desc.length
|
||||||
|
@output.puts desc
|
||||||
|
@output.puts '-' * desc.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_passed(_example)
|
||||||
|
@output << "\n\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_failed(_example)
|
||||||
|
@output << "\n\n"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue