spec/dineromail/notification_spec.rb in dineromail-0.0.4 vs spec/dineromail/notification_spec.rb in dineromail-0.1.0
- old
+ new
@@ -1,14 +1,25 @@
require 'spec_helper'
describe Dineromail::Notification do
it 'should load the notifications from the notification xml' do
- notification_xml = '<NOTIFICACION><TIPONOTIFICACION>1</TIPONOTIFICACION><OPERACIONES><OPERACION><TIPO>1</TIPO><ID>31548</ID></OPERACION><OPERACION><TIPO>1</TIPO><ID>XA5547</ID></OPERACION></OPERACIONES></NOTIFICACION>'
- notifications = Dineromail::Notification.from_xml(notification_xml)
+ notification_xml = File.read( 'spec/fixtures/notification.xml')
+ notifications = Dineromail::Notification.parse(notification_xml)
notifications.count.should == 2
- notifications.first.transaction_id.should == '31548'
- notifications.last.transaction_id.should == 'XA5547'
+ notifications.first.transaction_id.should == 1889
+ notifications.last.transaction_id.should == 5547
end
-
+ it 'should get automaticaly the status data associated with the notification' do
+ HTTParty.stub!(:get).and_return {
+ response = Object.new
+ response.stub!(:body).and_return(File.read( 'spec/fixtures/status_report.xml'))
+ response
+ }
+ notification_xml = File.read( 'spec/fixtures/notification.xml')
+ notifications = Dineromail::Notification.parse(notification_xml)
+ notification = notifications.first
+ notification.valid_report?.should be_true
+ notification.net_amount.should == 50.3
+ end
end