spec/lib/epp-eis/nsset_spec.rb in epp-eis-1.0.1 vs spec/lib/epp-eis/nsset_spec.rb in epp-eis-1.0.2
- old
+ new
@@ -5,83 +5,150 @@
before(:each) do
@server = Epp::Server.new(:server => '127.0.0.1', :tag => 'username', :password => 'password')
end
describe 'check_nsset' do
-
- context 'when response is successful' do
-
- before(:each) do
- @server.stub(:send_request).and_return(xml_mock('responses/nsset/check_nsset_1000.xml'))
+ before(:each) do
+ @server.should_receive(:send_request) do |xml|
+ @request = Nokogiri::XML(xml)
+ xml_mock('responses/nsset/check_nsset_1000.xml')
end
+ end
+
+ context 'request' do
+ it 'contains nsset id' do
+ @server.check_nsset('NSSID:TEST:1')
+ expect(@request.css('nsset|check nsset|id', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('NSSID:TEST:1')
+ end
+ end
+ context 'response' do
it 'has status code 1000' do
- @server.check_nsset('NSSID:TEST:1').code.should == 1000
+ expect(@server.check_nsset('NSSID:TEST:1').code).to eq(1000)
end
context 'when multiple nsset names are provided' do
it 'has multiple nsset check items in response object' do
- @server.check_nsset('NSSID:TEST:1', 'NSSID:TEST:2').items.size.should == 2
+ expect(@server.check_nsset('NSSID:TEST:1', 'NSSID:TEST:2').items.size).to eq(2)
end
end
end
end
describe 'create_nsset' do
- context 'when response is successful' do
- before(:each) do
- @server.stub(:send_request).and_return(xml_mock('responses/nsset/create_nsset_1000.xml'))
- @response = @server.create_nsset('NSSID:TEST:2', [['test.com', '123.123.123.123'], ['ns2.test.com', '111.111.111.111']], 'test1')
+ before(:each) do
+ @server.should_receive(:send_request) do |xml|
+ @request = Nokogiri::XML(xml)
+ xml_mock('responses/nsset/create_nsset_1000.xml')
end
-
+ @response = @server.create_nsset('NSSID:TEST:2', [['test.com', '123.123.123.123'], ['ns2.test.com', '111.111.111.111']], 'test1')
+ end
+
+ context 'request' do
+ it 'contains nsset id' do
+ expect(@request.css('nsset|create nsset|id', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('NSSID:TEST:2')
+ end
+
+ it 'contains nameserver names' do
+ expect(@request.css('nsset|create nsset|ns nsset|name', 'nsset' => Epp::Eis::XML_NS_NSSET).collect{ |n| n.text }).to include('test.com', 'ns2.test.com')
+ end
+
+ it 'contains nameserver ip addresses' do
+ expect(@request.css('nsset|create nsset|ns nsset|addr', 'nsset' => Epp::Eis::XML_NS_NSSET).collect{ |n| n.text }).to include('123.123.123.123', '111.111.111.111')
+ end
+
+ it 'contains technical contact' do
+ expect(@request.css('nsset|create nsset|tech', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('test1')
+ end
+ end
+
+ context 'response' do
it 'returns nsset id' do
- @response.nsset_id.should == 'NSSID:TEST:2'
+ expect(@response.nsset_id).to eq('NSSID:TEST:2')
end
it 'returns nsset create date' do
- @response.nsset_create_date.should == '2010-02-08T16:27:22+02:00'
+ expect(@response.nsset_create_date).to eq('2010-02-08T16:27:22+02:00')
end
end
end
describe 'info_nsset' do
- context 'when response is successful' do
- before(:each) do
- @server.stub(:send_request).and_return(xml_mock('responses/nsset/info_nsset_1000.xml'))
- @response = @server.info_nsset('NSSID:TEST:2')
+ before(:each) do
+ @server.should_receive(:send_request) do |xml|
+ @request = Nokogiri::XML(xml)
+ xml_mock('responses/nsset/info_nsset_1000.xml')
end
-
+ @response = @server.info_nsset('NSSID:TEST:2')
+ end
+
+ context 'request' do
+ it 'contains nsset id' do
+ expect(@request.css('nsset|info nsset|id', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('NSSID:TEST:2')
+ end
+ end
+
+ context 'response' do
it 'returns nsset id' do
- @response.nsset_id.should == 'NSSID:TEST:2'
+ expect(@response.nsset_id).to eq('NSSID:TEST:2')
end
it 'returns roid' do
- @response.nsset_roid.should == 'N0000000051-EPP'
+ expect(@response.nsset_roid).to eq('N0000000051-EPP')
end
it 'returns status' do
- @response.nsset_status.should == 'ok'
+ expect(@response.nsset_status).to eq('ok')
end
it 'returns nameservers' do
- @response.nameservers.should == [['test.com', '123.123.123.123'], ['ns2.test.com', '111.111.111.111']]
+ expect(@response.nameservers).to eq([['test.com', '123.123.123.123'], ['ns2.test.com', '111.111.111.111']])
end
end
end
describe 'update_nsset' do
- context 'when response is successful' do
- before(:each) do
- @server.stub(:send_request).and_return(xml_mock('responses/nsset/update_nsset_1000.xml'))
- @response = @server.update_nsset('NSSID:TEST:2', [['ns3.test.com', '112.112.112.112']], 'margustech1', 'ns2.test.com', 'tech1')
+ before(:each) do
+ @server.should_receive(:send_request) do |xml|
+ @request = Nokogiri::XML(xml)
+ xml_mock('responses/nsset/update_nsset_1000.xml')
end
-
+ @response = @server.update_nsset('NSSID:TEST:2', [['ns3.test.com', '112.112.112.112']], 'margustech1', 'ns2.test.com', 'tech1')
+ end
+
+ context 'request' do
+ it 'contains nsset id' do
+ expect(@request.css('nsset|update nsset|id', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('NSSID:TEST:2')
+ end
+
+ it 'contains nameserver names to be added' do
+ expect(@request.css('nsset|update nsset|add nsset|ns nsset|name', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('ns3.test.com')
+ end
+
+ it 'contains nameserver ip addresses to be added' do
+ expect(@request.css('nsset|update nsset|add nsset|ns nsset|addr', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('112.112.112.112')
+ end
+
+ it 'contains tech contact to be added' do
+ expect(@request.css('nsset|update nsset|add nsset|tech', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('margustech1')
+ end
+
+ it 'contains nameserver to be removed' do
+ expect(@request.css('nsset|update nsset|rem nsset|name', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('ns2.test.com')
+ end
+
+ it 'contains tech contact to be removed' do
+ expect(@request.css('nsset|update nsset|rem nsset|tech', 'nsset' => Epp::Eis::XML_NS_NSSET).text).to eq('tech1')
+ end
+ end
+
+ context 'response' do
it 'returns response code' do
- @response.code.should == 1000
+ expect(@response.code).to eq(1000)
end
it 'returns response message' do
- @response.message.should == 'Command completed successfully'
+ expect(@response.message).to eq('Command completed successfully')
end
end
end
end