freeagent 0.1.0 → 0.2.0

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 (42) hide show
  1. data/CHANGELOG.rdoc +17 -0
  2. data/Gemfile.lock +12 -10
  3. data/README.rdoc +13 -1
  4. data/TODO +22 -0
  5. data/freeagent.gemspec +4 -3
  6. data/lib/free_agent.rb +1 -0
  7. data/lib/free_agent/base.rb +132 -0
  8. data/lib/free_agent/contact.rb +68 -0
  9. data/lib/free_agent/invoice.rb +58 -0
  10. data/lib/free_agent/project.rb +20 -0
  11. data/lib/free_agent/task.rb +10 -0
  12. data/lib/free_agent/version.rb +1 -1
  13. data/spec/fixtures/bank_accounts/all.xml +24 -19
  14. data/spec/fixtures/bank_accounts/single.xml +6 -6
  15. data/spec/fixtures/contacts/all.xml +13 -13
  16. data/spec/fixtures/contacts/all_filter_all.xml +69 -0
  17. data/spec/fixtures/contacts/invoices.xml +75 -0
  18. data/spec/fixtures/contacts/single.xml +6 -6
  19. data/spec/fixtures/estimates/all.xml +38 -0
  20. data/spec/fixtures/expenses/all.xml +93 -0
  21. data/spec/fixtures/expenses/single.xml +31 -0
  22. data/spec/fixtures/expenses/single_with_project_id.xml +31 -0
  23. data/spec/fixtures/invoices/all.xml +112 -75
  24. data/spec/fixtures/invoices/single.xml +38 -37
  25. data/spec/fixtures/projects/invoices.xml +39 -0
  26. data/spec/fixtures/projects/single.xml +2 -2
  27. data/spec/fixtures/projects/tasks.xml +30 -0
  28. data/spec/fixtures/projects/timeslips.xml +25 -0
  29. data/spec/fixtures/tasks/single.xml +10 -0
  30. data/spec/fixtures/timeslips/all.xml +25 -0
  31. data/spec/fixtures/timeslips/single.xml +12 -0
  32. data/spec/spec_helper.rb +1 -1
  33. data/spec/support/helper.rb +4 -4
  34. data/spec/support/mimic.rb +40 -25
  35. data/spec/unit/bank_account_spec.rb +1 -1
  36. data/spec/unit/base_spec.rb +113 -0
  37. data/spec/unit/contact_spec.rb +87 -1
  38. data/spec/unit/invoice_item_spec.rb +1 -1
  39. data/spec/unit/invoice_spec.rb +48 -2
  40. data/spec/unit/project_spec.rb +34 -0
  41. data/spec/unit/task_spec.rb +77 -0
  42. metadata +45 -7
@@ -53,4 +53,38 @@ describe FreeAgent::Project do
53
53
  end
54
54
  end
55
55
 
56
+ describe "#invoices" do
57
+ it "merges the finder options" do
58
+ mock(FreeAgent::Invoice).all(:from => '/projects/0/invoices.xml')
59
+ FreeAgent::Project.new(:id => 0).invoices
60
+
61
+ mock(FreeAgent::Invoice).all(:from => '/projects/0/invoices.xml', :params => { :foo => 'bar' })
62
+ FreeAgent::Project.new(:id => 0).invoices(:params => { :foo => 'bar' })
63
+ end
64
+
65
+ context "when the project exists" do
66
+ before(:each) do
67
+ @invoices = FreeAgent::Project.new(:id => 2).invoices
68
+ end
69
+
70
+ it "returns an array" do
71
+ @invoices.should be_a(Array)
72
+ end
73
+
74
+ it "returns the invoices" do
75
+ @invoices.should have(1).records
76
+ @invoices.first.should be_a(FreeAgent::Invoice)
77
+ end
78
+ end
79
+
80
+ context "when the project does not exist" do
81
+ it "raises a ResourceNotFound error" do
82
+ pending 'ActiveResource rescues the error and returns nil'
83
+ lambda do
84
+ FreeAgent::Project.new(:id => 1).invoices
85
+ end.should raise_error(ActiveResource::ResourceNotFound)
86
+ end
87
+ end
88
+ end
89
+
56
90
  end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe FreeAgent::Task do
