rconomic 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +6 -14
  2. data/.travis.yml +0 -1
  3. data/Gemfile +0 -1
  4. data/lib/economic/account.rb +3 -5
  5. data/lib/economic/cash_book.rb +1 -1
  6. data/lib/economic/cash_book_entry.rb +92 -94
  7. data/lib/economic/creditor.rb +1 -1
  8. data/lib/economic/creditor_contact.rb +15 -17
  9. data/lib/economic/creditor_entry.rb +0 -1
  10. data/lib/economic/current_invoice.rb +32 -35
  11. data/lib/economic/current_invoice_line.rb +14 -2
  12. data/lib/economic/debtor.rb +60 -37
  13. data/lib/economic/debtor_contact.rb +26 -20
  14. data/lib/economic/endpoint.rb +72 -0
  15. data/lib/economic/entity/handle.rb +35 -21
  16. data/lib/economic/entity/mapper.rb +41 -0
  17. data/lib/economic/entity.rb +58 -34
  18. data/lib/economic/invoice.rb +15 -2
  19. data/lib/economic/proxies/account_proxy.rb +2 -3
  20. data/lib/economic/proxies/actions/find_by_ci_number.rb +4 -2
  21. data/lib/economic/proxies/actions/find_by_date_interval.rb +0 -1
  22. data/lib/economic/proxies/actions/find_by_name.rb +5 -1
  23. data/lib/economic/proxies/cash_book_entry_proxy.rb +1 -1
  24. data/lib/economic/proxies/entity_proxy.rb +15 -8
  25. data/lib/economic/session.rb +27 -31
  26. data/lib/rconomic/version.rb +1 -1
  27. data/rconomic.gemspec +1 -5
  28. data/spec/economic/cash_book_entry_spec.rb +27 -5
  29. data/spec/economic/cash_book_spec.rb +6 -6
  30. data/spec/economic/creditor_contact_spec.rb +24 -15
  31. data/spec/economic/creditor_spec.rb +9 -9
  32. data/spec/economic/current_invoice_line_spec.rb +7 -7
  33. data/spec/economic/current_invoice_spec.rb +82 -33
  34. data/spec/economic/debtor_contact_spec.rb +25 -15
  35. data/spec/economic/debtor_entry_spec.rb +3 -3
  36. data/spec/economic/debtor_spec.rb +49 -15
  37. data/spec/economic/endpoint_spec.rb +71 -0
  38. data/spec/economic/entity/handle_spec.rb +42 -49
  39. data/spec/economic/entity/mapper_spec.rb +54 -0
  40. data/spec/economic/entity_spec.rb +78 -72
  41. data/spec/economic/entry_spec.rb +3 -3
  42. data/spec/economic/invoice_spec.rb +37 -18
  43. data/spec/economic/proxies/actions/find_by_name_spec.rb +15 -12
  44. data/spec/economic/proxies/cash_book_entry_proxy_spec.rb +26 -24
  45. data/spec/economic/proxies/cash_book_proxy_spec.rb +23 -21
  46. data/spec/economic/proxies/creditor_contact_proxy_spec.rb +12 -16
  47. data/spec/economic/proxies/creditor_entry_proxy_spec.rb +18 -14
  48. data/spec/economic/proxies/creditor_proxy_spec.rb +23 -26
  49. data/spec/economic/proxies/current_invoice_line_proxy_spec.rb +17 -20
  50. data/spec/economic/proxies/current_invoice_proxy_spec.rb +38 -41
  51. data/spec/economic/proxies/debtor_contact_proxy_spec.rb +12 -15
  52. data/spec/economic/proxies/debtor_entry_proxy_spec.rb +18 -14
  53. data/spec/economic/proxies/debtor_proxy_spec.rb +31 -34
  54. data/spec/economic/proxies/entry_proxy_spec.rb +26 -22
  55. data/spec/economic/proxies/invoice_proxy_spec.rb +18 -21
  56. data/spec/economic/session_spec.rb +57 -44
  57. data/spec/fixtures/{spec_entity_create_from_data → account_create_from_data}/success.xml +5 -5
  58. data/spec/fixtures/{spec_entity_delete → account_delete}/success.xml +1 -1
  59. data/spec/fixtures/{spec_entity_get_data → account_get_data}/success.xml +5 -5
  60. data/spec/fixtures/{spec_entity_update_from_data → account_update_from_data}/success.xml +5 -5
  61. data/spec/fixtures/cash_book_entry_create_creditor_invoice/success.xml +2 -2
  62. data/spec/fixtures/cash_book_entry_create_creditor_payment/success.xml +2 -2
  63. data/spec/fixtures/creditor_contact_create_from_data/success.xml +10 -0
  64. data/spec/fixtures/debtor_contact_create_from_data/success.xml +10 -0
  65. data/spec/fixtures/debtor_create_from_data/success.xml +57 -0
  66. data/spec/spec_helper.rb +10 -104
  67. data/spec/support/api_requests.rb +20 -0
  68. data/spec/support/factories.rb +65 -0
  69. data/spec/support/fixtures.rb +9 -0
  70. metadata +27 -31
