rews 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
data/lib/rews/item.rb CHANGED
@@ -4,6 +4,7 @@ module Rews
4
4
 
5
5
  # return a list of Item objects given a hash formed from an Items element
6
6
  def read_items(client, items)
7
+ return [] if !items
7
8
  items.map do |item_class,items_of_class|
8
9
  items_of_class = [items_of_class] if !items_of_class.is_a?(Array)
9
10
  items_of_class.map do |item|
@@ -154,6 +154,19 @@ module Rews
154
154
 
155
155
  end
156
156
 
157
+ it "should parse a response with no folders" do
158
+ client = Object.new
159
+ folders = test_find_folder(client,
160
+ {:base_shape=>:IdOnly},
161
+ nil,
162
+ nil,
163
+ {:includes_last_item_in_range=>false,
164
+ :indexed_paging_offset=>0,
165
+ :total_items_in_view=>0,
166
+ :folders=>nil})
167
+ folders.result.should == []
168
+ end
169
+
157
170
  it "should generate xml with indexed_page_folder_view and parse a response with multiple folders" do
158
171
  client = Object.new
159
172
  folders = test_find_folder(client,
@@ -223,6 +236,21 @@ module Rews
223
236
  end
224
237
 
225
238
  describe "find_item" do
239
+ it "should parse a response with no items" do
240
+ client = Object.new
241
+ items = test_find_item(client,
242
+ {:base_shape=>:IdOnly},
243
+ nil,
244
+ nil,
245
+ {:includes_last_item_in_range=>false,
246
+ :indexed_paging_offset=>10,
247
+ :total_items_in_view=>0,
248
+ :items=>nil})
249
+ items.indexed_paging_offset.should == 10
250
+ items.total_items_in_view.should == 0
251
+ items.result.should == []
252
+ end
253
+
226
254
  it "should generate minimal xml and parse a response with one item" do
227
255
  client = Object.new
228
256
  items = test_find_item(client,
@@ -2,6 +2,66 @@ require File.expand_path("../../spec_helper", __FILE__)
2
2
 
3
3
  module Rews
4
4
  describe Item do
5
+ describe "read_items" do
6
+ it "should parse a list of zero items correctly" do
7
+ c = Object.new
8
+ items = Item.read_items(c, nil)
9
+ items.should == []
10
+ end
11
+
12
+ it "should parse a list of one items correctly" do
13
+ c = Object.new
14
+ items = Item.read_items(c, {:message=>{:item_id=>{:id=>"abc", :change_key=>"def"}}})
15
+ items.length.should == 1
16
+ item = items.first
17
+ item.item_id.should == Item::ItemId.new(c, {:id=>"abc", :change_key=>"def"})
18
+ item.item_class.should == :message
19
+ end
20
+
21
+ it "should parse a list of more than one item correctly" do
22
+ c = Object.new
23
+ items = Item.read_items(c, {:message=>[{:item_id=>{:id=>"abc", :change_key=>"def"}},
24
+ {:item_id=>{:id=>"ghi", :change_key=>"jkl"}}]})
25
+ items.length.should == 2
26
+ item1 = items.first
27
+ item1.item_id.should == Item::ItemId.new(c, {:id=>"abc", :change_key=>"def"})
28
+ item1.item_class.should == :message
29
+ item2 = items.last
30
+ item2.item_id.should == Item::ItemId.new(c, {:id=>"ghi", :change_key=>"jkl"})
31
+ item2.item_class.should == :message
32
+ end
33
+ end
34
+
35
+ describe "read_get_item_response_messages" do
36
+ it "should parse a list of zero items correctly" do
37
+ c = Object.new
38
+ items = Item.read_get_item_response_messages(c, {:items=>nil})
39
+ items.should == []
40
+ end
41
+
42
+ it "should parse a list of one items correctly" do
43
+ c = Object.new
44
+ items = Item.read_get_item_response_messages(c, {:items=>{:message=>{:item_id=>{:id=>"abc", :change_key=>"def"}}}})
45
+ items.length.should == 1
46
+ item = items.first
47
+ item.item_id.should == Item::ItemId.new(c, {:id=>"abc", :change_key=>"def"})
48
+ item.item_class.should == :message
49
+ end
50
+
51
+ it "should parse a list of more than one items correctly" do
52
+ c = Object.new
53
+ items = Item.read_get_item_response_messages(c, {:items=>{:message=>[{:item_id=>{:id=>"abc", :change_key=>"def"}},
54
+ {:item_id=>{:id=>"ghi", :change_key=>"jkl"}}]}})
55
+ items.length.should == 2
56
+ item1 = items.first
57
+ item1.item_id.should == Item::ItemId.new(c, {:id=>"abc", :change_key=>"def"})
58
+ item1.item_class.should == :message
59
+ item2 = items.last
60
+ item2.item_id.should == Item::ItemId.new(c, {:id=>"ghi", :change_key=>"jkl"})
61
+ item2.item_class.should == :message
62
+ end
63
+ end
64
+
5
65
  describe Item::Item do
6
66
  it "should parse the item_id and attributes from the XML hash" do
7
67
  client = Object.new
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rews
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Trampoline Systems Ltd
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-21 00:00:00 +00:00
18
+ date: 2011-03-22 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency