spec/unit/webmoney_spec.rb in webmoney-0.0.8 vs spec/unit/webmoney_spec.rb in webmoney-0.0.9
- old
+ new
@@ -18,11 +18,11 @@
t1.should match(/^\d{16}$/)
(t2 > t1).should be_true
end
it "should correct prepare interfaces urls" do
- wm = TestWM.new :wmid => WmConfig.wmid , :key => nil
+ wm = TestWM.new :wmid => WmConfig.first['wmid'], :key => nil
wm.should_not be_classic
wm.interfaces[:balance].class.should == URI::HTTPS
# converted to light-auth version
wm.interfaces[:balance].to_s.should == 'https://w3s.wmtransfer.com/asp/XMLPursesCert.asp'
# non-converted to light-auth version
@@ -109,10 +109,14 @@
it "should raise exception on non existent WMID" do
lambda {@wm.request(:get_passport, :wmid => '012345678901')}.should raise_error(Webmoney::NonExistentWmidError)
end
+ it "should create transaction" do
+ # TODO @wm.request( :create_transaction, ...)
+ end
+
it "should return correct BL" do
wmid = '370860915669'
@wm.request(:bussines_level, :wmid => wmid).should == 0
wmid = Webmoney::Wmid.new '000000000007'
@@ -159,8 +163,47 @@
# TODO @wm.request( :create_transaction, ...)
end
it "should raise error on undefined xml func" do
lambda { @wm.request(:unexistent_interface) }.should raise_error(::NoMethodError)
+ end
+
+ describe "invoice" do
+ before(:each) do
+ @wm = webmoney()
+ @ca = contragent()
+ # create invoice
+ @invoice = @ca.request(:create_invoice,
+ :orderid => 1,
+ :amount => 1,
+ :customerwmid => @wm.wmid,
+ :storepurse => WmConfig.second['wmz'],
+ :desc => "Test invoice",
+ :address => "Address"
+ )
+ end
+
+ it "should be created" do
+ @invoice[:retval].should == 0
+ @invoice[:state].should == 0
+ @invoice[:orderid].should == 1
+ @invoice[:ts].should > 0
+ @invoice[:id].should > 0
+ end
+
+ it "should be in state 0 (not paid)" do
+ res = @ca.request(:outgoing_invoices,
+ :purse => WmConfig.second['wmz'],
+ :wminvid => @invoice[:id],
+ :orderid => @invoice[:orderid],
+ :customerwmid => @wm.wmid,
+ :datestart => @invoice[:created_at],
+ :datefinish => @invoice[:created_at]
+ )
+ res[:retval].should == 0
+ res[:invoices].length.should == 1
+ res[:invoices][0][:state].should == 0
+ res[:invoices][0][:amount].should == 1
+ end
end
end