@@ -8,7 +8,7 @@ describe Economic::CashBookProxy do
8
8
  describe ".new" do
9
9
 
10
10
  it "stores session" do
11
- subject.session.should === session
11
+ expect(subject.session).to equal(session)
12
12
  end
13
13
 
14
14
  end
@@ -16,11 +16,11 @@ describe Economic::CashBookProxy do
16
16
  describe ".build" do
17
17
 
18
18
  it "instantiates a new CashBook" do
19
- subject.build.should be_instance_of(Economic::CashBook)
19
+ expect(subject.build).to be_instance_of(Economic::CashBook)
20
20
  end
21
21
 
22
22
  it "assigns the session to the CashBook" do
23
- subject.build.session.should === session
23
+ expect(subject.build.session).to equal(session)
24
24
  end
25
25
 
26
26
  end
@@ -28,52 +28,54 @@ describe Economic::CashBookProxy do
28
28
  describe ".all" do
29
29
 
30
30
  it "returns multiple cashbooks" do
31
- savon.stubs('CashBook_GetAll').returns(:multiple)
32
- savon.stubs('CashBook_GetDataArray').returns(:multiple)
31
+ stub_request('CashBook_GetAll', nil, :multiple)
32
+ stub_request('CashBook_GetDataArray', nil, :multiple)
33
33
 
34
34
  all = subject.all
35
- all.size.should == 2
36
- all.each { |cash_book| cash_book.should be_instance_of(Economic::CashBook) }
35
+ expect(all.size).to eq(2)
36
+ all.each { |cash_book| expect(cash_book).to be_instance_of(Economic::CashBook) }
37
37
  end
38
38
 
39
39
  it "properly fills out handles of cash books" do
40
40
  # Issue #12
41
- savon.stubs('CashBook_GetAll').returns(:multiple)
42
- savon.stubs('CashBook_GetData').returns(:success)
43
- savon.stubs('CashBook_GetDataArray').returns(:multiple)
41
+ stub_request('CashBook_GetAll', nil, :multiple)
42
+ stub_request('CashBook_GetDataArray', nil, :multiple)
43
+ stub_request('CashBook_GetData', nil, :success)
44
+ stub_request('CashBook_GetAll', nil, :multiple)
45
+ stub_request('CashBook_GetDataArray', nil, :multiple)
44
46
 
45
47
  cash_book = subject.find(subject.all.first.handle)
46
- subject.all.first.handle.should == cash_book.handle
48
+ expect(subject.all.first.handle).to eq(cash_book.handle)
47
49
  end
48
50
  end
49
51
 
50
52
  describe ".get_name" do
51
53
 
52
54
  it 'returns a cash book with a name' do
53
- savon.expects('CashBook_GetName').with("cashBookHandle" => { "Number" => "52" }).returns(:success)
55
+ mock_request('CashBook_GetName', {"cashBookHandle" => { "Number" => "52" }}, :success)
54
56
  result = subject.get_name("52")
