sabredav_client 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -3
- data/.rspec +1 -1
- data/CHANGELOG.rdoc +8 -8
- data/Gemfile +3 -3
- data/Gemfile.lock +39 -38
- data/README.md +49 -49
- data/Rakefile +5 -5
- data/lib/sabredav_client.rb +10 -10
- data/lib/sabredav_client/calendar.rb +171 -171
- data/lib/sabredav_client/client.rb +57 -57
- data/lib/sabredav_client/errors/errors.rb +41 -41
- data/lib/sabredav_client/events.rb +106 -105
- data/lib/sabredav_client/net.rb +15 -15
- data/lib/sabredav_client/principal.rb +51 -51
- data/lib/sabredav_client/request.rb +97 -97
- data/lib/sabredav_client/version.rb +3 -3
- data/lib/sabredav_client/xml_request_builder.rb +7 -7
- data/lib/sabredav_client/xml_request_builder/base.rb +17 -17
- data/lib/sabredav_client/xml_request_builder/mkcalendar.rb +25 -25
- data/lib/sabredav_client/xml_request_builder/mkcol_principal.rb +28 -28
- data/lib/sabredav_client/xml_request_builder/post_sharing.rb +41 -41
- data/lib/sabredav_client/xml_request_builder/propfind_calendar.rb +41 -41
- data/lib/sabredav_client/xml_request_builder/propfind_invite.rb +19 -19
- data/lib/sabredav_client/xml_request_builder/propfind_owner.rb +19 -19
- data/lib/sabredav_client/xml_request_builder/proppatch_calendar.rb +25 -25
- data/lib/sabredav_client/xml_request_builder/proppatch_events_owner.rb +23 -23
- data/lib/sabredav_client/xml_request_builder/proppatch_principal.rb +25 -25
- data/lib/sabredav_client/xml_request_builder/report_event_changes.rb +22 -22
- data/lib/sabredav_client/xml_request_builder/report_vevent.rb +30 -30
- data/lib/sabredav_client/xml_request_builder/report_vtodo.rb +20 -20
- data/sabredav_client.gemspec +31 -31
- data/spec/fixtures/calendar_fetch_changes.xml +26 -26
- data/spec/fixtures/calendar_info.xml +14 -14
- data/spec/fixtures/calendar_sharees.xml +35 -35
- data/spec/fixtures/calendar_sharees_without_common_name.xml +26 -26
- data/spec/fixtures/event.ics +23 -23
- data/spec/fixtures/events_find_multiple.xml +51 -51
- data/spec/fixtures/events_owner.xml +12 -12
- data/spec/fixtures/xml_request_builder/mkcalendar.xml +9 -9
- data/spec/fixtures/xml_request_builder/mkcol_principal.xml +12 -12
- data/spec/fixtures/xml_request_builder/post_sharing.xml +18 -18
- data/spec/fixtures/xml_request_builder/propfind_calendar/all_properties.xml +8 -8
- data/spec/fixtures/xml_request_builder/propfind_invite.xml +6 -6
- data/spec/fixtures/xml_request_builder/propfind_owner.xml +6 -6
- data/spec/fixtures/xml_request_builder/proppatch_calendar.xml +9 -9
- data/spec/fixtures/xml_request_builder/proppatch_events_owner.xml +8 -8
- data/spec/fixtures/xml_request_builder/proppatch_principal.xml +9 -9
- data/spec/fixtures/xml_request_builder/report_event_changes.xml +8 -8
- data/spec/sabredav_client/calendar_spec.rb +142 -142
- data/spec/sabredav_client/client_spec.rb +41 -41
- data/spec/sabredav_client/events_spec.rb +119 -119
- data/spec/sabredav_client/principal_spec.rb +51 -51
- data/spec/sabredav_client/request_spec.rb +55 -55
- data/spec/sabredav_client/xml_request_builder_specs/base_spec.rb +30 -30
- data/spec/sabredav_client/xml_request_builder_specs/mkcalendar_spec.rb +13 -13
- data/spec/sabredav_client/xml_request_builder_specs/mkcol_principal_spec.rb +13 -13
- data/spec/sabredav_client/xml_request_builder_specs/post_sharing_spec.rb +15 -15
- data/spec/sabredav_client/xml_request_builder_specs/propfind_calendar_spec.rb +24 -24
- data/spec/sabredav_client/xml_request_builder_specs/propfind_invite_spec.rb +14 -14
- data/spec/sabredav_client/xml_request_builder_specs/propfind_owner_spec.rb +14 -14
- data/spec/sabredav_client/xml_request_builder_specs/proppatch_calendar.rb +15 -15
- data/spec/sabredav_client/xml_request_builder_specs/proppatch_events_owner_spec.rb +14 -14
- data/spec/sabredav_client/xml_request_builder_specs/proppatch_principal_spec.rb +24 -24
- data/spec/sabredav_client/xml_request_builder_specs/report_event_changes_spec.rb +15 -15
- data/spec/spec.opts +4 -4
- data/spec/spec_helper.rb +8 -8
- metadata +5 -5
@@ -1,119 +1,119 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SabredavClient::Events do
|
4
|
-
client = SabredavClient::Client.new(uri: "http://localhost:5232/user/calendar", user: "user", password: "")
|
5
|
-
let!(:events) { described_class.new(client = client) }
|
6
|
-
|
7
|
-
describe "initialization" do
|
8
|
-
|
9
|
-
it "client" do
|
10
|
-
|
11
|
-
expect(events.client).to be_a(SabredavClient::Client)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "delete" do
|
16
|
-
|
17
|
-
it "one event" do
|
18
|
-
uri = "event.ics"
|
19
|
-
FakeWeb.register_uri(:delete, "http://user@localhost:5232/user/calendar/#{uri}",
|
20
|
-
[{:body => "1 deleted.", :status => ["200", "OK"]}])
|
21
|
-
r = events.delete(uri)
|
22
|
-
|
23
|
-
expect(r).to be(true)
|
24
|
-
end
|
25
|
-
|
26
|
-
context "error" do
|
27
|
-
it "raises error if etag not includes .ics" do
|
28
|
-
uri = nil
|
29
|
-
|
30
|
-
expect {
|
31
|
-
events.delete(uri)
|
32
|
-
}.to raise_error(SabredavClient::Errors::SabredavClientError)
|
33
|
-
|
34
|
-
uri = "x-vvvvvv-sssss-2122222-xssw"
|
35
|
-
|
36
|
-
expect {
|
37
|
-
events.delete(uri)
|
38
|
-
}.to raise_error(SabredavClient::Errors::SabredavClientError)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "it raises error NotFoundError if resource was not found" do
|
42
|
-
uri = "event.ics"
|
43
|
-
FakeWeb.register_uri(:delete, "http://user@localhost:5232/user/calendar/#{uri}",
|
44
|
-
[{:body => "not found", :status => ["404", "Not Found"]}])
|
45
|
-
expect {
|
46
|
-
events.delete(uri)
|
47
|
-
}.to raise_error(SabredavClient::Errors::NotFoundError)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "find one event" do
|
53
|
-
|
54
|
-
it "one event" do
|
55
|
-
uid = "47732F70-1793-47B3-80FA-57E3C5ECA0E5"
|
56
|
-
uri = "#{uid}.ics"
|
57
|
-
|
58
|
-
etag = "6341a7e8f9a1f775dd07c55b17ff27b7"
|
59
|
-
|
60
|
-
expected_result = {etag: etag, ics: File.open("spec/fixtures/event.ics").read}
|
61
|
-
|
62
|
-
FakeWeb.register_uri(:get, "http://user@localhost:5232/user/calendar/#{uri}", body: File.open("spec/fixtures/event.ics"), etag: etag )
|
63
|
-
r = events.find(uri)
|
64
|
-
|
65
|
-
expect(r).to eq(expected_result)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "two events" do
|
69
|
-
FakeWeb.register_uri(:report, "http://user@localhost:5232/user/calendar/", body: File.open('spec/fixtures/events_find_multiple.xml'))
|
70
|
-
r = events.find_multiple(starts: "2001-02-02 07:00", ends: "2000-02-03 23:59")
|
71
|
-
|
72
|
-
expect(r).to include("BEGIN:VCALENDAR")
|
73
|
-
expect(r).to include("UID:960232b0-371c-0130-9e6b-001999638982")
|
74
|
-
expect(r).to include("UID:98f067a0-371c-0130-9e6c-001999638982")
|
75
|
-
expect(r).to include("END:VCALENDAR")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "create_update" do
|
80
|
-
etag = "123"
|
81
|
-
uri = "event.ics"
|
82
|
-
event_ics = File.open('spec/fixtures/event.ics')
|
83
|
-
|
84
|
-
it "create event" do
|
85
|
-
FakeWeb.register_uri(:put, "http://user@localhost:5232/user/calendar/#{uri}", {etag: etag, status: ["201", "OK"]})
|
86
|
-
r = events.create_update(uri, event_ics.to_s)
|
87
|
-
|
88
|
-
expect(r).to eq
|
89
|
-
end
|
90
|
-
|
91
|
-
it "update event" do
|
92
|
-
new_etag = "124"
|
93
|
-
FakeWeb.register_uri(:put, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"], etag: new_etag})
|
94
|
-
r = events.create_update(uri, event_ics.to_s, etag )
|
95
|
-
|
96
|
-
expect(r).not_to eq etag
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "owner" do
|
101
|
-
uri = "event.ics"
|
102
|
-
|
103
|
-
it "find" do
|
104
|
-
owner = "principals/usertest"
|
105
|
-
FakeWeb.register_uri(:propfind, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"], body: File.open("spec/fixtures/events_owner.xml")})
|
106
|
-
r = events.owner(uri)
|
107
|
-
|
108
|
-
expect(r).to eq(owner)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "update" do
|
112
|
-
FakeWeb.register_uri(:proppatch, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"]})
|
113
|
-
r = events.update_owner(uri, "principals/usertest")
|
114
|
-
|
115
|
-
expect(r).to be
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SabredavClient::Events do
|
4
|
+
client = SabredavClient::Client.new(uri: "http://localhost:5232/user/calendar", user: "user", password: "")
|
5
|
+
let!(:events) { described_class.new(client = client) }
|
6
|
+
|
7
|
+
describe "initialization" do
|
8
|
+
|
9
|
+
it "client" do
|
10
|
+
|
11
|
+
expect(events.client).to be_a(SabredavClient::Client)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "delete" do
|
16
|
+
|
17
|
+
it "one event" do
|
18
|
+
uri = "event.ics"
|
19
|
+
FakeWeb.register_uri(:delete, "http://user@localhost:5232/user/calendar/#{uri}",
|
20
|
+
[{:body => "1 deleted.", :status => ["200", "OK"]}])
|
21
|
+
r = events.delete(uri)
|
22
|
+
|
23
|
+
expect(r).to be(true)
|
24
|
+
end
|
25
|
+
|
26
|
+
context "error" do
|
27
|
+
it "raises error if etag not includes .ics" do
|
28
|
+
uri = nil
|
29
|
+
|
30
|
+
expect {
|
31
|
+
events.delete(uri)
|
32
|
+
}.to raise_error(SabredavClient::Errors::SabredavClientError)
|
33
|
+
|
34
|
+
uri = "x-vvvvvv-sssss-2122222-xssw"
|
35
|
+
|
36
|
+
expect {
|
37
|
+
events.delete(uri)
|
38
|
+
}.to raise_error(SabredavClient::Errors::SabredavClientError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "it raises error NotFoundError if resource was not found" do
|
42
|
+
uri = "event.ics"
|
43
|
+
FakeWeb.register_uri(:delete, "http://user@localhost:5232/user/calendar/#{uri}",
|
44
|
+
[{:body => "not found", :status => ["404", "Not Found"]}])
|
45
|
+
expect {
|
46
|
+
events.delete(uri)
|
47
|
+
}.to raise_error(SabredavClient::Errors::NotFoundError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "find one event" do
|
53
|
+
|
54
|
+
it "one event" do
|
55
|
+
uid = "47732F70-1793-47B3-80FA-57E3C5ECA0E5"
|
56
|
+
uri = "#{uid}.ics"
|
57
|
+
|
58
|
+
etag = "6341a7e8f9a1f775dd07c55b17ff27b7"
|
59
|
+
|
60
|
+
expected_result = {etag: etag, ics: File.open("spec/fixtures/event.ics").read}
|
61
|
+
|
62
|
+
FakeWeb.register_uri(:get, "http://user@localhost:5232/user/calendar/#{uri}", body: File.open("spec/fixtures/event.ics"), etag: etag )
|
63
|
+
r = events.find(uri)
|
64
|
+
|
65
|
+
expect(r).to eq(expected_result)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "two events" do
|
69
|
+
FakeWeb.register_uri(:report, "http://user@localhost:5232/user/calendar/", body: File.open('spec/fixtures/events_find_multiple.xml'))
|
70
|
+
r = events.find_multiple(starts: "2001-02-02 07:00", ends: "2000-02-03 23:59")
|
71
|
+
|
72
|
+
expect(r).to include("BEGIN:VCALENDAR")
|
73
|
+
expect(r).to include("UID:960232b0-371c-0130-9e6b-001999638982")
|
74
|
+
expect(r).to include("UID:98f067a0-371c-0130-9e6c-001999638982")
|
75
|
+
expect(r).to include("END:VCALENDAR")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "create_update" do
|
80
|
+
etag = "\"123\""
|
81
|
+
uri = "event.ics"
|
82
|
+
event_ics = File.open('spec/fixtures/event.ics')
|
83
|
+
|
84
|
+
it "create event" do
|
85
|
+
FakeWeb.register_uri(:put, "http://user@localhost:5232/user/calendar/#{uri}", {etag: etag, status: ["201", "OK"]})
|
86
|
+
r = events.create_update(uri, event_ics.to_s)
|
87
|
+
|
88
|
+
expect(r).to eq "123"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "update event" do
|
92
|
+
new_etag = "124"
|
93
|
+
FakeWeb.register_uri(:put, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"], etag: new_etag})
|
94
|
+
r = events.create_update(uri, event_ics.to_s, etag )
|
95
|
+
|
96
|
+
expect(r).not_to eq etag
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "owner" do
|
101
|
+
uri = "event.ics"
|
102
|
+
|
103
|
+
it "find" do
|
104
|
+
owner = "principals/usertest"
|
105
|
+
FakeWeb.register_uri(:propfind, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"], body: File.open("spec/fixtures/events_owner.xml")})
|
106
|
+
r = events.owner(uri)
|
107
|
+
|
108
|
+
expect(r).to eq(owner)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "update" do
|
112
|
+
FakeWeb.register_uri(:proppatch, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"]})
|
113
|
+
r = events.update_owner(uri, "principals/usertest")
|
114
|
+
|
115
|
+
expect(r).to be
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SabredavClient::Client do
|
4
|
-
|
5
|
-
let(:principal) { SabredavClient::Principal.new(:uri => "http://localhost:5232/user/principals/user", :user => "user" , :password => "") }
|
6
|
-
|
7
|
-
|
8
|
-
describe "initialization" do
|
9
|
-
|
10
|
-
it "client available" do
|
11
|
-
expect(principal.client).to be_a(SabredavClient::Client)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "create" do
|
16
|
-
email = "test@mail.de"
|
17
|
-
description = "a random description"
|
18
|
-
|
19
|
-
it "create with description" do
|
20
|
-
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["201", "Created"])
|
21
|
-
result = principal.create(email, description)
|
22
|
-
expect(result).to be
|
23
|
-
end
|
24
|
-
|
25
|
-
it "create without description" do
|
26
|
-
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["201", "Created"])
|
27
|
-
result = principal.create(email)
|
28
|
-
expect(result).to be
|
29
|
-
end
|
30
|
-
|
31
|
-
it "create fails because resource already exists" do
|
32
|
-
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["405", "Method not allowed"])
|
33
|
-
expect {
|
34
|
-
principal.create(email)
|
35
|
-
}.to raise_error(SabredavClient::Errors::NotAllowedError)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "update" do
|
40
|
-
|
41
|
-
it "updates email and displayname" do
|
42
|
-
email = "update@test.de"
|
43
|
-
displayname = "David B."
|
44
|
-
FakeWeb.register_uri(:proppatch, "http://user@localhost:5232/user/principals/user/", status: ["207", "OK"])
|
45
|
-
|
46
|
-
result = principal.update(email: email, displayname: displayname)
|
47
|
-
expect(result).to be
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SabredavClient::Client do
|
4
|
+
|
5
|
+
let(:principal) { SabredavClient::Principal.new(:uri => "http://localhost:5232/user/principals/user", :user => "user" , :password => "") }
|
6
|
+
|
7
|
+
|
8
|
+
describe "initialization" do
|
9
|
+
|
10
|
+
it "client available" do
|
11
|
+
expect(principal.client).to be_a(SabredavClient::Client)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "create" do
|
16
|
+
email = "test@mail.de"
|
17
|
+
description = "a random description"
|
18
|
+
|
19
|
+
it "create with description" do
|
20
|
+
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["201", "Created"])
|
21
|
+
result = principal.create(email, description)
|
22
|
+
expect(result).to be
|
23
|
+
end
|
24
|
+
|
25
|
+
it "create without description" do
|
26
|
+
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["201", "Created"])
|
27
|
+
result = principal.create(email)
|
28
|
+
expect(result).to be
|
29
|
+
end
|
30
|
+
|
31
|
+
it "create fails because resource already exists" do
|
32
|
+
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["405", "Method not allowed"])
|
33
|
+
expect {
|
34
|
+
principal.create(email)
|
35
|
+
}.to raise_error(SabredavClient::Errors::NotAllowedError)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "update" do
|
40
|
+
|
41
|
+
it "updates email and displayname" do
|
42
|
+
email = "update@test.de"
|
43
|
+
displayname = "David B."
|
44
|
+
FakeWeb.register_uri(:proppatch, "http://user@localhost:5232/user/principals/user/", status: ["207", "OK"])
|
45
|
+
|
46
|
+
result = principal.update(email: email, displayname: displayname)
|
47
|
+
expect(result).to be
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,55 +1,55 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe SabredavClient::Request do
|
4
|
-
let!(:client) { SabredavClient::Client.new(:uri => "http://localhost:5232/user/calendar", :user => "user" , :password => "") }
|
5
|
-
path = ""
|
6
|
-
|
7
|
-
describe "initialize" do
|
8
|
-
let!(:request) { SabredavClient::Request.new(:get, client, path) }
|
9
|
-
|
10
|
-
it "tests supported http methods" do
|
11
|
-
methods = [:put, :get, :post, :mkcalendar, :propfind, :proppatch, :report, :delete, :mkcol]
|
12
|
-
methods.each do |method|
|
13
|
-
res = SabredavClient::Request.new(method, client, path)
|
14
|
-
expect(res).to be_a SabredavClient::Request
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "raises error if method not supported" do
|
19
|
-
method = :foobar
|
20
|
-
expect { res = SabredavClient::Request.new(method, client, path)
|
21
|
-
}.to raise_error SabredavClient::Errors::HTTPMethodNotSupportedError
|
22
|
-
end
|
23
|
-
|
24
|
-
it "testes existence of http object" do
|
25
|
-
expect(request.http).to be_a Net::HTTP
|
26
|
-
end
|
27
|
-
|
28
|
-
it "tests existence of path" do
|
29
|
-
expect(request.path).to be
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "add" do
|
34
|
-
let!(:request) { SabredavClient::Request.new(:put, client, path: "random.ics") }
|
35
|
-
|
36
|
-
it "header attributes" do
|
37
|
-
request.add_header(content_type: "application/xml",
|
38
|
-
content_length: "xxxx",
|
39
|
-
if_match: "etag",
|
40
|
-
dav: "resource-must-be-null")
|
41
|
-
req = request.request.to_hash
|
42
|
-
expect(req["content-type"]).to include "application/xml"
|
43
|
-
expect(req["content-length"]).to include "xxxx"
|
44
|
-
expect(req["if-match"]).to include "etag"
|
45
|
-
expect(req["dav"]).to include "resource-must-be-null"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "body" do
|
49
|
-
body = "some content"
|
50
|
-
request.add_body(body)
|
51
|
-
expect(request.request.body).to eq body
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SabredavClient::Request do
|
4
|
+
let!(:client) { SabredavClient::Client.new(:uri => "http://localhost:5232/user/calendar", :user => "user" , :password => "") }
|
5
|
+
path = ""
|
6
|
+
|
7
|
+
describe "initialize" do
|
8
|
+
let!(:request) { SabredavClient::Request.new(:get, client, path) }
|
9
|
+
|
10
|
+
it "tests supported http methods" do
|
11
|
+
methods = [:put, :get, :post, :mkcalendar, :propfind, :proppatch, :report, :delete, :mkcol]
|
12
|
+
methods.each do |method|
|
13
|
+
res = SabredavClient::Request.new(method, client, path)
|
14
|
+
expect(res).to be_a SabredavClient::Request
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "raises error if method not supported" do
|
19
|
+
method = :foobar
|
20
|
+
expect { res = SabredavClient::Request.new(method, client, path)
|
21
|
+
}.to raise_error SabredavClient::Errors::HTTPMethodNotSupportedError
|
22
|
+
end
|
23
|
+
|
24
|
+
it "testes existence of http object" do
|
25
|
+
expect(request.http).to be_a Net::HTTP
|
26
|
+
end
|
27
|
+
|
28
|
+
it "tests existence of path" do
|
29
|
+
expect(request.path).to be
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "add" do
|
34
|
+
let!(:request) { SabredavClient::Request.new(:put, client, path: "random.ics") }
|
35
|
+
|
36
|
+
it "header attributes" do
|
37
|
+
request.add_header(content_type: "application/xml",
|
38
|
+
content_length: "xxxx",
|
39
|
+
if_match: "etag",
|
40
|
+
dav: "resource-must-be-null")
|
41
|
+
req = request.request.to_hash
|
42
|
+
expect(req["content-type"]).to include "application/xml"
|
43
|
+
expect(req["content-length"]).to include "xxxx"
|
44
|
+
expect(req["if-match"]).to include "etag"
|
45
|
+
expect(req["dav"]).to include "resource-must-be-null"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "body" do
|
49
|
+
body = "some content"
|
50
|
+
request.add_body(body)
|
51
|
+
expect(request.request.body).to eq body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|