rews 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.
@@ -0,0 +1,36 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ module Rews
4
+ describe Shape do
5
+ describe Shape::FolderShape do
6
+ it "should write FolderShape xml" do
7
+ xml = Shape::FolderShape.new(:base_shape=>:IdOnly,
8
+ :additional_properties=>[[:field_uri, "folder:FolderId"],
9
+ [:field_uri, "folder:TotalCount"]]).to_xml
10
+
11
+ doc = Nokogiri::XML(xml)
12
+ fs = doc.children.first
13
+ fs.name.should == "FolderShape"
14
+ fs.children.size.should == 2
15
+
16
+ bs = fs.children.first
17
+ bs.name.should == "BaseShape"
18
+ bs.content.should == "IdOnly"
19
+
20
+ ap = fs.children[1]
21
+ ap.name.should == "AdditionalProperties"
22
+ ap.children.size.should == 2
23
+
24
+ fid = ap.children.first
25
+ fid.name.should == "FieldURI"
26
+ fid[:FieldURI].should == "folder:FolderId"
27
+ fid.children.size.should == 0
28
+
29
+ ftot = ap.children[1]
30
+ ftot.name.should == "FieldURI"
31
+ ftot[:FieldURI].should == "folder:TotalCount"
32
+ ftot.children.size.should == 0
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,56 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ module Rews
4
+ describe "SortOrder" do
5
+ it "should write a single sort order" do
6
+ xml = SortOrder.new([["item:DateTimeReceived", "Ascending"]]).to_xml
7
+
8
+ doc = Nokogiri::XML(xml)
9
+ doc.children.size.should == 1
10
+
11
+ so = doc.children.first
12
+ so.name.should == "SortOrder"
13
+ so.children.size.should == 1
14
+
15
+ fo = so.children.first
16
+ fo.name.should == "FieldOrder"
17
+ fo[:Order].should == "Ascending"
18
+ fo.children.size.should == 1
19
+
20
+ furi = fo.children.first
21
+ furi.name.should == "FieldURI"
22
+ furi[:FieldURI].should == "item:DateTimeReceived"
23
+ end
24
+
25
+ it "should write multiple sort orders" do
26
+ xml = SortOrder.new([["item:DateTimeReceived", "Ascending"],
27
+ ["message:InternetMessageId", "Descending"]]).to_xml
28
+
29
+ doc = Nokogiri::XML(xml)
30
+ doc.children.size.should == 1
31
+
32
+ so = doc.children.first
33
+ so.name.should == "SortOrder"
34
+ so.children.size.should == 2
35
+
36
+ fo = so.children.first
37
+ fo.name.should == "FieldOrder"
38
+ fo[:Order].should == "Ascending"
39
+ fo.children.size.should == 1
40
+
41
+ furi = fo.children.first
42
+ furi.name.should == "FieldURI"
43
+ furi[:FieldURI].should == "item:DateTimeReceived"
44
+
45
+ fo2 = so.children.last
46
+ fo2.name.should == "FieldOrder"
47
+ fo2[:Order].should == "Descending"
48
+ fo2.children.size.should == 1
49
+
50
+ furi2 = fo2.children.first
51
+ furi2.name.should == "FieldURI"
52
+ furi2[:FieldURI].should == "message:InternetMessageId"
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,103 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ module Rews
4
+ describe Util do
5
+ describe "strip_bang" do
6
+ it "should strip the bang from the end of a String" do
7
+ Util.strip_bang("foo!").should == "foo"
8
+ end
9
+
10
+ it "should strip the bank from the end of a Symbol" do
11
+ Util.strip_bang(:foo! ).should == :foo
12
+ end
13
+ end
14
+
15
+ describe "camelize" do
16
+ it "should camelize a String" do
17
+ Util.camelize("foo_bar").should == "FooBar"
18
+ end
19
+ end
20
+
21
+ describe "camel_keys" do
22
+ it "should camelize the keys of a Hash" do
23
+ Util.camel_keys(:foo_bar=>1, "bar_baz"=>2, "bam"=>3).should ==
24
+ {"FooBar"=>1, "BarBaz"=>2, "Bam"=>3}
25
+ end
26
+ end
27
+
28
+ describe "with_error_check" do
29
+ it "should yield, convert the response to a hash and fetch_in the status" do
30
+ client = Object.new
31
+ Util.with_error_check(client, :foo, :bar) do
32
+ response_hash = {:foo=>{:bar=>{:response_class=>"Success"}}}
33
+ response = Object.new
34
+ mock(response).to_hash{response_hash}
35
+ response
36
+ end
37
+ end
38
+
39
+ it "should raise if there are any errors" do
40
+ client = Object.new
41
+ lambda {
42
+ Util.with_error_check(client, :foo, :bar) do
43
+ response_hash = {:foo=>{:bar=>{:response_class=>"Error", :message_text=>"boo"}}}
44
+ response = Object.new
45
+ mock(response).to_hash{response_hash}
46
+ response
47
+ end
48
+ }.should raise_error
49
+ end
50
+ end
51
+
52
+ describe "single_error_check" do
53
+ it "should return an error description of the response_class is Error" do
54
+ client = Object.new
55
+ status = {:response_class=>"Error", :message_text=>"boo", :response_code=>"BooError"}
56
+ Util.single_error_check(client, status).should == "BooError - boo"
57
+ end
58
+
59
+ it "should log a warning and return if the response_class is Warning" do
60
+ client = Object.new
61
+ status = {:response_class=>"Warning", :message_text=>"boo", :response_code=>"BooWarning"}
62
+ mock(client).log() do |p|
63
+ logger = Object.new
64
+ mock(logger).warn("BooWarning - boo")
65
+ p.call(logger)
66
+ end
67
+ Util.single_error_check(client, status).should == nil
68
+ end
69
+
70
+ it "should return if the response_class is Success" do
71
+ client = Object.new
72
+ status = {:response_class=>"Success", :message_text=>nil, :response_code=>"Blah"}
73
+ Util.single_error_check(client, status).should == nil
74
+ end
75
+ end
76
+
77
+ describe "check_opts" do
78
+ it "should raise if given an unknown option" do
79
+ lambda {
80
+ Util.check_opts({:foo=>nil}, {:foo=>1, :bar=>10})
81
+ }.should raise_error(RuntimeError, /unknown option:.*bar/)
82
+ end
83
+
84
+ it "should fill in a default" do
85
+ Util.check_opts({:foo=>10}, {}).should == {:foo=>10}
86
+ end
87
+
88
+ it "should not fill in a key if nil value given" do
89
+ Util.check_opts({:foo=>nil}, {}).should == {}
90
+ end
91
+
92
+ it "should raise an error if a bang-suffixed option is not given" do
93
+ lambda {
94
+ Util.check_opts({:foo! =>nil}, {})
95
+ }.should raise_error(RuntimeError, /required options not given:.*foo/)
96
+ end
97
+
98
+ it "should check_opts on sub-hashes if constraints sub-hashes given" do
99
+ Util.check_opts({:foo=>{:bar=>10}}, {:foo=>{}}).should == {:foo=>{:bar=>10}}
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ module Rews
4
+ describe View do
5
+ describe View::IndexedPageItemView do
6
+ it "should write IndexedPageItemView xml" do
7
+ xml = View::IndexedPageItemView.new(:max_entries_returned=>10,
8
+ :offset=>10,
9
+ :base_point=>:End).to_xml
10
+
11
+ doc = Nokogiri::XML(xml)
12
+ ipiv = doc.children.first
13
+ ipiv.name.should == "IndexedPageItemView"
14
+ ipiv[:MaxEntriesReturned].should == "10"
15
+ ipiv[:Offset].should == "10"
16
+ ipiv[:BasePoint].should == "End"
17
+ end
18
+ end
19
+
20
+ describe View::IndexedPageFolderView do
21
+ it "should write an IndexedPageFolderView" do
22
+ xml = View::IndexedPageFolderView.new(:max_entries_returned=>10,
23
+ :offset=>10,
24
+ :base_point=>:End).to_xml
25
+
26
+ doc = Nokogiri::XML(xml)
27
+ ipiv = doc.children.first
28
+ ipiv.name.should == "IndexedPageFolderView"
29
+ ipiv[:MaxEntriesReturned].should == "10"
30
+ ipiv[:Offset].should == "10"
31
+ ipiv[:BasePoint].should == "End"
32
+ end
33
+ end
34
+ end
35
+ end
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,8 @@ require 'rews'
5
5
  require 'spec'