55
- result.should be_instance_of(Economic::CashBook)
56
- result.number.should == "52"
57
- result.name.should be_a(String)
57
+ expect(result).to be_instance_of(Economic::CashBook)
58
+ expect(result.number).to eq("52")
59
+ expect(result.name).to be_a(String)
58
60
  end
59
61
 
60
62
  end
61
63
 
62
64
  describe "#last" do
63
65
  it "returns the last cash book" do
64
- savon.stubs('CashBook_GetAll').returns(:multiple)
65
- savon.stubs('CashBook_GetDataArray').returns(:multiple)
66
+ stub_request('CashBook_GetAll', nil, :multiple)
67
+ stub_request('CashBook_GetDataArray', nil, :multiple)
66
68
 
67
- subject.all.last.name.should == "Another cash book"
69
+ expect(subject.all.last.name).to eq("Another cash book")
68
70
  end
69
71
  end
70
72
 
71
73
  describe "#[]" do
72
74
  it "returns the specific cash book" do
73
- savon.stubs('CashBook_GetAll').returns(:multiple)
74
- savon.stubs('CashBook_GetDataArray').returns(:multiple)
75
+ stub_request('CashBook_GetAll', nil, :multiple)
76
+ stub_request('CashBook_GetDataArray', nil, :multiple)
75
77
 
76
- subject.all[1].name.should == "Another cash book"
78
+ expect(subject.all[1].name).to eq("Another cash book")
77
79
  end
78
80
  end
79
81
  end
@@ -6,21 +6,21 @@ describe Economic::CreditorContactProxy do
6
6
 
7
7
  describe ".new" do
8
8
  it "stores session" do
9
- subject.session.should === session
9
+ expect(subject.session).to equal(session)
10
10
  end
11
11
  end
12
12
 
13
13
  describe ".build" do
14
14
  it "instantiates a new CreditorContact" do
15
- subject.build.should be_instance_of(Economic::CreditorContact)
15
+ expect(subject.build).to be_instance_of(Economic::CreditorContact)
16
16
  end
17
17
 
18
18
  it "assigns the session to the CreditorContact" do
19
- subject.build.session.should === session
19
+ expect(subject.build.session).to equal(session)
20
20
  end
21
21
 
22
22
  it "should not build a partial CreditorContact" do
23
- subject.build.should_not be_partial
23
+ expect(subject.build).to_not be_partial
24
24
  end
25
25
 
26
26
  context "when owner is a Creditor" do
@@ -28,38 +28,34 @@ describe Economic::CreditorContactProxy do
28
28
  subject { creditor.contacts }
29
29
 
30
30
  it "should use the Creditors session" do
31
- subject.build.session.should == creditor.session
31
+ expect(subject.build.session).to eq(creditor.session)
32
32
  end
33
33
 
34
34
  it "should initialize with values from Creditor" do
35
35
  contact = subject.build
36
- contact.creditor_handle.should == creditor.handle
36
+ expect(contact.creditor_handle).to eq(creditor.handle)
37
37
  end
38
38
  end
39
39
  end
40
40
 
41
41
  describe ".find" do
42
- before :each do
43
- savon.stubs('CreditorContact_GetData').returns(:success)
44
- end
45
-
46
42
  it "gets contact data from API" do
47
- savon.expects('CreditorContact_GetData').with('entityHandle' => {'Id' => 42}).returns(:success)
43
+ mock_request('CreditorContact_GetData', {'entityHandle' => {'Id' => 42}}, :success)
48
44
  subject.find(42)
49
45
  end
50
46
 
51
47
  it "returns CreditorContact object" do
52
- subject.find(42).should be_instance_of(Economic::CreditorContact)
48
+ stub_request('CreditorContact_GetData', nil, :success)
49
+ expect(subject.find(42)).to be_instance_of(Economic::CreditorContact)
53
50
  end
54
51
  end
55
52
 
56
53
  describe "#find_by_name" do