4
+
5
+ it "extends FreeAgent::Base" do
6
+ klass.superclass.should == FreeAgent::Base
7
+ end
8
+
9
+ describe "paths" do
10
+ it "has correct collection path" do
11
+ FreeAgent::Task.collection_path(:project_id => 1).should == '/projects/1/tasks.xml'
12
+ end
13
+
14
+ it "has correct element path" do
15
+ FreeAgent::Task.element_path(:first, :project_id => 1).should == '/projects/1/tasks/first.xml'
16
+ FreeAgent::Task.element_path(100000, :project_id => 1).should == '/projects/1/tasks/100000.xml'
17
+ end
18
+ end
19
+
20
+
21
+ context "when the project exists" do
22
+ describe ".all" do
23
+ before(:each) do
24
+ @tasks = FreeAgent::Task.all(:params => { :project_id => 2 })
25
+ end
26
+
27
+ it "returns an array" do
28
+ @tasks.should be_a(Array)
29
+ end
30
+
31
+ it "returns the tasks" do
32
+ @tasks.should have(3).records
33
+ @tasks.first.should be_a(FreeAgent::Task)
34
+ end
35
+ end
36
+
37
+ describe ".find(id)" do
38
+ context "when the record exists" do
39
+ before(:each) do
40
+ @task = FreeAgent::Task.find(2, :params => { :project_id => 2 })
41
+ end
42
+
43
+ it "returns a task" do
44
+ @task.should be_a(FreeAgent::Task)
45
+ end
46
+ end
47
+
48
+ context "when the record does not exist" do
49
+ it "raises a ResourceNotFound error" do
50
+ lambda do
51
+ FreeAgent::Task.find(1, :params => { :project_id => 2 })
52
+ end.should raise_error(ActiveResource::ResourceNotFound)
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ context "when the project does not exist" do
59
+ describe ".all" do
60
+ it "raises a ResourceNotFound error" do
61
+ pending 'ActiveResource rescues the error and returns nil'
62
+ lambda do
63
+ FreeAgent::Task.all(:params => { :project_id => 1 })
64
+ end.should raise_error(ActiveResource::ResourceNotFound)
65
+ end
66
+ end
67
+
68
+ describe ".find(id)" do
69
+ it "raises a ResourceNotFound error" do
70
+ lambda do
71
+ FreeAgent::Task.find(1, :params => { :project_id => 1 })
72
+ end.should raise_error(ActiveResource::ResourceNotFound)
73
+ end
74
+ end
75
+ end
76
+
77
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: freeagent
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Simone Carletti
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-12 00:00:00 Z
13
+ date: 2011-05-24 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -56,7 +56,18 @@ dependencies:
56
56
  version: "0"
57
57
  type: :development
58
58
  version_requirements: *id004
59
- description: ""
59
+ - !ruby/object:Gem::Dependency
60
+ name: rr
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ version_requirements: *id005
70
+ description: Ruby client for the FreeAgent API.
60
71
  email:
61
72
  - weppos@weppos.net
62
73
  executables: []
@@ -74,6 +85,7 @@ files:
74
85
  - LICENSE
75
86
  - README.rdoc
76
87
  - Rakefile
88
+ - TODO
77
89
  - freeagent.gemspec
78
90
  - lib/free_agent.rb
79
91
  - lib/free_agent/attachment.rb
@@ -84,6 +96,7 @@ files:
84
96
  - lib/free_agent/invoice.rb
85
97
  - lib/free_agent/invoice_item.rb
86
98
  - lib/free_agent/project.rb
99
+ - lib/free_agent/task.rb
87
100
  - lib/free_agent/version.rb
88
101
  - lib/freeagent.rb
89
102
  - spec/fixtures/attachments/all.xml
@@ -93,13 +106,25 @@ files:
93
106
  - spec/fixtures/bills/all.xml
