mirror of
https://github.com/internetee/registry.git
synced 2025-07-06 11:13:27 +02:00
parent
edf1e33260
commit
e31c68d43f
6 changed files with 56 additions and 18 deletions
|
@ -6,6 +6,7 @@ require 'capybara/poltergeist'
|
||||||
require 'paper_trail/frameworks/rspec'
|
require 'paper_trail/frameworks/rspec'
|
||||||
require 'money-rails/test_helpers'
|
require 'money-rails/test_helpers'
|
||||||
require 'support/requests/session_helpers'
|
require 'support/requests/session_helpers'
|
||||||
|
require 'support/requests/epp_helpers'
|
||||||
require 'support/features/session_helpers'
|
require 'support/features/session_helpers'
|
||||||
|
|
||||||
if ENV['ROBOT']
|
if ENV['ROBOT']
|
||||||
|
@ -15,6 +16,7 @@ end
|
||||||
|
|
||||||
require 'support/matchers/alias_attribute'
|
require 'support/matchers/alias_attribute'
|
||||||
require 'support/matchers/active_job'
|
require 'support/matchers/active_job'
|
||||||
|
require 'support/matchers/epp/code'
|
||||||
require 'support/capybara'
|
require 'support/capybara'
|
||||||
require 'support/factory_girl'
|
require 'support/factory_girl'
|
||||||
require 'support/database_cleaner'
|
require 'support/database_cleaner'
|
||||||
|
@ -30,6 +32,8 @@ RSpec.configure do |config|
|
||||||
config.include Features::SessionHelpers, type: :feature
|
config.include Features::SessionHelpers, type: :feature
|
||||||
config.include AbstractController::Translation, type: :feature
|
config.include AbstractController::Translation, type: :feature
|
||||||
|
|
||||||
|
config.include Requests::EPPHelpers, epp: true
|
||||||
|
|
||||||
config.define_derived_metadata(file_path: %r[/spec/features/]) do |metadata|
|
config.define_derived_metadata(file_path: %r[/spec/features/]) do |metadata|
|
||||||
metadata[:db] = true if metadata[:db].nil?
|
metadata[:db] = true if metadata[:db].nil?
|
||||||
end
|
end
|
||||||
|
@ -46,6 +50,10 @@ RSpec.configure do |config|
|
||||||
metadata[:db] = true if metadata[:db].nil?
|
metadata[:db] = true if metadata[:db].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.define_derived_metadata(file_path: %r[/spec/requests/epp/]) do |metadata|
|
||||||
|
metadata[:epp] = true if metadata[:epp].nil?
|
||||||
|
end
|
||||||
|
|
||||||
config.define_derived_metadata(file_path: %r[/spec/api/]) do |metadata|
|
config.define_derived_metadata(file_path: %r[/spec/api/]) do |metadata|
|
||||||
metadata[:type] = :request
|
metadata[:type] = :request
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,10 +20,6 @@ RSpec.describe 'EPP domain:delete' do
|
||||||
XML
|
XML
|
||||||
}
|
}
|
||||||
|
|
||||||
subject(:response_xml) { Nokogiri::XML(response.body) }
|
|
||||||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
|
||||||
subject(:response_description) { response_xml.css('result msg').text }
|
|
||||||
|
|
||||||
before :example do
|
before :example do
|
||||||
sign_in_to_epp_area
|
sign_in_to_epp_area
|
||||||
end
|
end
|
||||||
|
@ -33,7 +29,7 @@ RSpec.describe 'EPP domain:delete' do
|
||||||
|
|
||||||
it 'returns epp code of 1001' do
|
it 'returns epp code of 1001' do
|
||||||
post '/epp/command/delete', frame: request_xml
|
post '/epp/command/delete', frame: request_xml
|
||||||
expect(response_code).to eq('1001'), "Expected EPP code of 1001, got #{response_code} (#{response_description})"
|
expect(response).to have_code_of(1001)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,7 +38,7 @@ RSpec.describe 'EPP domain:delete' do
|
||||||
|
|
||||||
it 'returns epp code of 2105' do
|
it 'returns epp code of 2105' do
|
||||||
post '/epp/command/delete', frame: request_xml
|
post '/epp/command/delete', frame: request_xml
|
||||||
expect(response_code).to eq('2105'), "Expected EPP code of 2105, got #{response_code} (#{response_description})"
|
expect(response).to have_code_of(2105)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,10 +18,6 @@ RSpec.describe 'EPP domain:transfer' do
|
||||||
XML
|
XML
|
||||||
}
|
}
|
||||||
|
|
||||||
subject(:response_xml) { Nokogiri::XML(response.body) }
|
|
||||||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
|
||||||
subject(:response_description) { response_xml.css('result msg').text }
|
|
||||||
|
|
||||||
before :example do
|
before :example do
|
||||||
sign_in_to_epp_area
|
sign_in_to_epp_area
|
||||||
end
|
end
|
||||||
|
@ -31,7 +27,7 @@ RSpec.describe 'EPP domain:transfer' do
|
||||||
|
|
||||||
it 'returns epp code of 1000' do
|
it 'returns epp code of 1000' do
|
||||||
post '/epp/command/transfer', frame: request_xml
|
post '/epp/command/transfer', frame: request_xml
|
||||||
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
|
expect(response).to have_code_of(1000)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,7 +36,7 @@ RSpec.describe 'EPP domain:transfer' do
|
||||||
|
|
||||||
it 'returns epp code of 2105' do
|
it 'returns epp code of 2105' do
|
||||||
post '/epp/command/transfer', frame: request_xml
|
post '/epp/command/transfer', frame: request_xml
|
||||||
expect(response_code).to eq('2105'), "Expected EPP code of 2105, got #{response_code} (#{response_description})"
|
expect(response).to have_code_of(2105)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,10 +15,6 @@ RSpec.describe 'EPP domain:update' do
|
||||||
XML
|
XML
|
||||||
}
|
}
|
||||||
|
|
||||||
subject(:response_xml) { Nokogiri::XML(response.body) }
|
|
||||||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
|
||||||
subject(:response_description) { response_xml.css('result msg').text }
|
|
||||||
|
|
||||||
before :example do
|
before :example do
|
||||||
sign_in_to_epp_area
|
sign_in_to_epp_area
|
||||||
end
|
end
|
||||||
|
@ -28,7 +24,7 @@ RSpec.describe 'EPP domain:update' do
|
||||||
|
|
||||||
it 'returns epp code of 1000' do
|
it 'returns epp code of 1000' do
|
||||||
post '/epp/command/update', frame: request_xml
|
post '/epp/command/update', frame: request_xml
|
||||||
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
|
expect(response).to have_code_of(1000)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,7 +33,7 @@ RSpec.describe 'EPP domain:update' do
|
||||||
|
|
||||||
it 'returns epp code of 2105' do
|
it 'returns epp code of 2105' do
|
||||||
post '/epp/command/update', frame: request_xml
|
post '/epp/command/update', frame: request_xml
|
||||||
expect(response_code).to eq('2105'), "Expected EPP code of 2105, got #{response_code} (#{response_description})"
|
expect(response).to have_code_of(2105)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
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
|
7
spec/support/requests/epp_helpers.rb
Normal file
7
spec/support/requests/epp_helpers.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module Requests
|
||||||
|
module EPPHelpers
|
||||||
|
def have_code_of(*args)
|
||||||
|
Matchers::EPP::Code.new(*args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue