googlecontacts 0.1.8 → 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.
- data/.gitignore +4 -0
- data/Gemfile +9 -0
- data/LICENSE +1 -1
- data/Rakefile +4 -47
- data/googlecontacts.gemspec +23 -0
- data/lib/google_contacts.rb +13 -15
- data/lib/google_contacts/auth.rb +5 -5
- data/lib/google_contacts/base.rb +38 -30
- data/lib/google_contacts/contact.rb +16 -5
- data/lib/google_contacts/group.rb +4 -2
- data/lib/google_contacts/proxies/emails.rb +15 -8
- data/lib/google_contacts/proxies/hash.rb +2 -2
- data/lib/google_contacts/proxies/tag.rb +1 -1
- data/lib/google_contacts/version.rb +3 -0
- data/lib/google_contacts/wrapper.rb +16 -16
- data/lib/googlecontacts.rb +1 -1
- data/spec/base_spec.rb +35 -35
- data/spec/contact_spec.rb +30 -30
- data/spec/group_spec.rb +5 -5
- data/spec/proxies/array_spec.rb +19 -19
- data/spec/proxies/emails_spec.rb +54 -52
- data/spec/proxies/hash_spec.rb +14 -14
- data/spec/proxies/tag_spec.rb +9 -8
- data/spec/spec_helper.rb +8 -15
- data/spec/wrapper_spec.rb +25 -25
- metadata +43 -88
- data/VERSION +0 -1
- data/spec/spec.opts +0 -2
@@ -17,7 +17,7 @@ module GoogleContacts
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def get(url, options = {})
|
20
|
-
query = options.map { |k,v| "#{k}=#{v}" }.join(
|
20
|
+
query = options.map { |k,v| "#{k}=#{v}" }.join("&")
|
21
21
|
url += "?#{query}" if query.size > 0
|
22
22
|
|
23
23
|
body = consumer.get(url).body
|
@@ -25,7 +25,7 @@ module GoogleContacts
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def post(url, body)
|
28
|
-
consumer.post(url, body,
|
28
|
+
consumer.post(url, body, "Content-Type" => "application/atom+xml")
|
29
29
|
end
|
30
30
|
|
31
31
|
def batch(options = {}, &blk)
|
@@ -52,19 +52,19 @@ module GoogleContacts
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def find(what, options = {}, &blk)
|
55
|
-
options[
|
56
|
-
options[
|
55
|
+
options["max-results"] ||= 200
|
56
|
+
options["start-index"] = 1
|
57
57
|
|
58
58
|
result = []
|
59
59
|
begin
|
60
60
|
xml = get("http://www.google.com/m8/feeds/#{what}/default/full", options)
|
61
|
-
result.concat xml.xpath(
|
61
|
+
result.concat xml.xpath("/xmlns:feed/xmlns:entry").map(&blk)
|
62
62
|
|
63
|
-
total_results = xml.at(
|
64
|
-
start_index = xml.at(
|
65
|
-
per_page = xml.at(
|
66
|
-
options[
|
67
|
-
end while (options[
|
63
|
+
total_results = xml.at("//openSearch:totalResults").text.to_i
|
64
|
+
start_index = xml.at("//openSearch:startIndex" ).text.to_i
|
65
|
+
per_page = xml.at("//openSearch:itemsPerPage").text.to_i
|
66
|
+
options["start-index"] = start_index + per_page
|
67
|
+
end while (options["start-index"] <= total_results)
|
68
68
|
|
69
69
|
result
|
70
70
|
end
|
@@ -78,9 +78,9 @@ module GoogleContacts
|
|
78
78
|
|
79
79
|
def append_to_batch(entry)
|
80
80
|
if @batching
|
81
|
-
if @batch.
|
82
|
-
batch_term = @batch.last.at(
|
83
|
-
entry_term = entry.at(
|
81
|
+
if @batch.length > 0
|
82
|
+
batch_term = @batch.last.at("./atom:category")["term"]
|
83
|
+
entry_term = entry.at("./atom:category")["term"]
|
84
84
|
raise "Cannot mix Contact and Group in one batch" if batch_term != entry_term
|
85
85
|
end
|
86
86
|
|
@@ -93,9 +93,9 @@ module GoogleContacts
|
|
93
93
|
end
|
94
94
|
|
95
95
|
# Use the <category/> tag of the first entry to find out
|
96
|
-
# which type we
|
96
|
+
# which type we"re flushing
|
97
97
|
def flush_batch(document)
|
98
|
-
url = case document.at(
|
98
|
+
url = case document.at("./xmlns:entry[1]/xmlns:category")["term"]
|
99
99
|
when /#contact$/i
|
100
100
|
CONTACTS_BATCH
|
101
101
|
when /#group$/i
|
@@ -118,7 +118,7 @@ module GoogleContacts
|
|
118
118
|
def initialize(wrapper, klass)
|
119
119
|
@wrapper = wrapper
|
120
120
|
@klass = klass
|
121
|
-
@collection = klass.name.
|
121
|
+
@collection = klass.name.split("::").last.downcase + "s"
|
122
122
|
end
|
123
123
|
|
124
124
|
# :what - all, ID, whatever, currently unused
|
data/lib/googlecontacts.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# For convenience
|
2
|
-
require
|
2
|
+
require "google_contacts"
|
data/spec/base_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
class GoogleContacts::BaseTester < GoogleContacts::Base
|
4
|
-
CATEGORY_TERM =
|
4
|
+
CATEGORY_TERM = %{i'm not used here}
|
5
5
|
end
|
6
6
|
|
7
7
|
describe GoogleContacts::Base do
|
8
8
|
it "should not be possible to create" do
|
9
9
|
lambda {
|
10
|
-
GoogleContacts::Base.new(wrapper,
|
10
|
+
GoogleContacts::Base.new(wrapper, "some xml")
|
11
11
|
}.should raise_error(/cannot create instance/i)
|
12
12
|
end
|
13
13
|
|
@@ -17,38 +17,38 @@ describe GoogleContacts::Base do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should default namespace to document default" do
|
20
|
-
node = @t.insert_xml
|
21
|
-
node.namespace.href.should ==
|
22
|
-
@t.xml.xpath(
|
20
|
+
node = @t.insert_xml "tag"
|
21
|
+
node.namespace.href.should == "http://www.w3.org/2005/Atom"
|
22
|
+
@t.xml.xpath("atom:tag").should have(1).node
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should set namespace when specified in tag" do
|
26
|
-
node = @t.insert_xml
|
27
|
-
node.namespace.href.should ==
|
28
|
-
@t.xml.xpath(
|
26
|
+
node = @t.insert_xml "gd:extendedProperty"
|
27
|
+
node.namespace.href.should == "http://schemas.google.com/g/2005"
|
28
|
+
@t.xml.xpath("gd:extendedProperty").should have(1).node
|
29
29
|
|
30
|
-
node = @t.insert_xml
|
31
|
-
node.namespace.href.should ==
|
32
|
-
@t.xml.xpath(
|
30
|
+
node = @t.insert_xml "gContact:birthday"
|
31
|
+
node.namespace.href.should == "http://schemas.google.com/contact/2008"
|
32
|
+
@t.xml.xpath("gContact:birthday").should have(1).node
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should raise on unknown namespace" do
|
36
36
|
lambda {
|
37
|
-
@t.insert_xml
|
37
|
+
@t.insert_xml "unknown:foo"
|
38
38
|
}.should raise_error(/unknown namespace/i)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should also set attributes if given" do
|
42
|
-
node = @t.insert_xml
|
43
|
-
node[
|
42
|
+
node = @t.insert_xml "tag", :foo => "bar"
|
43
|
+
node["foo"].should == "bar"
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should allow removing xml" do
|
47
|
-
@t.insert_xml
|
48
|
-
@t.xml.xpath(
|
47
|
+
@t.insert_xml "gd:extendedProperty"
|
48
|
+
@t.xml.xpath("./gd:extendedProperty").should have(1).node
|
49
49
|
|
50
|
-
@t.remove_xml
|
51
|
-
@t.xml.xpath(
|
50
|
+
@t.remove_xml "gd:extendedProperty"
|
51
|
+
@t.xml.xpath("./gd:extendedProperty").should have(:no).nodes
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -60,39 +60,39 @@ describe GoogleContacts::Base do
|
|
60
60
|
|
61
61
|
# It is not sane to try and save a default entry
|
62
62
|
it "should not save when an entry is new but has no changed fields" do
|
63
|
-
@entry.
|
64
|
-
@wrapper.
|
63
|
+
@entry.stub(:new? => true, :changed? => false)
|
64
|
+
@wrapper.should_not_receive(:append_operation)
|
65
65
|
@entry.save
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should save when an entry is new and has changed fields" do
|
69
|
-
@entry.
|
70
|
-
@wrapper.
|
69
|
+
@entry.stub(:new? => true, :changed? => true)
|
70
|
+
@wrapper.should_receive(:append_operation).with(@entry, :insert)
|
71
71
|
@entry.save
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should save when an entry has changed fields" do
|
75
|
-
@entry.
|
76
|
-
@wrapper.
|
75
|
+
@entry.stub(:new? => false, :changed? => true)
|
76
|
+
@wrapper.should_receive(:append_operation).with(@entry, :update)
|
77
77
|
@entry.save
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should not delete when an entry is new" do
|
81
|
-
@entry.
|
82
|
-
@wrapper.
|
81
|
+
@entry.stub(:new? => true)
|
82
|
+
@wrapper.should_not_receive(:append_operation)
|
83
83
|
@entry.delete
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should delete when an entry is not new" do
|
87
|
-
@entry.
|
88
|
-
@wrapper.
|
87
|
+
@entry.stub(:new? => false)
|
88
|
+
@wrapper.should_receive(:append_operation).with(@entry, :delete)
|
89
89
|
@entry.delete
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe "prepare for batch operation" do
|
94
94
|
before(:all) do
|
95
|
-
@t = GoogleContacts::BaseTester.new(wrapper, parsed_asset(
|
95
|
+
@t = GoogleContacts::BaseTester.new(wrapper, parsed_asset("contacts_full").at("feed > entry"))
|
96
96
|
@batch = @t.entry_for_batch(:update)
|
97
97
|
end
|
98
98
|
|
@@ -101,15 +101,15 @@ describe GoogleContacts::Base do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should create a duplicate node without link tags" do
|
104
|
-
@batch.xpath(
|
104
|
+
@batch.xpath("./atom:link").should be_empty
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should not touch the category tag" do
|
108
|
-
@batch.xpath(
|
108
|
+
@batch.xpath("./atom:category").should_not be_nil
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should remove the updated tag (not useful when updating)" do
|
112
|
-
@batch.xpath(
|
112
|
+
@batch.xpath("./atom:updated").should be_empty
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should be possible to combine feed_for_batch and entry_for_batch" do
|
@@ -118,9 +118,9 @@ describe GoogleContacts::Base do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should corretly set the batch:operation tag" do
|
121
|
-
%(insert update delete).each do |op|
|
121
|
+
%w(insert update delete).each do |op|
|
122
122
|
batch = @t.entry_for_batch(op.to_sym)
|
123
|
-
batch.at(
|
123
|
+
batch.at("./batch:operation")["type"].should == op
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
data/spec/contact_spec.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe GoogleContacts::Contact do
|
4
4
|
describe "when loaded" do
|
5
5
|
before(:each) do
|
6
|
-
entries = parsed_asset(
|
6
|
+
entries = parsed_asset("contacts_full").search("feed > entry")
|
7
7
|
@contacts = entries.map { |entry| GoogleContacts::Contact.new(wrapper, entry) }
|
8
8
|
@contact = @contacts.first
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should know its href" do
|
12
|
-
@contact.href.should ==
|
12
|
+
@contact.href.should == "http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/c9012de"
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should know when it was updated" do
|
@@ -18,15 +18,15 @@ describe GoogleContacts::Contact do
|
|
18
18
|
|
19
19
|
it "should initialize with groups from xml" do
|
20
20
|
@contact.groups.should have(1).group
|
21
|
-
@contact.groups[0].should ==
|
21
|
+
@contact.groups[0].should == "http://www.google.com/m8/feeds/groups/liz%40gmail.com/base/270f"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should initialize extended properties" do
|
25
|
-
@contact[:pet].should ==
|
25
|
+
@contact[:pet].should == "hamster"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should initialize the title tag" do
|
29
|
-
@contact.title.should ==
|
29
|
+
@contact.title.should == "Fitzwilliam Darcy"
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should not be changed? initially" do
|
@@ -35,24 +35,24 @@ describe GoogleContacts::Contact do
|
|
35
35
|
|
36
36
|
describe "urls" do
|
37
37
|
it "should know its self url" do
|
38
|
-
@contact.url(:self).should ==
|
38
|
+
@contact.url(:self).should == "http://www.google.com/m8/feeds/contacts/liz%40gmail.com/full/c9012de"
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should know its edit url" do
|
42
|
-
@contact.url(:edit).should ==
|
42
|
+
@contact.url(:edit).should == "http://www.google.com/m8/feeds/contacts/liz%40gmail.com/full/c9012de"
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should know its photo url" do
|
46
|
-
@contact.url(:photo).should ==
|
46
|
+
@contact.url(:photo).should == "http://www.google.com/m8/feeds/photos/media/liz%40gmail.com/c9012de"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "updating" do
|
51
51
|
it "should update the title-tag" do
|
52
|
-
@contact.xml.at(
|
53
|
-
@contact.title =
|
52
|
+
@contact.xml.at("./atom:title").content.should == "Fitzwilliam Darcy"
|
53
|
+
@contact.title = "foo"
|
54
54
|
@contact.title.synchronize
|
55
|
-
@contact.xml.at(
|
55
|
+
@contact.xml.at("./atom:title").content.should == "foo"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -64,12 +64,12 @@ describe GoogleContacts::Contact do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should create a new xml root node" do
|
67
|
-
@root.name.should ==
|
68
|
-
@root.namespace.href.should ==
|
67
|
+
@root.name.should == "entry"
|
68
|
+
@root.namespace.href.should == "http://www.w3.org/2005/Atom"
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should set the right category term" do
|
72
|
-
@root.at_xpath(
|
72
|
+
@root.at_xpath("./atom:category")["term"].should == "http://schemas.google.com/contact/2008#contact"
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should not have an href" do
|
@@ -93,23 +93,23 @@ describe GoogleContacts::Contact do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should be possible to set the default email address" do
|
96
|
-
@contact.email =
|
97
|
-
@contact.emails[
|
96
|
+
@contact.email = "foo@bar.com"
|
97
|
+
@contact.emails["foo@bar.com"].should be_primary
|
98
98
|
@contact.emails.size.should == 1
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should provide access to the contact's primary email address" do
|
102
102
|
@contact.email.should be_nil
|
103
|
-
@contact.email =
|
104
|
-
@contact.email.should ==
|
103
|
+
@contact.email = "foo@bar.com"
|
104
|
+
@contact.email.should == "foo@bar.com"
|
105
105
|
end
|
106
106
|
|
107
107
|
describe "when updating" do
|
108
108
|
it "should update the title-tag" do
|
109
|
-
@contact.xml.at(
|
110
|
-
@contact.title =
|
109
|
+
@contact.xml.at("./atom:title").should be_nil
|
110
|
+
@contact.title = "foo"
|
111
111
|
@contact.title.synchronize
|
112
|
-
@contact.xml.at(
|
112
|
+
@contact.xml.at("./atom:title").content.should == "foo"
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -122,32 +122,32 @@ describe GoogleContacts::Contact do
|
|
122
122
|
|
123
123
|
describe "on groups" do
|
124
124
|
before(:each) do
|
125
|
-
@groups = [stub(
|
125
|
+
@groups = [stub("group1", :href => "foo"), stub("group2", :href => "bar")]
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should be possible to add an array of groups" do
|
129
129
|
@contact.groups += @groups
|
130
|
-
@contact.groups.should == [
|
130
|
+
@contact.groups.should == ["foo", "bar"].sort
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should be possible to add an array of urls" do
|
134
|
-
@contact.groups += [
|
135
|
-
@contact.groups.should == [
|
134
|
+
@contact.groups += ["foo", "bar"]
|
135
|
+
@contact.groups.should == ["foo", "bar"].sort
|
136
136
|
end
|
137
137
|
|
138
138
|
describe "with initial content" do
|
139
139
|
before(:each) do
|
140
|
-
@contact.groups = [
|
140
|
+
@contact.groups = ["foo", "bar", "quux"]
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should be possible to remove an array of groups" do
|
144
144
|
@contact.groups -= @groups
|
145
|
-
@contact.groups.should == [
|
145
|
+
@contact.groups.should == ["quux"]
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should be possible to remove an array of urls" do
|
149
|
-
@contact.groups -= [
|
150
|
-
@contact.groups.should == [
|
149
|
+
@contact.groups -= ["foo", "bar"]
|
150
|
+
@contact.groups.should == ["quux"]
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
data/spec/group_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe GoogleContacts::Group do
|
4
4
|
before(:each) do
|
5
|
-
entries = parsed_asset(
|
5
|
+
entries = parsed_asset("groups_full").search("feed > entry")
|
6
6
|
@groups = entries.map { |entry| GoogleContacts::Group.new(wrapper, entry) }
|
7
7
|
@group = @groups.first
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should know its href" do
|
11
|
-
@group.href.should ==
|
11
|
+
@group.href.should == "http://www.google.com/m8/feeds/groups/jo%40gmail.com/base/6"
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should initialize the title tag" do
|
15
|
-
@group.title.should ==
|
15
|
+
@group.title.should == "System Group: My Contacts"
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should know when it is a system group" do
|
@@ -21,6 +21,6 @@ describe GoogleContacts::Group do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should initialize extended properties" do
|
24
|
-
@group[:foo].should ==
|
24
|
+
@group[:foo].should == "bar"
|
25
25
|
end
|
26
26
|
end
|
data/spec/proxies/array_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe GoogleContacts::Proxies::Array do
|
4
4
|
describe "with existing entries" do
|
@@ -8,7 +8,7 @@ describe GoogleContacts::Proxies::Array do
|
|
8
8
|
|
9
9
|
it "should initialize on creation" do
|
10
10
|
@proxy.size.should == 1
|
11
|
-
@proxy[0].should ==
|
11
|
+
@proxy[0].should == "http://some.group"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -18,20 +18,20 @@ describe GoogleContacts::Proxies::Array do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should allow pushing a plain value" do
|
21
|
-
@proxy <<
|
21
|
+
@proxy << "http://foo"
|
22
22
|
@proxy.should have(1).group
|
23
|
-
@proxy[0].should ==
|
23
|
+
@proxy[0].should == "http://foo"
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should allow pushing an object that responds to href" do
|
27
|
-
@proxy << mock(
|
27
|
+
@proxy << mock("Group", :href => "http://foo")
|
28
28
|
@proxy.should have(1).group
|
29
|
-
@proxy[0].should ==
|
29
|
+
@proxy[0].should == "http://foo"
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should filter duplicates" do
|
33
|
-
@proxy <<
|
34
|
-
@proxy <<
|
33
|
+
@proxy << "http://foo"
|
34
|
+
@proxy << "http://foo"
|
35
35
|
@proxy.should have(1).group
|
36
36
|
end
|
37
37
|
|
@@ -41,7 +41,7 @@ describe GoogleContacts::Proxies::Array do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should allow clearing" do
|
44
|
-
@proxy <<
|
44
|
+
@proxy << "http://foo"
|
45
45
|
@proxy.clear
|
46
46
|
@proxy.should have(:no).groups
|
47
47
|
end
|
@@ -59,13 +59,13 @@ describe GoogleContacts::Proxies::Array do
|
|
59
59
|
|
60
60
|
it "should work after pushing a new entry" do
|
61
61
|
lambda {
|
62
|
-
@proxy <<
|
62
|
+
@proxy << "http://foo"
|
63
63
|
}.should change(@proxy, :changed?).from(false).to(true)
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should not be changed when a duplicate is added" do
|
67
67
|
lambda {
|
68
|
-
@proxy <<
|
68
|
+
@proxy << "http://some.group"
|
69
69
|
}.should_not change(@proxy, :changed?).from(false)
|
70
70
|
end
|
71
71
|
|
@@ -77,7 +77,7 @@ describe GoogleContacts::Proxies::Array do
|
|
77
77
|
|
78
78
|
it "should not be influenced by order" do
|
79
79
|
lambda {
|
80
|
-
@proxy.replace [
|
80
|
+
@proxy.replace ["http://another.group", "http://some.group"]
|
81
81
|
}.should_not change(@proxy, :changed?).from(false)
|
82
82
|
end
|
83
83
|
end
|
@@ -88,18 +88,18 @@ describe GoogleContacts::Proxies::Array do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should update the group entries" do
|
91
|
-
@proxy <<
|
92
|
-
@proxy <<
|
93
|
-
@parent.
|
94
|
-
@parent.
|
95
|
-
@parent.
|
91
|
+
@proxy << "http://another.group"
|
92
|
+
@proxy << "http://some.group"
|
93
|
+
@parent.should_receive(:remove_xml).with("./group")
|
94
|
+
@parent.should_receive(:insert_xml).with("group", { "href" => "http://another.group" })
|
95
|
+
@parent.should_receive(:insert_xml).with("group", { "href" => "http://some.group" })
|
96
96
|
@proxy.synchronize
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
def create_proxy_from_xml(str)
|
101
|
-
@parent = mock(
|
102
|
-
@proxy = GoogleContacts::Proxies::Array.new(@parent, :tag =>
|
101
|
+
@parent = mock("parent", :xml => Nokogiri::XML.parse(str).root)
|
102
|
+
@proxy = GoogleContacts::Proxies::Array.new(@parent, :tag => "group", :attr => "href")
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|