57
54
  it "uses the FindByName command" do
58
- Economic::Proxies::Actions::FindByName.expects(:new).
55
+ expect(Economic::Proxies::Actions::FindByName).to receive(:new).
59
56
  with(subject, "Bob").
60
- returns(lambda { "Result" })
61
- subject.find_by_name("Bob").should == "Result"
57
+ and_return(lambda { "Result" })
58
+ expect(subject.find_by_name("Bob")).to eq("Result")
62
59
  end
63
60
  end
64
61
  end
65
-
@@ -6,44 +6,48 @@ describe Economic::CreditorEntryProxy do
6
6
 
7
7
  describe "new" do
8
8
  it "stores session" do
9
- subject.session.should === session
9
+ expect(subject.session).to equal(session)
10
10
  end
11
11
  end
12
12
 
13
13
  describe "#find_by_invoice_number" do
14
14
  it 'should be able to find multiple creditor entries' do
15
- savon.expects("CreditorEntry_FindByInvoiceNumber").with('invoiceNumber' => '123').returns(:many)
16
- subject.find_by_invoice_number('123').should == [1, 2]
15
+ mock_request("CreditorEntry_FindByInvoiceNumber", {'invoiceNumber' => '123'}, :many)
16
+ expect(subject.find_by_invoice_number('123')).to eq([1, 2])
17
17
  end
18
18
 
19
19
  it 'should handle a single serial number in the response' do
20
- savon.stubs("CreditorEntry_FindByInvoiceNumber").returns(:single)
21
- subject.find_by_invoice_number('123').should == [1]
20
+ stub_request("CreditorEntry_FindByInvoiceNumber", nil, :single)
21
+ expect(subject.find_by_invoice_number('123')).to eq([1])
22
22
  end
23
23
  end
24
24
 
25
25
  describe "#find" do
26
26
  it 'should get a creditor entry by serial number' do
27
- savon.expects("CreditorEntry_GetData").with('entityHandle' => { 'SerialNumber' => '123' }).returns(:success)
28
- subject.find('123').should be_instance_of(Economic::CreditorEntry)
27
+ mock_request("CreditorEntry_GetData", {'entityHandle' => { 'SerialNumber' => '123' }}, :success)
28
+ expect(subject.find('123')).to be_instance_of(Economic::CreditorEntry)
29
29
  end
30
30
  end
31
31
 
32
32
  describe "#match" do
33
33
  it 'should match two creditor entries by serial numbers' do
34
- savon.stubs("CreditorEntry_MatchEntries").with(
35
- :entries => [
36
- { :creditor_entry_handle => { :serial_number => 1 } },
37
- { :credior_entry_handle => { :serial_number => 2 } }
38
- ]
39
- ).returns(:success)
34
+ stub_request(
35
+ "CreditorEntry_MatchEntries",
36
+ {:entries => {
37
+ "CreditorEntryHandle" => [
38
+ {"SerialNumber"=>1},
39
+ {"SerialNumber"=>2}
40
+ ]
41
+ }},
42
+ :success
43
+ )
40
44
  subject.match(1, 2)
41
45
  end
42
46
  end
43
47
 
44
48
  describe "#entity_class" do
45
49
  it "should return Economic::CreditorEntry" do
46
- Economic::CreditorEntryProxy.entity_class.should == Economic::CreditorEntry
50
+ expect(Economic::CreditorEntryProxy.entity_class).to eq(Economic::CreditorEntry)
47
51
  end
48
52
  end
49
53
  end
@@ -6,40 +6,37 @@ describe Economic::CreditorProxy do
6
6
 
7
7
  describe "new" do
8
8
  it "stores session" do
9
- subject.session.should === session
9
+ expect(subject.session).to equal(session)
10
10
  end
11
11
  end
12
12
 
13
13
  describe "find" do
14
- before :each do
15
- savon.stubs('Creditor_GetData').returns(:success)
16
- end
17
-
18
14
  it "gets creditor data from API" do
