require 'rails_helper' RSpec.describe 'EPP domain:delete' do let(:request_xml) { <<-XML test.com dGVzdCBmYWlsCg== 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 sign_in_to_epp_area end context 'when domain is not discarded' do let!(:domain) { create(:domain, name: 'test.com') } it 'returns epp code of 1001' do post '/epp/command/delete', frame: request_xml expect(response_code).to eq('1001'), "Expected EPP code of 1001, got #{response_code} (#{response_description})" end end context 'when domain is discarded' do let!(:domain) { create(:domain_discarded, name: 'test.com') } it 'returns epp code of 2105' do post '/epp/command/delete', frame: request_xml expect(response_code).to eq('2105'), "Expected EPP code of 2105, got #{response_code} (#{response_description})" end end end