94
107
  - spec/fixtures/bills/single.xml
95
108
  - spec/fixtures/contacts/all.xml
109
+ - spec/fixtures/contacts/all_filter_all.xml
110
+ - spec/fixtures/contacts/invoices.xml
96
111
  - spec/fixtures/contacts/single.xml
112
+ - spec/fixtures/estimates/all.xml
113
+ - spec/fixtures/expenses/all.xml
114
+ - spec/fixtures/expenses/single.xml
115
+ - spec/fixtures/expenses/single_with_project_id.xml
97
116
  - spec/fixtures/invoice_items/all.xml
98
117
  - spec/fixtures/invoice_items/single.xml
99
118
  - spec/fixtures/invoices/all.xml
100
119
  - spec/fixtures/invoices/single.xml
101
120
  - spec/fixtures/projects/all.xml
121
+ - spec/fixtures/projects/invoices.xml
102
122
  - spec/fixtures/projects/single.xml
123
+ - spec/fixtures/projects/tasks.xml
124
+ - spec/fixtures/projects/timeslips.xml
125
+ - spec/fixtures/tasks/single.xml
126
+ - spec/fixtures/timeslips/all.xml
127
+ - spec/fixtures/timeslips/single.xml
103
128
  - spec/spec_helper.rb
104
129
  - spec/support/helper.rb
105
130
  - spec/support/mimic.rb
@@ -112,7 +137,8 @@ files:
112
137
  - spec/unit/invoice_item_spec.rb
113
138
  - spec/unit/invoice_spec.rb
114
139
  - spec/unit/project_spec.rb
115
- homepage: ""
140
+ - spec/unit/task_spec.rb
141
+ homepage: https://github.com/weppos/freeagent
116
142
  licenses: []
117
143
 
118
144
  post_install_message:
@@ -135,10 +161,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
161
  requirements: []
136
162
 
137
163
  rubyforge_project:
138
- rubygems_version: 1.7.2
164
+ rubygems_version: 1.8.2
139
165
  signing_key:
140
166
  specification_version: 3
141
- summary: ""
167
+ summary: Ruby client for the FreeAgent API.
142
168
  test_files:
143
169
  - spec/fixtures/attachments/all.xml
144
170
  - spec/fixtures/attachments/single.xml
@@ -147,13 +173,25 @@ test_files:
147
173
  - spec/fixtures/bills/all.xml
148
174
  - spec/fixtures/bills/single.xml
149
175
  - spec/fixtures/contacts/all.xml
176
+ - spec/fixtures/contacts/all_filter_all.xml
177
+ - spec/fixtures/contacts/invoices.xml
150
178
  - spec/fixtures/contacts/single.xml
179
+ - spec/fixtures/estimates/all.xml
180
+ - spec/fixtures/expenses/all.xml
181
+ - spec/fixtures/expenses/single.xml
182
+ - spec/fixtures/expenses/single_with_project_id.xml
151
183
  - spec/fixtures/invoice_items/all.xml
152
184
  - spec/fixtures/invoice_items/single.xml
153
185
  - spec/fixtures/invoices/all.xml
154
186
  - spec/fixtures/invoices/single.xml
155
187
  - spec/fixtures/projects/all.xml
188
+ - spec/fixtures/projects/invoices.xml
156
189
  - spec/fixtures/projects/single.xml
190
+ - spec/fixtures/projects/tasks.xml
191
+ - spec/fixtures/projects/timeslips.xml
192
+ - spec/fixtures/tasks/single.xml
193
+ - spec/fixtures/timeslips/all.xml
194
+ - spec/fixtures/timeslips/single.xml
157
195
  - spec/spec_helper.rb
158
196
  - spec/support/helper.rb
159
197
  - spec/support/mimic.rb
@@ -166,4 +204,4 @@ test_files:
166
204
  - spec/unit/invoice_item_spec.rb
167
205
  - spec/unit/invoice_spec.rb
168
206
  - spec/unit/project_spec.rb
169
- has_rdoc:
207
+ - spec/unit/task_spec.rb