qbfc 0.1.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README +41 -0
- data/Rakefile +82 -0
- data/lib/qbfc.rb +39 -0
- data/lib/qbfc/base.rb +82 -0
- data/lib/qbfc/element.rb +178 -0
- data/lib/qbfc/entities/generated.rb +8 -0
- data/lib/qbfc/entity.rb +11 -0
- data/lib/qbfc/info.rb +42 -0
- data/lib/qbfc/infos/generated.rb +9 -0
- data/lib/qbfc/item.rb +10 -0
- data/lib/qbfc/items/generated.rb +11 -0
- data/lib/qbfc/list.rb +84 -0
- data/lib/qbfc/lists/generated.rb +15 -0
- data/lib/qbfc/lists/qb_class.rb +25 -0
- data/lib/qbfc/modifiable.rb +31 -0
- data/lib/qbfc/ole_wrapper.rb +193 -0
- data/lib/qbfc/qb_collection.rb +26 -0
- data/lib/qbfc/qb_types.rb +34 -0
- data/lib/qbfc/qbfc_const.rb +14 -0
- data/lib/qbfc/request.rb +158 -0
- data/lib/qbfc/session.rb +136 -0
- data/lib/qbfc/terms.rb +10 -0
- data/lib/qbfc/terms/generated.rb +10 -0
- data/lib/qbfc/transaction.rb +83 -0
- data/lib/qbfc/transactions/generated.rb +18 -0
- data/lib/qbfc/voidable.rb +11 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +62 -0
- data/spec/unit/base_spec.rb +138 -0
- data/spec/unit/element_finder_spec.rb +180 -0
- data/spec/unit/element_spec.rb +118 -0
- data/spec/unit/entities/generated_spec.rb +18 -0
- data/spec/unit/entity_spec.rb +18 -0
- data/spec/unit/info/generated_spec.rb +12 -0
- data/spec/unit/info_spec.rb +48 -0
- data/spec/unit/item_spec.rb +18 -0
- data/spec/unit/items/generated_spec.rb +16 -0
- data/spec/unit/list_finders_spec.rb +128 -0
- data/spec/unit/list_spec.rb +86 -0
- data/spec/unit/lists/generated_spec.rb +15 -0
- data/spec/unit/lists/qb_class_spec.rb +9 -0
- data/spec/unit/modifiable_spec.rb +84 -0
- data/spec/unit/ole_wrapper_spec.rb +293 -0
- data/spec/unit/qb_collection_spec.rb +13 -0
- data/spec/unit/qbfc_const_spec.rb +10 -0
- data/spec/unit/qbfc_spec.rb +10 -0
- data/spec/unit/request_query_survey.txt +48 -0
- data/spec/unit/request_spec.rb +236 -0
- data/spec/unit/session_spec.rb +138 -0
- data/spec/unit/terms/generated_spec.rb +14 -0
- data/spec/unit/terms_spec.rb +18 -0
- data/spec/unit/transaction_finders_spec.rb +124 -0
- data/spec/unit/transaction_spec.rb +94 -0
- data/spec/unit/transactions/generated_spec.rb +20 -0
- data/spec/unit/voidable_spec.rb +32 -0
- metadata +140 -0
@@ -0,0 +1,138 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe QBFC::Session do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@ole_object = mock("WIN32OLE")
|
7
|
+
@ole_object.stub!(:OpenConnection2)
|
8
|
+
@ole_object.stub!(:BeginSession)
|
9
|
+
WIN32OLE.stub!(:new).and_return(@ole_object)
|
10
|
+
|
11
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
12
|
+
QBFC::OLEWrapper.stub!(:new).and_return(@ole_wrapper)
|
13
|
+
|
14
|
+
@qb_sess = QBFC::Session.new()
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should create an QBFC WIN32OLE object" do
|
18
|
+
WIN32OLE.should_receive(:new).with("QBFC6.QBSessionManager").and_return(@ole_object)
|
19
|
+
QBFC::Session.new()
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should wrap WIN32OLE object" do
|
23
|
+
QBFC::OLEWrapper.should_receive(:new).with(@ole_object)
|
24
|
+
QBFC::Session.new()
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should open connection to Quickbooks and establish a session" do
|
28
|
+
@ole_object.should_receive(:OpenConnection2)
|
29
|
+
QBFC::Session.new()
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should begin a session with Quickbooks" do
|
33
|
+
@ole_object.should_receive(:BeginSession)
|
34
|
+
QBFC::Session.new()
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should raise an error if session can't be established" do
|
38
|
+
@ole_object.should_receive(:BeginSession).and_raise(WIN32OLERuntimeError)
|
39
|
+
@ole_object.should_receive(:CloseConnection)
|
40
|
+
lambda { QBFC::Session.new }.should raise_error(QBFC::QuickbooksClosedError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should accept an app_name option" do
|
44
|
+
@ole_object.should_receive(:OpenConnection2).with('', 'Test Application', 1)
|
45
|
+
QBFC::Session.new(:app_name => 'Test Application')
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should accept an app_id option" do
|
49
|
+
@ole_object.should_receive(:OpenConnection2).with('ID', 'Test Application', 1)
|
50
|
+
QBFC::Session.new(:app_name => 'Test Application', :app_id => 'ID')
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should accept a conn_type option" do
|
54
|
+
@ole_object.should_receive(:OpenConnection2).with('', 'Test Application', 0)
|
55
|
+
QBFC::Session.new(:app_name => 'Test Application', :conn_type => QBFC_CONST::CtUnknown)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should accept an open mode constant" do
|
59
|
+
@ole_object.should_receive(:BeginSession).with('', 0)
|
60
|
+
QBFC::Session.new(:open_mode => QBFC_CONST::OmSingleUser )
|
61
|
+
|
62
|
+
@ole_object.should_receive(:BeginSession).with('', 1)
|
63
|
+
QBFC::Session.new(:open_mode => QBFC_CONST::OmMultiUser)
|
64
|
+
|
65
|
+
@ole_object.should_receive(:BeginSession).with('', 2)
|
66
|
+
QBFC::Session.new(:open_mode => QBFC_CONST::OmDontCare)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should accept a filename option" do
|
70
|
+
@ole_object.should_receive(:BeginSession).with('TestCompany.qbw', 2)
|
71
|
+
QBFC::Session.new(:filename => 'TestCompany.qbw')
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should close session and connection on close" do
|
75
|
+
@ole_wrapper.should_receive(:EndSession)
|
76
|
+
@ole_wrapper.should_receive(:CloseConnection)
|
77
|
+
@qb_sess.close()
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "::open" do
|
81
|
+
|
82
|
+
before(:each) do
|
83
|
+
@ole_wrapper.stub!(:EndSession)
|
84
|
+
@ole_wrapper.stub!(:CloseConnection)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should accept a block" do
|
88
|
+
QBFC::Session.open do |qb|
|
89
|
+
qb.should be_kind_of(QBFC::Session)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return session if called without a block" do
|
94
|
+
QBFC::Session.open.should be_kind_of(QBFC::Session)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should create an instance of QBFC::Base descendant from a singular method with params" do
|
99
|
+
@base = mock(QBFC::Base)
|
100
|
+
QBFC::Customer.should_receive(:find_by_unique_id).with(@qb_sess, '1234-5678').and_return(@base)
|
101
|
+
@qb_sess.customer('1234-5678').should == @base
|
102
|
+
|
103
|
+
QBFC::Vendor.should_receive(:find_by_unique_id).with(@qb_sess, '1234-5678').and_return(@base)
|
104
|
+
@qb_sess.vendor('1234-5678').should == @base
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should create an instance of QBFC::Base descendant from a singular method" do
|
108
|
+
@base = mock(QBFC::Base)
|
109
|
+
QBFC::Customer.should_receive(:find).with(@qb_sess, :first).and_return(@base)
|
110
|
+
@qb_sess.customer.should == @base
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should create an instance of QBFC::QBCollection a plural method" do
|
114
|
+
@collection = mock(QBFC::QBCollection)
|
115
|
+
QBFC::QBCollection.should_receive(:new).with(@qb_sess, :Customer).and_return(@collection)
|
116
|
+
@qb_sess.customers.should == @collection
|
117
|
+
|
118
|
+
QBFC::QBCollection.should_receive(:new).with(@qb_sess, :Vendor).and_return(@collection)
|
119
|
+
@qb_sess.vendors.should == @collection
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should create QBFC::QBCollection QBFC::QBClass from #classes" do
|
123
|
+
@collection = mock(QBFC::QBCollection)
|
124
|
+
QBFC::QBCollection.should_receive(:new).with(@qb_sess, :QBClass).and_return(@collection)
|
125
|
+
@qb_sess.classes.should == @collection
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should let OLEWrapper handle other unknown methods" do
|
129
|
+
@ole_wrapper.should_receive(:qbfc_method_missing).with(@qb_sess, :FullName).and_return(true)
|
130
|
+
@qb_sess.FullName
|
131
|
+
|
132
|
+
@ole_wrapper.should_receive(:qbfc_method_missing).with(@qb_sess, :full_name).and_return(true)
|
133
|
+
@qb_sess.full_name
|
134
|
+
|
135
|
+
@ole_wrapper.should_receive(:qbfc_method_missing).with(@qb_sess, :full_name=, 'Full Name').and_return(true)
|
136
|
+
@qb_sess.full_name = 'Full Name'
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe "QBFC::Terms generated.rb" do
|
4
|
+
|
5
|
+
it "should generate classes" do
|
6
|
+
QBFC::DateDrivenTerms.superclass.should be(QBFC::Terms)
|
7
|
+
QBFC::StandardTerms.superclass.should be(QBFC::Terms)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should not include Modifiable in any classes" do
|
11
|
+
QBFC::DateDrivenTerms.included_modules.should_not include(QBFC::Modifiable)
|
12
|
+
QBFC::StandardTerms.included_modules.should_not include(QBFC::Modifiable)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe QBFC::Terms do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@sess = mock(QBFC::Session)
|
7
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "is a base class" do
|
11
|
+
QBFC::Terms.is_base_class?.should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".find" do
|
15
|
+
it "should return subclass objects"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
module QBFC::Test
|
4
|
+
class TxnFind < QBFC::Transaction
|
5
|
+
def self.qb_name
|
6
|
+
"Check"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe QBFC::Transaction do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@sess = mock(QBFC::Session)
|
15
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
16
|
+
@txn = QBFC::Test::Txn.new(@sess, @ole_wrapper)
|
17
|
+
|
18
|
+
# Request related mocks
|
19
|
+
@request = mock("QBFC::Request")
|
20
|
+
@txn_query = mock("QBFC::OLEWrapper#txn_query")
|
21
|
+
@response = mock("QBFC::Request#response")
|
22
|
+
|
23
|
+
# Filter mock
|
24
|
+
@filter = mock("QBFC::OLEWrapper#Filter")
|
25
|
+
@request.stub!(:filter).and_return(@filter)
|
26
|
+
@filter.stub!(:max_returned=)
|
27
|
+
@request.stub!(:filter_available?).and_return(true)
|
28
|
+
@request.stub!(:apply_options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup_request
|
32
|
+
QBFC::Request.should_receive(:new).with(@sess, 'CheckQuery').and_return(@request)
|
33
|
+
@request.should_receive(:kind_of?).with(QBFC::Request).and_return(true)
|
34
|
+
@request.stub!(:response).and_return(@response)
|
35
|
+
@response.stub!(:GetAt).with(0).and_return(@ole_wrapper)
|
36
|
+
@response.stub!(:ole_methods).and_return(["GetAt"])
|
37
|
+
end
|
38
|
+
|
39
|
+
describe ".find_by_ref" do
|
40
|
+
before(:each) do
|
41
|
+
@ref_list = mock("QBFC::OLEWrapper#ref_list")
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_request
|
45
|
+
super
|
46
|
+
@request.should_receive(:query).and_return(@txn_query)
|
47
|
+
@txn_query.should_receive(:RefNumberList).and_return(@ref_list)
|
48
|
+
@ref_list.should_receive(:Add).with("12345")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should set up Request, specifying RefNumberList" do
|
52
|
+
setup_request
|
53
|
+
QBFC::Test::TxnFind.find_by_ref(@sess, "12345")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return a Transaction object" do
|
57
|
+
setup_request
|
58
|
+
list = QBFC::Test::TxnFind.find_by_ref(@sess, "12345")
|
59
|
+
list.should be_kind_of(QBFC::Test::TxnFind)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should return nil if none found" do
|
63
|
+
setup_request
|
64
|
+
@request.should_receive(:response).and_return(nil)
|
65
|
+
QBFC::Test::TxnFind.find_by_ref(@sess, "12345").should be_nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe ".find_by_id" do
|
70
|
+
before(:each) do
|
71
|
+
@txn_id_list = mock("QBFC::OLEWrapper#txn_id_list")
|
72
|
+
end
|
73
|
+
|
74
|
+
def setup_request
|
75
|
+
super
|
76
|
+
@request.should_receive(:query).and_return(@txn_query)
|
77
|
+
@txn_query.should_receive(:TxnIDList).and_return(@txn_id_list)
|
78
|
+
@txn_id_list.should_receive(:Add).with("123-456")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should set up Request, specifying TxnIDTxn" do
|
82
|
+
setup_request
|
83
|
+
QBFC::Test::TxnFind.find_by_id(@sess, "123-456")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should return a Transaction object" do
|
87
|
+
setup_request
|
88
|
+
list = QBFC::Test::TxnFind.find_by_id(@sess, "123-456")
|
89
|
+
list.should be_kind_of(QBFC::Test::TxnFind)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return nil if none found" do
|
93
|
+
setup_request
|
94
|
+
@request.should_receive(:response).and_return(nil)
|
95
|
+
QBFC::Test::TxnFind.find_by_id(@sess, "123-456").should be_nil
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe ".find_by_name_or_id" do
|
100
|
+
it "should try to find_by_id" do
|
101
|
+
QBFC::Test::TxnFind.should_receive(:find_by_id).with(@sess, "123-456").and_return("Txn By ID")
|
102
|
+
QBFC::Test::TxnFind.find_by_ref_or_id(@sess, "123-456").should == "Txn By ID"
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should try to find_by_ref if id fails" do
|
106
|
+
QBFC::Test::TxnFind.should_receive(:find_by_id).with(@sess, "123-456").and_return(nil)
|
107
|
+
QBFC::Test::TxnFind.should_receive(:find_by_ref).with(@sess, "123-456").and_return("Txn By Ref")
|
108
|
+
QBFC::Test::TxnFind.find_by_ref_or_id(@sess, "123-456").should == "Txn By Ref"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return nil if both ref and id return nil" do
|
112
|
+
QBFC::Test::TxnFind.should_receive(:find_by_id).with(@sess, "123-456").and_return(nil)
|
113
|
+
QBFC::Test::TxnFind.should_receive(:find_by_ref).with(@sess, "123-456").and_return(nil)
|
114
|
+
QBFC::Test::TxnFind.find_by_ref_or_id(@sess, "123-456").should be_nil
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should be aliased as .find_by_unique_id" do
|
118
|
+
QBFC::Test::TxnFind.should_receive(:find_by_id).with(@sess, "123-456").and_return(nil)
|
119
|
+
QBFC::Test::TxnFind.should_receive(:find_by_ref).with(@sess, "123-456").and_return(nil)
|
120
|
+
QBFC::Test::TxnFind.find_by_unique_id(@sess, "123-456").should be_nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
module QBFC::Test
|
4
|
+
class Txn < QBFC::Transaction
|
5
|
+
def qb_name
|
6
|
+
"Check"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe QBFC::Transaction do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@sess = mock(QBFC::Session)
|
15
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
16
|
+
@txn = QBFC::Test::Txn.new(@sess, @ole_wrapper)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "::ID_NAME" do
|
20
|
+
it "should be 'TxnID'" do
|
21
|
+
QBFC::Test::Txn::ID_NAME.should == "TxnID"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#id" do
|
26
|
+
it "is an alias of txn_id" do
|
27
|
+
@ole_wrapper.should_receive(:txn_id).and_return('T123')
|
28
|
+
@txn.id.should == 'T123'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#delete" do
|
33
|
+
it "should setup a TxnDelRq with Txn Type and ID" do
|
34
|
+
@del_rq = mock(QBFC::Request)
|
35
|
+
@ole_wrapper.should_receive(:txn_id).and_return('123-456')
|
36
|
+
QBFC::Request.should_receive(:new).with(@sess, "TxnDel").and_return(@del_rq)
|
37
|
+
@del_rq.should_receive(:txn_del_type=).with(QBFC_CONST::TdtCheck)
|
38
|
+
@del_rq.should_receive(:txn_id=).with('123-456')
|
39
|
+
@del_rq.should_receive(:submit)
|
40
|
+
@txn.delete.should be_true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#display" do
|
45
|
+
before(:each) do
|
46
|
+
@display_rq = mock(QBFC::Request)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should call TxnDisplayAdd for new records" do
|
50
|
+
QBFC::Request.should_receive(:new).with(@sess, "TxnDisplayAdd").and_return(@display_rq)
|
51
|
+
@display_rq.should_receive(:txn_display_add_type=).with(QBFC_CONST::TdatCheck)
|
52
|
+
@display_rq.should_receive(:submit)
|
53
|
+
@txn.instance_variable_set(:@new_record, true)
|
54
|
+
@txn.display
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should call TxnDisplayMod for existing records" do
|
58
|
+
@ole_wrapper.should_receive(:txn_id).and_return('123-456')
|
59
|
+
|
60
|
+
QBFC::Request.should_receive(:new).with(@sess, "TxnDisplayMod").and_return(@display_rq)
|
61
|
+
@display_rq.should_receive(:txn_display_mod_type=).with(QBFC_CONST::TdmtCheck)
|
62
|
+
@display_rq.should_receive(:txn_id=).with('123-456')
|
63
|
+
@display_rq.should_receive(:submit)
|
64
|
+
@txn.display
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#cleared_status=" do
|
69
|
+
before(:each) do
|
70
|
+
@ole_wrapper.should_receive(:txn_id).and_return('123-456')
|
71
|
+
|
72
|
+
@cs_rq = mock(QBFC::Request)
|
73
|
+
QBFC::Request.should_receive(:new).with(@sess, "ClearedStatusMod").and_return(@cs_rq)
|
74
|
+
@cs_rq.should_receive(:txn_id=).with('123-456')
|
75
|
+
@cs_rq.should_receive(:submit)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should submit a ClearedStatusModRq" do
|
79
|
+
@cs_rq.should_receive(:cleared_status=).with(QBFC_CONST::CsCleared)
|
80
|
+
@txn.cleared_status = QBFC_CONST::CsCleared
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should accept true for CsCleared" do
|
84
|
+
@cs_rq.should_receive(:cleared_status=).with(QBFC_CONST::CsCleared)
|
85
|
+
@txn.cleared_status = true
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should accept false for CsNotCleared" do
|
89
|
+
@cs_rq.should_receive(:cleared_status=).with(QBFC_CONST::CsNotCleared)
|
90
|
+
@txn.cleared_status = false
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe "QBFC::Transactions generated.rb" do
|
4
|
+
|
5
|
+
it "should generate classes" do
|
6
|
+
QBFC::Check.superclass.should be(QBFC::Transaction)
|
7
|
+
QBFC::Bill.superclass.should be(QBFC::Transaction)
|
8
|
+
QBFC::CreditMemo.superclass.should be(QBFC::Transaction)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should include Voidable in voidable classes" do
|
12
|
+
QBFC::Check.included_modules.should include(QBFC::Voidable)
|
13
|
+
QBFC::Estimate.included_modules.should_not include(QBFC::Voidable)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should include Modifiable in modifiable classes" do
|
17
|
+
QBFC::Check.included_modules.should include(QBFC::Modifiable)
|
18
|
+
QBFC::Deposit.included_modules.should_not include(QBFC::Modifiable)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
module QBFC::Test
|
4
|
+
class TxnVoid < QBFC::Transaction
|
5
|
+
include QBFC::Voidable
|
6
|
+
|
7
|
+
def qb_name
|
8
|
+
"Check"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe QBFC::Voidable do
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
@sess = mock(QBFC::Session)
|
17
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
18
|
+
@txn = QBFC::Test::TxnVoid.new(@sess, @ole_wrapper)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#void" do
|
22
|
+
it "should call a TxnVoidRq with Txn Type and ID" do
|
23
|
+
@void_rq = mock(QBFC::Request)
|
24
|
+
@ole_wrapper.should_receive(:txn_id).and_return('{123-456}')
|
25
|
+
QBFC::Request.should_receive(:new).with(@sess, "TxnVoid").and_return(@void_rq)
|
26
|
+
@void_rq.should_receive(:txn_void_type=).with(QBFC_CONST::const_get("TvtCheck"))
|
27
|
+
@void_rq.should_receive(:txn_id=).with("{123-456}")
|
28
|
+
@void_rq.should_receive(:submit)
|
29
|
+
@txn.void.should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|