19
- savon.expects('Creditor_GetData').with('entityHandle' => {'Number' => 42}).returns(:success)
15
+ mock_request('Creditor_GetData', {'entityHandle' => {'Number' => 42}}, :success)
20
16
  subject.find(42)
21
17
  end
22
18
 
23
19
  it "returns Creditor object" do
24
- subject.find(42).should be_instance_of(Economic::Creditor)
20
+ stub_request('Creditor_GetData', nil, :success)
21
+ expect(subject.find(42)).to be_instance_of(Economic::Creditor)
25
22
  end
26
23
  end
27
24
 
28
25
  describe "find_by_number" do
29
26
  it "can find a creditor" do
30
- savon.expects('Creditor_FindByNumber').with('number' => '1').returns(:found)
27
+ mock_request('Creditor_FindByNumber', {'number' => '1'}, :found)
31
28
  result = subject.find_by_number('1')
32
- result.should be_instance_of(Economic::Creditor)
33
- result.number.should == 1
34
- result.partial.should be_true
35
- result.persisted.should be_true
36
- result.handle.should == Economic::Entity::Handle.new({ :number => 1 })
29
+ expect(result).to be_instance_of(Economic::Creditor)
30
+ expect(result.number).to eq(1)
31
+ expect(result.partial).to be_true
32
+ expect(result.persisted).to be_true
33
+ expect(result.handle).to eq(Economic::Entity::Handle.new({ :number => 1 }))
37
34
  end
38
35
 
39
36
  it "returns nil when there is no creditor" do
40
- savon.expects('Creditor_FindByNumber').with('number' => '1').returns(:not_found)
37
+ mock_request('Creditor_FindByNumber', {'number' => '1'}, :not_found)
41
38
  result = subject.find_by_number('1')
42
- result.should be_nil
39
+ expect(result).to be_nil
43
40
  end
44
41
  end
45
42
 
@@ -47,35 +44,35 @@ describe Economic::CreditorProxy do
47
44
  subject { session.creditors.build }
48
45
 
49
46
  it "instantiates a new Creditor" do
50
- subject.should be_instance_of(Economic::Creditor)
47
+ expect(subject).to be_instance_of(Economic::Creditor)
51
48
  end
52
49
 
53
50
  it "assigns the session to the Creditor" do
54
- subject.session.should === session
51
+ expect(subject.session).to equal(session)
55
52
  end
56
53
  end
57
54
 
58
55
  describe "#entity_class" do
59
56
  it "should return Economic::Creditor" do
60
- Economic::CreditorProxy.entity_class.should == Economic::Creditor
57
+ expect(Economic::CreditorProxy.entity_class).to eq(Economic::Creditor)
61
58
  end
62
59
  end
63
60
 
64
61
  describe ".all" do
65
62
  it "returns a single creditor" do
66
- savon.expects('Creditor_GetAll').returns(:single)
67
- savon.expects('Creditor_GetData').with('entityHandle' => {'Number' => 1}).returns(:success)
63
+ stub_request('Creditor_GetAll', nil, :single)
64
+ mock_request('Creditor_GetData', {'entityHandle' => {'Number' => 1}}, :success)
68
65
  all = subject.all
69
- all.size.should == 1
70
- all.first.should be_instance_of(Economic::Creditor)
66
+ expect(all.size).to eq(1)
67
+ expect(all.first).to be_instance_of(Economic::Creditor)
71
68
  end
72
69
 
73
70
  it "returns multiple creditors" do
74
- savon.expects('Creditor_GetAll').returns(:multiple)
75
- savon.expects('Creditor_GetDataArray').returns(:multiple)
71
+ mock_request('Creditor_GetAll', nil, :multiple)
72
+ stub_request('Creditor_GetDataArray', nil, :multiple)
76
73
  all = subject.all
77
- all.size.should == 2
78
- all.first.should be_instance_of(Economic::Creditor)
74
+ expect(all.size).to eq(2)
75
+ expect(all.first).to be_instance_of(Economic::Creditor)
79
76
  end
