author | Mahlon E. Smith <mahlon@martini.nu> |
Thu, 03 Oct 2019 11:46:05 -0700 | |
changeset 29 | 5e07ff7d5601 |
parent 24 | f8873b391f3d |
permissions | -rw-r--r-- |
15 | 1 |
# vim: set nosta noet ts=4 sw=4 ft=rspec: |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
2 |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
3 |
require_relative '../spec_helpers' |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
4 |
|
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
5 |
describe Ezmlm::List do |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
6 |
|
14 | 7 |
before( :each ) do |
8 |
@listdir = make_listdir() |
|
9 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
10 |
|
14 | 11 |
after( :each ) do |
12 |
rm_r( @listdir ) |
|
13 |
end |
|
14 |
||
15 |
let( :list ) do |
|
16 |
described_class.new( @listdir ) |
|
17 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
18 |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
19 |
|
15 | 20 |
it "returns the list name" do |
14 | 21 |
expect( list.name ).to eq( TEST_LIST_NAME ) |
22 |
end |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
23 |
|
15 | 24 |
it "returns the list host" do |
14 | 25 |
expect( list.host ).to eq( TEST_LIST_HOST ) |
26 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
27 |
|
15 | 28 |
it "returns the list address" do |
14 | 29 |
expect( list.address ).to eq( TEST_LIST_NAME + '@' + TEST_LIST_HOST ) |
30 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
31 |
|
14 | 32 |
it "returns nil if the list owner isn't an email address" do |
33 |
expect( list.owner ).to eq( nil ) |
|
34 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
35 |
|
15 | 36 |
it "returns an email address owner" do |
14 | 37 |
expect( list ).to receive( :read ).with( 'owner' ).and_return( TEST_OWNER ) |
38 |
expect( list.owner ).to eq( TEST_OWNER ) |
|
39 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
40 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
41 |
|
14 | 42 |
it "can add a new subscriber" do |
43 |
list.add_subscriber( *TEST_SUBSCRIBERS ) |
|
44 |
expect( list.is_subscriber?( TEST_SUBSCRIBERS.first ) ).to be_truthy |
|
45 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
46 |
|
15 | 47 |
it "returns the list of subscibers" do |
14 | 48 |
list.add_subscriber( *TEST_SUBSCRIBERS ) |
49 |
list.add_subscriber( 'notanemailaddress' ) |
|
50 |
expect( list.subscribers.length ).to eq( 3 ) |
|
51 |
expect( list.subscribers ).to include( TEST_SUBSCRIBERS.first ) |
|
52 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
53 |
|
14 | 54 |
it "can remove a current subscriber" do |
55 |
list.add_subscriber( *TEST_SUBSCRIBERS ) |
|
56 |
list.remove_subscriber( 'notanemailaddress' ) |
|
57 |
list.remove_subscriber( TEST_MODERATORS.first ) |
|
58 |
expect( list.subscribers.length ).to eq( 2 ) |
|
59 |
end |
|
5
804e1c2b9a40
* Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents:
4
diff
changeset
|
60 |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
61 |
|
14 | 62 |
it "can add a new moderator" do |
63 |
list.add_moderator( *TEST_MODERATORS ) |
|
64 |
expect( list.is_moderator?( TEST_MODERATORS.first ) ).to be_truthy |
|
65 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
66 |
|
15 | 67 |
it "returns the list of moderators" do |
14 | 68 |
list.add_moderator( *TEST_MODERATORS ) |
69 |
expect( list.moderators.length ).to eq( 1 ) |
|
70 |
expect( list.moderators ).to include( TEST_MODERATORS.first ) |
|
71 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
72 |
|
14 | 73 |
it "can remove a current moderator" do |
74 |
list.add_moderator( *TEST_MODERATORS ) |
|
75 |
list.remove_moderator( TEST_MODERATORS.first ) |
|
76 |
expect( list.moderators ).to be_empty |
|
77 |
end |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
78 |
|
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
79 |
|
14 | 80 |
it "can add a blacklisted address" do |
81 |
list.add_blacklisted( *TEST_MODERATORS ) |
|
82 |
expect( list.is_blacklisted?( TEST_MODERATORS.first ) ).to be_truthy |
|
83 |
end |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
84 |
|
15 | 85 |
it "returns the list of blacklisted addresses" do |
14 | 86 |
list.add_blacklisted( *TEST_MODERATORS ) |
87 |
expect( list.blacklisted.length ).to eq( 1 ) |
|
88 |
expect( list.blacklisted ).to include( TEST_MODERATORS.first ) |
|
89 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
90 |
|
14 | 91 |
it "can remove a blacklisted address" do |
92 |
list.add_blacklisted( *TEST_MODERATORS ) |
|
93 |
list.remove_blacklisted( TEST_MODERATORS.first ) |
|
94 |
expect( list.blacklisted ).to be_empty |
|
95 |
end |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
96 |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
97 |
|
14 | 98 |
it "can add an allowed address" do |
99 |
list.add_allowed( *TEST_MODERATORS ) |
|
100 |
expect( list.is_allowed?( TEST_MODERATORS.first ) ).to be_truthy |
|
101 |
end |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
102 |
|
15 | 103 |
it "returns the list of allowed addresses" do |
14 | 104 |
list.add_allowed( *TEST_MODERATORS ) |
105 |
expect( list.allowed.length ).to eq( 1 ) |
|
106 |
expect( list.allowed ).to include( TEST_MODERATORS.first ) |
|
107 |
end |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
108 |
|
14 | 109 |
it "can remove a allowed address" do |
110 |
list.add_allowed( *TEST_MODERATORS ) |
|
111 |
list.remove_allowed( TEST_MODERATORS.first ) |
|
112 |
expect( list.allowed ).to be_empty |
|
113 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
114 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
115 |
|
15 | 116 |
it 'returns the current public/private state' do |
14 | 117 |
expect( list.public? ).to be_truthy |
118 |
expect( list.private? ).to be_falsey |
|
119 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
120 |
|
14 | 121 |
it 'can set the privacy state' do |
122 |
list.public = false |
|
123 |
expect( list.public? ).to be_falsey |
|
124 |
expect( list.private? ).to be_truthy |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
125 |
|
14 | 126 |
list.private = false |
127 |
expect( list.private? ).to be_falsey |
|
128 |
expect( list.public? ).to be_truthy |
|
129 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
130 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
131 |
|
14 | 132 |
it 'can set the remote subscription state' do |
133 |
expect( list.remote_subscriptions? ).to be_falsey |
|
134 |
list.remote_subscriptions = true |
|
135 |
expect( list.remote_subscriptions? ).to be_truthy |
|
136 |
list.remote_subscriptions = false |
|
137 |
expect( list.remote_subscriptions? ).to be_falsey |
|
138 |
end |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
139 |
|
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
140 |
|
14 | 141 |
it 'can set subscription moderation state' do |
142 |
expect( list.moderated_subscriptions? ).to be_falsey |
|
143 |
list.moderated_subscriptions = true |
|
144 |
expect( list.moderated_subscriptions? ).to be_truthy |
|
145 |
list.moderated_subscriptions = false |
|
146 |
expect( list.moderated_subscriptions? ).to be_falsey |
|
147 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
148 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
149 |
|
14 | 150 |
it 'can set posting moderation state' do |
151 |
expect( list.moderated? ).to be_falsey |
|
152 |
list.moderated = true |
|
153 |
expect( list.moderated? ).to be_truthy |
|
154 |
list.moderated = false |
|
155 |
expect( list.moderated? ).to be_falsey |
|
2
7b5a0131d5cd
Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents:
1
diff
changeset
|
156 |
end |
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
157 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
158 |
|
14 | 159 |
it 'can set moderation-only posting' do |
160 |
expect( list.moderator_posts_only? ).to be_falsey |
|
161 |
list.moderator_posts_only = true |
|
162 |
expect( list.moderator_posts_only? ).to be_truthy |
|
163 |
list.moderator_posts_only = false |
|
164 |
expect( list.moderator_posts_only? ).to be_falsey |
|
165 |
end |
|
166 |
||
167 |
||
168 |
it 'can set user-only posting' do |
|
169 |
expect( list.user_posts_only? ).to be_falsey |
|
170 |
list.user_posts_only = true |
|
171 |
expect( list.user_posts_only? ).to be_truthy |
|
172 |
list.user_posts_only = false |
|
173 |
expect( list.user_posts_only? ).to be_falsey |
|
174 |
end |
|
175 |
||
176 |
||
177 |
it 'user+moderation together sets non-subscriber moderation' do |
|
178 |
expect( list.user_posts_only? ).to be_falsey |
|
179 |
expect( list.moderated? ).to be_falsey |
|
180 |
||
181 |
list.moderated = true |
|
182 |
list.user_posts_only = true |
|
183 |
||
184 |
expect( list.listdir + 'noreturnposts' ).to exist |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
185 |
|
14 | 186 |
list.moderated = false |
187 |
expect( list.listdir + 'noreturnposts' ).to_not exist |
|
188 |
end |
|
189 |
||
190 |
||
191 |
it 'can set archival status' do |
|
192 |
expect( list.archived? ).to be_truthy |
|
17 | 193 |
list.archived = false |
14 | 194 |
expect( list.archived? ).to be_falsey |
17 | 195 |
list.archived = true |
14 | 196 |
expect( list.archived? ).to be_truthy |
197 |
end |
|
198 |
||
199 |
||
200 |
it 'can limit archive access to moderators only' do |
|
201 |
expect( list.private_archive? ).to be_falsey |
|
202 |
list.private_archive = true |
|
203 |
expect( list.private_archive? ).to be_truthy |
|
204 |
list.private_archive = false |
|
205 |
expect( list.private_archive? ).to be_falsey |
|
206 |
end |
|
207 |
||
208 |
||
209 |
it 'can limit archive access to list subscribers only' do |
|
210 |
expect( list.guarded_archive? ).to be_falsey |
|
211 |
list.guarded_archive = true |
|
212 |
expect( list.guarded_archive? ).to be_truthy |
|
213 |
list.guarded_archive = false |
|
214 |
expect( list.guarded_archive? ).to be_falsey |
|
215 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
216 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
217 |
|
14 | 218 |
it 'can toggle digest status' do |
219 |
expect( list.digested? ).to be_falsey |
|
220 |
list.digest = true |
|
221 |
expect( list.digested? ).to be_truthy |
|
222 |
list.digest = false |
|
223 |
expect( list.digested? ).to be_falsey |
|
224 |
end |
|
225 |
||
226 |
it 'returns a default digest kbyte size' do |
|
227 |
expect( list.digest_kbytesize ).to eq( 64 ) |
|
228 |
end |
|
229 |
||
230 |
it 'can set a new digest kbyte size' do |
|
231 |
list.digest_kbytesize = 300 |
|
232 |
expect( list.digest_kbytesize ).to eq( 300 ) |
|
233 |
end |
|
234 |
||
235 |
it 'returns a default digest message count' do |
|
236 |
expect( list.digest_count ).to eq( 10 ) |
|
237 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
238 |
|
24
f8873b391f3d
Add a "last activity" method to quickly determine when a list was last used. Bump version.
Mahlon E. Smith <mahlon@laika.com>
parents:
17
diff
changeset
|
239 |
it 'knows the date of the most recent posting' do |
f8873b391f3d
Add a "last activity" method to quickly determine when a list was last used. Bump version.
Mahlon E. Smith <mahlon@laika.com>
parents:
17
diff
changeset
|
240 |
expect( list.last_activity ).to be_a( Time ) |
f8873b391f3d
Add a "last activity" method to quickly determine when a list was last used. Bump version.
Mahlon E. Smith <mahlon@laika.com>
parents:
17
diff
changeset
|
241 |
end |
f8873b391f3d
Add a "last activity" method to quickly determine when a list was last used. Bump version.
Mahlon E. Smith <mahlon@laika.com>
parents:
17
diff
changeset
|
242 |
|
14 | 243 |
it 'can set a new digest message count' do |
244 |
list.digest_count = 25 |
|
245 |
expect( list.digest_count ).to eq( 25 ) |
|
246 |
end |
|
247 |
||
248 |
it 'returns a default digest timeout' do |
|
249 |
expect( list.digest_timeout ).to eq( 48 ) |
|
250 |
end |
|
251 |
||
252 |
it 'can set a new digest timeout' do |
|
253 |
list.digest_timeout = 24 |
|
254 |
expect( list.digest_timeout ).to eq( 24 ) |
|
255 |
end |
|
256 |
||
257 |
||
258 |
it 'can set subscription confirmation' do |
|
259 |
expect( list.confirm_subscriptions? ).to be_truthy |
|
260 |
list.confirm_subscriptions = false |
|
261 |
expect( list.confirm_subscriptions? ).to be_falsey |
|
262 |
list.confirm_subscriptions = true |
|
263 |
expect( list.confirm_subscriptions? ).to be_truthy |
|
264 |
end |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
265 |
|
14 | 266 |
it 'can set unsubscription confirmation' do |
267 |
expect( list.confirm_unsubscriptions? ).to be_truthy |
|
268 |
list.confirm_unsubscriptions = false |
|
269 |
expect( list.confirm_unsubscriptions? ).to be_falsey |
|
270 |
list.confirm_unsubscriptions = true |
|
271 |
expect( list.confirm_unsubscriptions? ).to be_truthy |
|
272 |
end |
|
273 |
||
274 |
||
275 |
it 'can set message posting confirmation' do |
|
276 |
expect( list.confirm_postings? ).to be_falsey |
|
277 |
list.confirm_postings = true |
|
278 |
expect( list.confirm_postings? ).to be_truthy |
|
279 |
list.confirm_postings = false |
|
280 |
expect( list.confirm_postings? ).to be_falsey |
|
281 |
end |
|
282 |
||
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
283 |
|
14 | 284 |
it 'can toggle remote subscriber lists for moderators' do |
285 |
expect( list.allow_remote_listing? ).to be_falsey |
|
286 |
list.allow_remote_listing = true |
|
287 |
expect( list.allow_remote_listing? ).to be_truthy |
|
288 |
list.allow_remote_listing = false |
|
289 |
expect( list.allow_remote_listing? ).to be_falsey |
|
290 |
end |
|
291 |
||
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
292 |
|
14 | 293 |
it 'can toggle bounce management' do |
294 |
expect( list.bounce_warnings? ).to be_truthy |
|
295 |
list.bounce_warnings = false |
|
296 |
expect( list.bounce_warnings? ).to be_falsey |
|
297 |
list.bounce_warnings = true |
|
298 |
expect( list.bounce_warnings? ).to be_truthy |
|
299 |
end |
|
300 |
||
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
301 |
|
14 | 302 |
it 'returns a default max message size' do |
303 |
expect( list.maximum_message_size ).to eq( 0 ) |
|
304 |
end |
|
305 |
||
306 |
it 'can set a new max message size' do |
|
307 |
list.maximum_message_size = 1024 * 300 |
|
308 |
expect( list.maximum_message_size ).to eq( 307200 ) |
|
309 |
end |
|
310 |
||
311 |
||
15 | 312 |
it 'can return the total message count for a pristine list' do |
313 |
expect( list ).to receive( :read ).with( 'archnum' ).and_return( nil ) |
|
14 | 314 |
expect( list.message_count ).to eq( 0 ) |
315 |
end |
|
15 | 316 |
|
317 |
it 'can return the total message count for a list with deliveries' do |
|
318 |
expect( list.message_count ).to eq( 150 ) |
|
319 |
end |
|
320 |
||
321 |
||
322 |
it 'can generate a message number to thread index' do |
|
323 |
idx = list.index |
|
324 |
expect( idx.size ).to be( 150 ) |
|
325 |
expect( idx[39][:thread] ).to eq( 'cadgeokhhaieijmndokb' ) |
|
326 |
end |
|
327 |
||
328 |
||
329 |
it 'fetches thread objects upon request' do |
|
330 |
expect( list.thread('cadgeokhhaieijmndokb') ).to be_a( Ezmlm::List::Thread ) |
|
331 |
end |
|
332 |
||
17 | 333 |
it 'returns nil when fetching an invalid thread' do |
334 |
expect( list.thread('whatever') ).to be_nil |
|
335 |
end |
|
336 |
||
15 | 337 |
|
338 |
it 'fetches author objects upon request' do |
|
339 |
expect( list.author('ojjhjlapnejjlbcplabi') ).to be_a( Ezmlm::List::Author ) |
|
340 |
end |
|
341 |
||
16
e135ccae6783
Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents:
15
diff
changeset
|
342 |
it 'fetches author objects by email address' do |
e135ccae6783
Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents:
15
diff
changeset
|
343 |
author = list.author( 'ojjhjlapnejjlbcplabi' ) |
e135ccae6783
Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents:
15
diff
changeset
|
344 |
expect( list.author('yvette@example.net').name ).to eq( author.name ) |
e135ccae6783
Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents:
15
diff
changeset
|
345 |
end |
e135ccae6783
Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents:
15
diff
changeset
|
346 |
|
17 | 347 |
it 'returns nil when fetching an invalid author' do |
348 |
expect( list.author('whatever') ).to be_nil |
|
349 |
end |
|
350 |
||
15 | 351 |
|
352 |
context 'fetching messages' do |
|
17 | 353 |
it 'returns nil if archiving is disabled' do |
15 | 354 |
expect( list ).to receive( :archived? ).and_return( false ) |
17 | 355 |
expect( list.message(1) ).to be_nil |
356 |
end |
|
357 |
||
358 |
it 'returns nil when fetching an invalid message id' do |
|
359 |
expect( list.message(2389234) ).to be_nil |
|
15 | 360 |
end |
361 |
||
362 |
it 'raises an error if the message archive is empty' do |
|
363 |
expect( list ).to receive( :message_count ).and_return( 0 ) |
|
364 |
expect { |
|
365 |
list.message( 1 ) |
|
366 |
}.to raise_error( RuntimeError, /message archive is empty/i ) |
|
367 |
end |
|
368 |
||
369 |
it 'returns an archived message' do |
|
370 |
message = list.message( 1 ) |
|
371 |
expect( message.id ).to be( 1 ) |
|
372 |
expect( message.subject ).to match( /compress program/ ) |
|
373 |
end |
|
374 |
||
375 |
it 'can iterate across all messages' do |
|
376 |
message = nil |
|
377 |
list.each_message do |m| |
|
378 |
if m.id == 20 |
|
379 |
message = m |
|
380 |
break |
|
381 |
end |
|
382 |
end |
|
383 |
expect( message ).to_not be_nil |
|
384 |
expect( message.id ).to be( 20 ) |
|
385 |
end |
|
386 |
end |
|
14 | 387 |
end |
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
388 |