6
6
  require 'spec/autorun'
7
7
  require 'rr'
8
+ require 'nokogiri'
9
+ require 'request_proxy'
8
10
 
9
11
  Spec::Runner.configure do |config|
10
12
  config.mock_with RR::Adapters::Rspec
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: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
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-14 00:00:00 +00:00
18
+ date: 2011-03-16 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,12 +42,13 @@ dependencies:
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 25
45
+ hash: 65
46
46
  segments:
47
47
  - 0
48
48
  - 1
49
49
  - 1
50
- version: 0.1.1
50
+ - 1
51
+ version: 0.1.1.1
51
52
  type: :runtime
52
53
  version_requirements: *id002
53
54
  - !ruby/object:Gem::Dependency
@@ -116,6 +117,22 @@ dependencies:
116
117
  version: 0.10.5
117
118
  type: :development
118
119
  version_requirements: *id006
120
+ - !ruby/object:Gem::Dependency
121
+ name: nokogiri
122
+ prerelease: false
123
+ requirement: &id007 !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 15
129
+ segments:
130
+ - 1
131
+ - 4
132
+ - 4
133
+ version: 1.4.4
134
+ type: :development
135
+ version_requirements: *id007
119
136
  description: an email focussed Ruby client for Exchange Web Services atop Savon