80
77
  end
81
78
  end
@@ -7,11 +7,11 @@ describe Economic::CurrentInvoiceLineProxy do
7
7
 
8
8
  describe "new" do
9
9
  it "stores owner" do
10
- subject.owner.should == invoice
10
+ expect(subject.owner).to eq(invoice)
11
11
  end
12
12
 
13
13
  it "stores session" do
14
- subject.session.should == invoice.session
14
+ expect(subject.session).to eq(invoice.session)
15
15
  end
16
16
  end
17
17
 
@@ -20,72 +20,69 @@ describe Economic::CurrentInvoiceLineProxy do
20
20
  line = Economic::CurrentInvoiceLine.new
21
21
  subject.append(line)
22
22
  subject.append(line)
23
- subject.size.should == 1
23
+ expect(subject.size).to eq(1)
24
24
  end
25
25
  end
26
26
 
27
27
  describe ".build" do
28
28
  it "instantiates a new CurrentInvoiceLine" do
29
- subject.build.should be_instance_of(Economic::CurrentInvoiceLine)
29
+ expect(subject.build).to be_instance_of(Economic::CurrentInvoiceLine)
30
30
  end
31
31
 
32
32
  it "assigns the session to the CurrentInvoiceLine" do
33
- subject.build.session.should == session
33
+ expect(subject.build.session).to eq(session)
34
34
  end
35
35
 
36
36
  it "should not build a partial CurrentInvoiceLine" do
37
- subject.build.should_not be_partial
37
+ expect(subject.build).to_not be_partial
38
38
  end
39
39
 
40
40
  it "adds the built line to proxy items" do
41
- line = subject.build
42
- subject.first.should == line
41
+ line = subject.build(:number => 5)
42
+ expect(subject.first).to eq(line)
43
43
  end
44
44
 
45
45
  context "when owner is a CurrentInvoice" do
46
46
  subject { invoice.lines }
47
47
 
48
48
  it "should use the Debtors session" do
49
- subject.build.session.should == invoice.session
49
+ expect(subject.build.session).to eq(invoice.session)
50
50
  end
51
51
 
52
52
  it "should initialize with values from CurrentInvoice" do
53
53
  invoice_line = subject.build
54
- invoice_line.invoice_handle.should == invoice.handle
54
+ expect(invoice_line.invoice_handle).to eq(invoice.handle)
55
55
  end
56
56
  end
57
57
  end
58
58
 
59
59
  describe ".find" do
60
- before :each do
61
- savon.stubs('CurrentInvoiceLine_GetData').returns(:success)
62
- end
63
-
64
60
  it "gets invoice_line data from API" do
65
- savon.expects('CurrentInvoiceLine_GetData').with('entityHandle' => {'Number' => 42}).returns(:success)
61
+ mock_request('CurrentInvoiceLine_GetData', {'entityHandle' => {'Number' => 42}}, :success)
66
62
  subject.find(42)
67
63
  end
68
64
 
69
65
  it "returns CurrentInvoiceLine object" do
70
- subject.find(42).should be_instance_of(Economic::CurrentInvoiceLine)
66
+ stub_request('CurrentInvoiceLine_GetData', nil, :success)
67
+ expect(subject.find(42)).to be_instance_of(Economic::CurrentInvoiceLine)
71
68
  end
72
69
  end
73
70
 
74
71
  describe "enumerable" do
75
72
  it "can be empty" do
76
- subject.should be_empty
73
+ expect(subject).to be_empty
77
74
  end
78
75
 
79
76
  it "can be appended to" do
80
- line = Economic::CurrentInvoiceLine.new
77
+ line = Economic::CurrentInvoiceLine.new(:number => 5)
81
78
  subject << line
82
- subject.last.should == line
79
+ expect(subject.last).to eq(line)
83
80
  end
84
81
 
85
82
  it "can be iterated over" do
86
83
  line = Economic::CurrentInvoiceLine.new
87
84
  subject << line
