gmail 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +27 -27
- data/.rspec +1 -1
- data/.rubocop.yml +13 -13
- data/.rubocop_todo.yml +239 -239
- data/.travis.yml +19 -19
- data/CHANGELOG.md +145 -139
- data/Gemfile +3 -3
- data/LICENSE +21 -21
- data/README.md +355 -354
- data/Rakefile +46 -46
- data/gmail.gemspec +34 -34
- data/lib/gmail.rb +78 -78
- data/lib/gmail/client.rb +34 -34
- data/lib/gmail/client/base.rb +229 -229
- data/lib/gmail/client/plain.rb +24 -24
- data/lib/gmail/client/xoauth.rb +68 -68
- data/lib/gmail/client/xoauth2.rb +39 -39
- data/lib/gmail/imap_extensions.rb +159 -150
- data/lib/gmail/labels.rb +79 -79
- data/lib/gmail/mailbox.rb +175 -135
- data/lib/gmail/message.rb +207 -207
- data/lib/gmail/version.rb +3 -3
- data/spec/account.yml.example +1 -1
- data/spec/account.yml.obfus +2 -2
- data/spec/gmail/client/base_spec.rb +5 -5
- data/spec/gmail/client/plain_spec.rb +169 -168
- data/spec/gmail/client/xoauth2_spec.rb +186 -186
- data/spec/gmail/client/xoauth_spec.rb +5 -5
- data/spec/gmail/client_spec.rb +5 -5
- data/spec/gmail/imap_extensions_spec.rb +47 -12
- data/spec/gmail/labels_spec.rb +27 -18
- data/spec/gmail/mailbox_spec.rb +84 -47
- data/spec/gmail/message_spec.rb +181 -181
- data/spec/gmail_spec.rb +39 -39
- data/spec/recordings/gmail/_new_connects_with_client_and_give_it_context_when_block_given.yml +28 -28
- data/spec/recordings/gmail/_new_connects_with_gmail_service_and_return_valid_connection_object.yml +28 -28
- data/spec/recordings/gmail/_new_does_not_raise_error_when_couldn_t_connect_with_given_account.yml +13 -13
- data/spec/recordings/gmail/_new_raises_error_when_couldn_t_connect_with_given_account.yml +13 -13
- data/spec/recordings/gmail_client_plain/instance/_connection_automatically_logs_in_to_gmail_account_when_it_s_called.yml +42 -42
- data/spec/recordings/gmail_client_plain/instance/delivers_inline_composed_email.yml +42 -42
- data/spec/recordings/gmail_client_plain/instance/does_not_log_in_when_given_gmail_account_is_invalid.yml +13 -13
- data/spec/recordings/gmail_client_plain/instance/does_not_raise_error_even_though_gmail_account_is_invalid.yml +13 -13
- data/spec/recordings/gmail_client_plain/instance/labels/checks_if_there_is_given_label_defined.yml +196 -196
- data/spec/recordings/gmail_client_plain/instance/labels/creates_given_label.yml +151 -151
- data/spec/recordings/gmail_client_plain/instance/labels/removes_existing_label.yml +146 -146
- data/spec/recordings/gmail_client_plain/instance/labels/returns_list_of_all_available_labels.yml +113 -113
- data/spec/recordings/gmail_client_plain/instance/properly_logs_in_to_valid_gmail_account.yml +42 -42
- data/spec/recordings/gmail_client_plain/instance/properly_logs_out_from_gmail.yml +42 -42
- data/spec/recordings/gmail_client_plain/instance/properly_switches_to_given_mailbox.yml +109 -109
- data/spec/recordings/gmail_client_plain/instance/properly_switches_to_given_mailbox_using_block_style.yml +109 -109
- data/spec/recordings/gmail_client_plain/instance/raises_error_when_given_gmail_account_is_invalid_and_errors_enabled.yml +13 -13
- data/spec/recordings/gmail_client_xo_auth2/instance/does_not_log_in_when_given_gmail_account_is_invalid.yml +13 -13
- data/spec/recordings/gmail_client_xo_auth2/instance/labels/checks_if_there_is_given_label_defined.yml +27 -27
- data/spec/recordings/gmail_client_xo_auth2/instance/labels/creates_given_label.yml +39 -39
- data/spec/recordings/gmail_client_xo_auth2/instance/labels/removes_existing_label.yml +39 -39
- data/spec/recordings/gmail_client_xo_auth2/instance/labels/returns_list_of_all_available_labels.yml +27 -27
- data/spec/recordings/gmail_client_xo_auth2/instance/properly_logs_in_to_valid_gmail_account.yml +15 -15
- data/spec/recordings/gmail_client_xo_auth2/instance/properly_logs_out_from_gmail.yml +15 -15
- data/spec/recordings/gmail_client_xo_auth2/instance/properly_switches_to_given_mailbox.yml +40 -40
- data/spec/recordings/gmail_client_xo_auth2/instance/properly_switches_to_given_mailbox_using_block_style.yml +40 -40
- data/spec/recordings/gmail_client_xo_auth2/instance/raises_error_when_given_gmail_account_is_invalid_and_errors_enabled.yml +13 -13
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/all/localizes_into_the_appropriate_label.yml +116 -116
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/and_the_mailbox_does_not_exist/returns_the_mailbox_name_as_a_string.yml +110 -0
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/drafts/localizes_into_the_appropriate_label.yml +116 -116
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/flagged/localizes_into_the_appropriate_label.yml +116 -116
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/important/localizes_into_the_appropriate_label.yml +116 -116
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/inbox/localizes_into_the_appropriate_label.yml +42 -42
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/junk/localizes_into_the_appropriate_label.yml +116 -116
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/sent/localizes_into_the_appropriate_label.yml +116 -116
- data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/trash/localizes_into_the_appropriate_label.yml +116 -116
- data/spec/recordings/gmail_mailbox/instance/counts_all_emails.yml +277 -277
- data/spec/recordings/gmail_mailbox/instance/finds_messages.yml +586 -586
- data/spec/recordings/gmail_mailbox/instance/waits_once.yml +136 -0
- data/spec/recordings/gmail_mailbox/instance/waits_repeatedly.yml +141 -0
- data/spec/recordings/gmail_mailbox/instance/waits_with_29-minute_re-issue.yml +136 -0
- data/spec/recordings/gmail_mailbox/instance/waits_with_an_unblocked_connection.yml +207 -0
- data/spec/recordings/gmail_mailbox/on_initialize/sets_client_and_name.yml +42 -42
- data/spec/recordings/gmail_mailbox/on_initialize/works_in_inbox_by_default.yml +42 -42
- data/spec/recordings/gmail_message/initialize/sets_prefetch_attrs.yml +578 -578
- data/spec/recordings/gmail_message/initialize/sets_uid_and_mailbox.yml +580 -580
- data/spec/recordings/gmail_message/instance_methods/deletes_itself.yml +637 -637
- data/spec/recordings/gmail_message/instance_methods/marks_itself_read.yml +682 -682
- data/spec/recordings/gmail_message/instance_methods/marks_itself_unread.yml +686 -686
- data/spec/recordings/gmail_message/instance_methods/moves_from_one_tag_to_other.yml +862 -862
- data/spec/recordings/gmail_message/instance_methods/removes_a_given_label.yml +776 -776
- data/spec/recordings/gmail_message/instance_methods/removes_a_given_label_with_old_method.yml +776 -776
- data/spec/recordings/gmail_message/instance_methods/sets_given_label.yml +690 -690
- data/spec/recordings/gmail_message/instance_methods/sets_given_label_with_old_method.yml +691 -691
- data/spec/spec_helper.rb +53 -53
- data/spec/support/imap_mock.rb +181 -129
- data/spec/support/obfuscation.rb +52 -52
- metadata +78 -5
@@ -1,186 +1,186 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Gmail::Client::XOAuth2 do
|
4
|
-
subject { Gmail::Client::XOAuth2 }
|
5
|
-
|
6
|
-
context "on initialize" do
|
7
|
-
it "sets username, oauth2_token and options" do
|
8
|
-
client = subject.new("test@gmail.com", {
|
9
|
-
:token => "token",
|
10
|
-
:foo => :bar
|
11
|
-
})
|
12
|
-
expect(client.username).to eq("test@gmail.com")
|
13
|
-
expect(client.token).to eq({ :token => "token", :foo => :bar })
|
14
|
-
end
|
15
|
-
|
16
|
-
it "converts simple name to gmail email" do
|
17
|
-
client = subject.new("test", { :token => "token" })
|
18
|
-
expect(client.username).to eq("test@gmail.com")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "instance" do
|
23
|
-
def mock_client(&block)
|
24
|
-
client = Gmail::Client::XOAuth2.new(*TEST_ACCOUNT)
|
25
|
-
if block_given?
|
26
|
-
client.connect
|
27
|
-
yield client
|
28
|
-
client.logout
|
29
|
-
end
|
30
|
-
client
|
31
|
-
end
|
32
|
-
|
33
|
-
it "connects to Gmail IMAP service" do
|
34
|
-
expect(-> {
|
35
|
-
client = mock_client
|
36
|
-
expect(client.connect!).to be_truthy
|
37
|
-
}).to_not raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
it "properly logs in to valid Gmail account" do
|
41
|
-
pending
|
42
|
-
client = mock_client
|
43
|
-
expect(client.connect).to be_truthy
|
44
|
-
expect(client.login).to be_truthy
|
45
|
-
expect(client).to be_logged_in
|
46
|
-
client.logout
|
47
|
-
end
|
48
|
-
|
49
|
-
it "raises error when given Gmail account is invalid and errors enabled" do
|
50
|
-
expect(-> {
|
51
|
-
client = Gmail::Client::XOAuth2.new("foo", { :token => "bar" })
|
52
|
-
expect(client.connect).to be_truthy
|
53
|
-
expect(client.login!).not_to be_truthy
|
54
|
-
}).to raise_error(Gmail::Client::AuthorizationError)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "does not log in when given Gmail account is invalid" do
|
58
|
-
expect(-> {
|
59
|
-
client = Gmail::Client::XOAuth2.new("foo", { :token => "bar" })
|
60
|
-
expect(client.connect).to be_truthy
|
61
|
-
expect(client.login).not_to be_truthy
|
62
|
-
}).to_not raise_error
|
63
|
-
end
|
64
|
-
|
65
|
-
it "properly logs out from Gmail" do
|
66
|
-
pending
|
67
|
-
client = mock_client
|
68
|
-
client.connect
|
69
|
-
expect(client.login).to be_truthy
|
70
|
-
expect(client.logout).to be_truthy
|
71
|
-
expect(client).not_to be_logged_in
|
72
|
-
end
|
73
|
-
|
74
|
-
it "#connection automatically logs in to Gmail account when it's called" do
|
75
|
-
mock_client do |client|
|
76
|
-
expect(client).to receive(:login).once.and_return(false)
|
77
|
-
expect(client.connection).not_to be_nil
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it "properly composes message" do
|
82
|
-
mail = mock_client.compose do
|
83
|
-
from "test@gmail.com"
|
84
|
-
to "friend@gmail.com"
|
85
|
-
subject "Hello world!"
|
86
|
-
end
|
87
|
-
expect(mail.from).to eq(["test@gmail.com"])
|
88
|
-
expect(mail.to).to eq(["friend@gmail.com"])
|
89
|
-
expect(mail.subject).to eq("Hello world!")
|
90
|
-
end
|
91
|
-
|
92
|
-
it "#compose automatically adds `from` header when it is not specified" do
|
93
|
-
mail = mock_client.compose
|
94
|
-
expect(mail.from).to eq([TEST_ACCOUNT[0]])
|
95
|
-
mail = mock_client.compose(Mail.new)
|
96
|
-
expect(mail.from).to eq([TEST_ACCOUNT[0]])
|
97
|
-
mail = mock_client.compose {}
|
98
|
-
expect(mail.from).to eq([TEST_ACCOUNT[0]])
|
99
|
-
end
|
100
|
-
|
101
|
-
it "delivers inline composed email" do
|
102
|
-
pending
|
103
|
-
mock_client do |client|
|
104
|
-
response = client.deliver do
|
105
|
-
to TEST_ACCOUNT[0]
|
106
|
-
subject "Hello world!"
|
107
|
-
body "Yeah, hello there!"
|
108
|
-
end
|
109
|
-
|
110
|
-
expect(response).to be_truthy
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
it "does not raise error when mail can't be delivered and errors are disabled" do
|
115
|
-
expect(-> {
|
116
|
-
client = mock_client
|
117
|
-
expect(client.deliver(Mail.new {})).to be_falsey
|
118
|
-
}).to_not raise_error
|
119
|
-
end
|
120
|
-
|
121
|
-
it "raises error when mail can't be delivered and errors are disabled" do
|
122
|
-
expect(-> {
|
123
|
-
client = mock_client
|
124
|
-
client.deliver!(Mail.new {})
|
125
|
-
}).to raise_error(Gmail::Client::DeliveryError)
|
126
|
-
end
|
127
|
-
|
128
|
-
it "properly switches to given mailbox" do
|
129
|
-
pending
|
130
|
-
mock_client do |client|
|
131
|
-
mailbox = client.mailbox("TEST")
|
132
|
-
expect(mailbox).to be_kind_of(Gmail::Mailbox)
|
133
|
-
expect(mailbox.name).to eq("TEST")
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
it "properly switches to given mailbox using block style" do
|
138
|
-
pending
|
139
|
-
mock_client do |client|
|
140
|
-
client.mailbox("TEST") do |mailbox|
|
141
|
-
expect(mailbox).to be_kind_of(Gmail::Mailbox)
|
142
|
-
expect(mailbox.name).to eq("TEST")
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
context "labels" do
|
148
|
-
subject {
|
149
|
-
client = Gmail::Client::XOAuth2.new(*TEST_ACCOUNT)
|
150
|
-
client.connect
|
151
|
-
client.labels
|
152
|
-
}
|
153
|
-
|
154
|
-
it "returns list of all available labels" do
|
155
|
-
pending
|
156
|
-
labels = subject
|
157
|
-
expect(labels.all).to include("TEST", "INBOX")
|
158
|
-
end
|
159
|
-
|
160
|
-
it "checks if there is given label defined" do
|
161
|
-
pending
|
162
|
-
labels = subject
|
163
|
-
expect(labels.exists?("TEST")).to be_truthy
|
164
|
-
expect(labels.exists?("FOOBAR")).to be_falsey
|
165
|
-
end
|
166
|
-
|
167
|
-
it "creates given label" do
|
168
|
-
pending
|
169
|
-
labels = subject
|
170
|
-
labels.create("MYLABEL")
|
171
|
-
expect(labels.exists?("MYLABEL")).to be_truthy
|
172
|
-
expect(labels.create("MYLABEL")).to be_falsey
|
173
|
-
labels.delete("MYLABEL")
|
174
|
-
end
|
175
|
-
|
176
|
-
it "removes existing label" do
|
177
|
-
pending
|
178
|
-
labels = subject
|
179
|
-
labels.create("MYLABEL")
|
180
|
-
expect(labels.delete("MYLABEL")).to be_truthy
|
181
|
-
expect(labels.exists?("MYLABEL")).to be_falsey
|
182
|
-
expect(labels.delete("MYLABEL")).to be_falsey
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gmail::Client::XOAuth2 do
|
4
|
+
subject { Gmail::Client::XOAuth2 }
|
5
|
+
|
6
|
+
context "on initialize" do
|
7
|
+
it "sets username, oauth2_token and options" do
|
8
|
+
client = subject.new("test@gmail.com", {
|
9
|
+
:token => "token",
|
10
|
+
:foo => :bar
|
11
|
+
})
|
12
|
+
expect(client.username).to eq("test@gmail.com")
|
13
|
+
expect(client.token).to eq({ :token => "token", :foo => :bar })
|
14
|
+
end
|
15
|
+
|
16
|
+
it "converts simple name to gmail email" do
|
17
|
+
client = subject.new("test", { :token => "token" })
|
18
|
+
expect(client.username).to eq("test@gmail.com")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "instance" do
|
23
|
+
def mock_client(&block)
|
24
|
+
client = Gmail::Client::XOAuth2.new(*TEST_ACCOUNT)
|
25
|
+
if block_given?
|
26
|
+
client.connect
|
27
|
+
yield client
|
28
|
+
client.logout
|
29
|
+
end
|
30
|
+
client
|
31
|
+
end
|
32
|
+
|
33
|
+
it "connects to Gmail IMAP service" do
|
34
|
+
expect(-> {
|
35
|
+
client = mock_client
|
36
|
+
expect(client.connect!).to be_truthy
|
37
|
+
}).to_not raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "properly logs in to valid Gmail account" do
|
41
|
+
pending
|
42
|
+
client = mock_client
|
43
|
+
expect(client.connect).to be_truthy
|
44
|
+
expect(client.login).to be_truthy
|
45
|
+
expect(client).to be_logged_in
|
46
|
+
client.logout
|
47
|
+
end
|
48
|
+
|
49
|
+
it "raises error when given Gmail account is invalid and errors enabled" do
|
50
|
+
expect(-> {
|
51
|
+
client = Gmail::Client::XOAuth2.new("foo", { :token => "bar" })
|
52
|
+
expect(client.connect).to be_truthy
|
53
|
+
expect(client.login!).not_to be_truthy
|
54
|
+
}).to raise_error(Gmail::Client::AuthorizationError)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "does not log in when given Gmail account is invalid" do
|
58
|
+
expect(-> {
|
59
|
+
client = Gmail::Client::XOAuth2.new("foo", { :token => "bar" })
|
60
|
+
expect(client.connect).to be_truthy
|
61
|
+
expect(client.login).not_to be_truthy
|
62
|
+
}).to_not raise_error
|
63
|
+
end
|
64
|
+
|
65
|
+
it "properly logs out from Gmail" do
|
66
|
+
pending
|
67
|
+
client = mock_client
|
68
|
+
client.connect
|
69
|
+
expect(client.login).to be_truthy
|
70
|
+
expect(client.logout).to be_truthy
|
71
|
+
expect(client).not_to be_logged_in
|
72
|
+
end
|
73
|
+
|
74
|
+
it "#connection automatically logs in to Gmail account when it's called" do
|
75
|
+
mock_client do |client|
|
76
|
+
expect(client).to receive(:login).once.and_return(false)
|
77
|
+
expect(client.connection).not_to be_nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it "properly composes message" do
|
82
|
+
mail = mock_client.compose do
|
83
|
+
from "test@gmail.com"
|
84
|
+
to "friend@gmail.com"
|
85
|
+
subject "Hello world!"
|
86
|
+
end
|
87
|
+
expect(mail.from).to eq(["test@gmail.com"])
|
88
|
+
expect(mail.to).to eq(["friend@gmail.com"])
|
89
|
+
expect(mail.subject).to eq("Hello world!")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "#compose automatically adds `from` header when it is not specified" do
|
93
|
+
mail = mock_client.compose
|
94
|
+
expect(mail.from).to eq([TEST_ACCOUNT[0]])
|
95
|
+
mail = mock_client.compose(Mail.new)
|
96
|
+
expect(mail.from).to eq([TEST_ACCOUNT[0]])
|
97
|
+
mail = mock_client.compose {}
|
98
|
+
expect(mail.from).to eq([TEST_ACCOUNT[0]])
|
99
|
+
end
|
100
|
+
|
101
|
+
it "delivers inline composed email" do
|
102
|
+
pending
|
103
|
+
mock_client do |client|
|
104
|
+
response = client.deliver do
|
105
|
+
to TEST_ACCOUNT[0]
|
106
|
+
subject "Hello world!"
|
107
|
+
body "Yeah, hello there!"
|
108
|
+
end
|
109
|
+
|
110
|
+
expect(response).to be_truthy
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it "does not raise error when mail can't be delivered and errors are disabled" do
|
115
|
+
expect(-> {
|
116
|
+
client = mock_client
|
117
|
+
expect(client.deliver(Mail.new {})).to be_falsey
|
118
|
+
}).to_not raise_error
|
119
|
+
end
|
120
|
+
|
121
|
+
it "raises error when mail can't be delivered and errors are disabled" do
|
122
|
+
expect(-> {
|
123
|
+
client = mock_client
|
124
|
+
client.deliver!(Mail.new {})
|
125
|
+
}).to raise_error(Gmail::Client::DeliveryError)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "properly switches to given mailbox" do
|
129
|
+
pending
|
130
|
+
mock_client do |client|
|
131
|
+
mailbox = client.mailbox("TEST")
|
132
|
+
expect(mailbox).to be_kind_of(Gmail::Mailbox)
|
133
|
+
expect(mailbox.name).to eq("TEST")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
it "properly switches to given mailbox using block style" do
|
138
|
+
pending
|
139
|
+
mock_client do |client|
|
140
|
+
client.mailbox("TEST") do |mailbox|
|
141
|
+
expect(mailbox).to be_kind_of(Gmail::Mailbox)
|
142
|
+
expect(mailbox.name).to eq("TEST")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "labels" do
|
148
|
+
subject {
|
149
|
+
client = Gmail::Client::XOAuth2.new(*TEST_ACCOUNT)
|
150
|
+
client.connect
|
151
|
+
client.labels
|
152
|
+
}
|
153
|
+
|
154
|
+
it "returns list of all available labels" do
|
155
|
+
pending
|
156
|
+
labels = subject
|
157
|
+
expect(labels.all).to include("TEST", "INBOX")
|
158
|
+
end
|
159
|
+
|
160
|
+
it "checks if there is given label defined" do
|
161
|
+
pending
|
162
|
+
labels = subject
|
163
|
+
expect(labels.exists?("TEST")).to be_truthy
|
164
|
+
expect(labels.exists?("FOOBAR")).to be_falsey
|
165
|
+
end
|
166
|
+
|
167
|
+
it "creates given label" do
|
168
|
+
pending
|
169
|
+
labels = subject
|
170
|
+
labels.create("MYLABEL")
|
171
|
+
expect(labels.exists?("MYLABEL")).to be_truthy
|
172
|
+
expect(labels.create("MYLABEL")).to be_falsey
|
173
|
+
labels.delete("MYLABEL")
|
174
|
+
end
|
175
|
+
|
176
|
+
it "removes existing label" do
|
177
|
+
pending
|
178
|
+
labels = subject
|
179
|
+
labels.create("MYLABEL")
|
180
|
+
expect(labels.delete("MYLABEL")).to be_truthy
|
181
|
+
expect(labels.exists?("MYLABEL")).to be_falsey
|
182
|
+
expect(labels.delete("MYLABEL")).to be_falsey
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Gmail::Client::XOAuth do
|
4
|
-
skip "add some examples to (or delete) #{__FILE__}"
|
5
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gmail::Client::XOAuth do
|
4
|
+
skip "add some examples to (or delete) #{__FILE__}"
|
5
|
+
end
|
data/spec/gmail/client_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Gmail::Client do
|
4
|
-
skip "add some examples to (or delete) #{__FILE__}"
|
5
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gmail::Client do
|
4
|
+
skip "add some examples to (or delete) #{__FILE__}"
|
5
|
+
end
|
@@ -1,12 +1,47 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rspec'
|
3
|
-
require 'net/imap'
|
4
|
-
require 'gmail/imap_extensions'
|
5
|
-
|
6
|
-
describe Gmail::ImapExtensions do
|
7
|
-
it 'does not modify arity' do
|
8
|
-
Gmail::ImapExtensions::patch_net_imap_response_parser
|
9
|
-
expect(Net::IMAP::ResponseParser.new).to respond_to(:msg_att).with(0).arguments
|
10
|
-
expect(Net::IMAP::ResponseParser.new).to respond_to(:msg_att).with(1).arguments
|
11
|
-
end
|
12
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
require 'net/imap'
|
4
|
+
require 'gmail/imap_extensions'
|
5
|
+
|
6
|
+
describe Gmail::ImapExtensions do
|
7
|
+
it 'does not modify arity' do
|
8
|
+
Gmail::ImapExtensions::patch_net_imap_response_parser
|
9
|
+
expect(Net::IMAP::ResponseParser.new).to respond_to(:msg_att).with(0).arguments
|
10
|
+
expect(Net::IMAP::ResponseParser.new).to respond_to(:msg_att).with(1).arguments
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'parses 1 label without spaces correctly' do
|
14
|
+
Gmail::ImapExtensions::patch_net_imap_response_parser
|
15
|
+
server_response = %[* 1 FETCH (X-GM-LABELS (Hello))\r\n]
|
16
|
+
parsed_labels = Net::IMAP::ResponseParser.new.parse(server_response).data.attr["X-GM-LABELS"]
|
17
|
+
expect(parsed_labels).to contain_exactly("Hello")
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'parses 2 label without spaces correctly' do
|
21
|
+
Gmail::ImapExtensions::patch_net_imap_response_parser
|
22
|
+
server_response = %[* 1 FETCH (X-GM-LABELS (Hello World))\r\n]
|
23
|
+
parsed_labels = Net::IMAP::ResponseParser.new.parse(server_response).data.attr["X-GM-LABELS"]
|
24
|
+
expect(parsed_labels).to contain_exactly("World", "Hello")
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'parses 1 label with a space correctly' do
|
28
|
+
Gmail::ImapExtensions::patch_net_imap_response_parser
|
29
|
+
server_response = %[* 1 FETCH (X-GM-LABELS ("Hello World"))\r\n]
|
30
|
+
parsed_labels = Net::IMAP::ResponseParser.new.parse(server_response).data.attr["X-GM-LABELS"]
|
31
|
+
expect(parsed_labels).to contain_exactly("Hello World")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'parses 2 labels, each with a space, correctly' do
|
35
|
+
Gmail::ImapExtensions::patch_net_imap_response_parser
|
36
|
+
server_response = %[* 1 FETCH (X-GM-LABELS ("Foo Bar" "Hello World"))\r\n]
|
37
|
+
parsed_labels = Net::IMAP::ResponseParser.new.parse(server_response).data.attr["X-GM-LABELS"]
|
38
|
+
expect(parsed_labels).to contain_exactly("Hello World", "Foo Bar")
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'parses a mixture of space and non-space labels correctly' do
|
42
|
+
Gmail::ImapExtensions::patch_net_imap_response_parser
|
43
|
+
server_response = %[* 1 FETCH (X-GM-LABELS ("Foo Bar" "\\Important" Hello World))\r\n]
|
44
|
+
parsed_labels = Net::IMAP::ResponseParser.new.parse(server_response).data.attr["X-GM-LABELS"]
|
45
|
+
expect(parsed_labels).to contain_exactly(:Important, "Hello", "World", "Foo Bar")
|
46
|
+
end
|
47
|
+
end
|