120
137
  email: craig@trampolinesystems.com
121
138
  executables: []
@@ -132,6 +149,7 @@ files:
132
149
  - Rakefile
133
150
  - VERSION
134
151
  - lib/rews.rb
152
+ - lib/rews/client.rb
135
153
  - lib/rews/folder.rb
136
154
  - lib/rews/item.rb
137
155
  - lib/rews/restriction.rb
@@ -139,7 +157,15 @@ files:
139
157
  - lib/rews/sort_order.rb
140
158
  - lib/rews/util.rb
141
159
  - lib/rews/view.rb
142
- - spec/rews_spec.rb
160
+ - spec/request_proxy.rb
161
+ - spec/rews/client_spec.rb
162
+ - spec/rews/folder_spec.rb
163
+ - spec/rews/item_spec.rb
164
+ - spec/rews/restriction_spec.rb
165
+ - spec/rews/shape_spec.rb
166
+ - spec/rews/sort_order_spec.rb
167
+ - spec/rews/util_spec.rb
168
+ - spec/rews/view_spec.rb
143
169
  - spec/spec.opts
144
170
  - spec/spec_helper.rb
145
171
  has_rdoc: true
@@ -172,10 +198,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
198
  requirements: []
173
199
 
174
200
  rubyforge_project:
175
- rubygems_version: 1.5.2
201
+ rubygems_version: 1.6.2
176
202
  signing_key:
177
203
  specification_version: 3
178
204
  summary: a Ruby client for Exchange Web Services
179
205
  test_files:
180
- - spec/rews_spec.rb
206
+ - spec/request_proxy.rb
207
+ - spec/rews/client_spec.rb
208
+ - spec/rews/folder_spec.rb
209
+ - spec/rews/item_spec.rb
210
+ - spec/rews/restriction_spec.rb
211
+ - spec/rews/shape_spec.rb
212
+ - spec/rews/sort_order_spec.rb
213
+ - spec/rews/util_spec.rb
214
+ - spec/rews/view_spec.rb
181
215
  - spec/spec_helper.rb
data/spec/rews_spec.rb DELETED
@@ -1,4 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Rews do
4
- end