88
- subject.all? { |l| l.is_a?(Economic::CurrentInvoiceLine) }.should be_true
85
+ expect(subject.all? { |l| l.is_a?(Economic::CurrentInvoiceLine) }).to be_true
89
86
  end
90
87
  end
91
88
  end
@@ -7,21 +7,21 @@ describe Economic::CurrentInvoiceProxy do
7
7
 
8
8
  describe ".new" do
9
9
  it "stores session" do
10
- subject.session.should === session
10
+ expect(subject.session).to equal(session)
11
11
  end
12
12
  end
13
13
 
14
14
  describe ".build" do
15
15
  it "instantiates a new CurrentInvoice" do
16
- subject.build.should be_instance_of(Economic::CurrentInvoice)
16
+ expect(subject.build).to be_instance_of(Economic::CurrentInvoice)
17
17
  end
18
18
 
19
19
  it "assigns the session to the CurrentInvoice" do
20
- subject.build.session.should === session
20
+ expect(subject.build.session).to equal(session)
21
21
  end
22
22
 
23
23
  it "should not build a partial CurrentInvoice" do
24
- subject.build.should_not be_partial
24
+ expect(subject.build).to_not be_partial
25
25
  end
26
26
 
27
27
  context "when owner is a Debtor" do
@@ -29,37 +29,34 @@ describe Economic::CurrentInvoiceProxy do
29
29
  subject { debtor.current_invoices }
30
30
 
31
31
  it "should use the Debtors session" do
32
- subject.build.session.should == debtor.session
32
+ expect(subject.build.session).to eq(debtor.session)
33
33
  end
34
34
 
35
35
  it "should initialize with values from Debtor" do
36
36
  invoice = subject.build
37
37
 
38
- invoice.debtor_name.should == debtor.name
39
- invoice.debtor_address.should == debtor.address
40
- invoice.debtor_postal_code.should == debtor.postal_code
41
- invoice.debtor_city.should == debtor.city
38
+ expect(invoice.debtor_name).to eq(debtor.name)
39
+ expect(invoice.debtor_address).to eq(debtor.address)
40
+ expect(invoice.debtor_postal_code).to eq(debtor.postal_code)
41
+ expect(invoice.debtor_city).to eq(debtor.city)
42
42
 
43
- invoice.debtor_handle.should == debtor.handle
44
- invoice.term_of_payment_handle.should == debtor.term_of_payment_handle
45
- invoice.layout_handle.should == debtor.layout_handle
46
- invoice.currency_handle.should == debtor.currency_handle
43
+ expect(invoice.debtor_handle).to eq(debtor.handle)
44
+ expect(invoice.term_of_payment_handle).to eq(debtor.term_of_payment_handle)
45
+ expect(invoice.layout_handle).to eq(debtor.layout_handle)
46
+ expect(invoice.currency_handle).to eq(debtor.currency_handle)
47
47
  end
48
48
  end
49
49
  end
50
50
 
51
51
  describe ".find" do
52
- before :each do
53
- savon.stubs('CurrentInvoice_GetData').returns(:success)
54
- end
55
-
56
52
  it "gets invoice data from API" do
57
- savon.expects('CurrentInvoice_GetData').with('entityHandle' => {'Id' => 42}).returns(:success)
53
+ mock_request('CurrentInvoice_GetData', {'entityHandle' => {'Id' => 42}}, :success)
58
54
  subject.find(42)
59
55
  end
60
56
 
61
57
  it "returns CurrentInvoice object" do
62
- subject.find(42).should be_instance_of(Economic::CurrentInvoice)
58
+ stub_request('CurrentInvoice_GetData', nil, :success)
59
+ expect(subject.find(42)).to be_instance_of(Economic::CurrentInvoice)
63
60
  end
64
61
  end
65
62
 
@@ -68,25 +65,25 @@ describe Economic::CurrentInvoiceProxy do
68
65
  let(:unto) { Time.now }
69
66
 
70
67
  it "should be able to return a single current invoice" do
71
- savon.expects('CurrentInvoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601).returns(:single)
72
- savon.expects('CurrentInvoice_GetDataArray').returns(:single)
68
+ mock_request('CurrentInvoice_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :single)
69
+ stub_request('CurrentInvoice_GetDataArray', nil, :single)
73
70
  results = subject.find_by_date_interval(from, unto)
74
- results.size.should == 1
75
- results.first.should be_instance_of(Economic::CurrentInvoice)
71
+ expect(results.size).to eq(1)
72
+ expect(results.first).to be_instance_of(Economic::CurrentInvoice)
76
73
  end
77
74
 
78
75
  it "should be able to return multiple invoices" do
79
- savon.expects('CurrentInvoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601).returns(:many)
80
- savon.expects('CurrentInvoice_GetDataArray').returns(:multiple)
76
+ mock_request('CurrentInvoice_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :many)
77
+ stub_request('CurrentInvoice_GetDataArray', nil, :multiple)
81
78
  results = subject.find_by_date_interval(from, unto)
82
- results.size.should == 2
83
- results.first.should be_instance_of(Economic::CurrentInvoice)
79
+ expect(results.size).to eq(2)
80
+ expect(results.first).to be_instance_of(Economic::CurrentInvoice)
84
81
  end
85
82
 
86
83
  it "should be able to return nothing" do
87
- savon.expects('CurrentInvoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601).returns(:none)
84
+ mock_request('CurrentInvoice_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :none)
88
85
  results = subject.find_by_date_interval(from, unto)
89
- results.size.should == 0
86
+ expect(results.size).to eq(0)
90
87
  end
91
88
 
92
89
  end
@@ -94,29 +91,29 @@ describe Economic::CurrentInvoiceProxy do
94
91
  describe ".all" do
95
92
 
96
93
  it "returns an empty array when there are no current invoices" do
97
- savon.expects('CurrentInvoice_GetAll').returns(:none)
98
- subject.all.size.should == 0
94
+ stub_request('CurrentInvoice_GetAll', nil, :none)
95
+ expect(subject.all.size).to eq(0)
99
96
  end
100
97
 
101
98
  it "finds and adds a single current invoice" do
102
- savon.expects('CurrentInvoice_GetAll').returns(:single)
103
- savon.expects('CurrentInvoice_GetData').with('entityHandle' => {'Id' => 1}).returns(:success)
99
+ stub_request('CurrentInvoice_GetAll', nil, :single)
100
+ mock_request('CurrentInvoice_GetData', {'entityHandle' => {'Id' => 1}}, :success)
104
101
 
105
102
  current_invoices = subject.all
106
- current_invoices.should be_instance_of(Economic::CurrentInvoiceProxy)
103
+ expect(current_invoices).to be_instance_of(Economic::CurrentInvoiceProxy)
107
104
 
108
- current_invoices.size.should == 1
109
- current_invoices.first.should be_instance_of(Economic::CurrentInvoice)
105
+ expect(current_invoices.size).to eq(1)
106
+ expect(current_invoices.first).to be_instance_of(Economic::CurrentInvoice)
110
107
  end
111
108
 
112
109
  it "adds multiple current invoices" do
113
- savon.expects('CurrentInvoice_GetAll').returns(:multiple)
114
- savon.expects('CurrentInvoice_GetDataArray').returns(:multiple)
110
+ stub_request('CurrentInvoice_GetAll', nil, :multiple)
111
+ stub_request('CurrentInvoice_GetDataArray', nil, :multiple)
115
112
 
116
113
  current_invoices = subject.all
117
- current_invoices.size.should == 2
118
- current_invoices.first.should be_instance_of(Economic::CurrentInvoice)
119
- current_invoices.last.should be_instance_of(Economic::CurrentInvoice)
114
+ expect(current_invoices.size).to eq(2)
115
+ expect(current_invoices.first).to be_instance_of(Economic::CurrentInvoice)
116
+ expect(current_invoices.last).to be_instance_of(Economic::CurrentInvoice)
120
117
  end
121
118
 
122
119
  end