mailboxer 0.12.4 → 0.12.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,15 +12,15 @@ describe "Mailboxer::Models::Messageable through User" do
12
12
  end
13
13
 
14
14
  it 'should return the inbox count' do
15
- @entity1.unread_inbox_count.should == 0
15
+ expect(@entity1.unread_inbox_count).to eq 0
16
16
  @entity2.send_message(@entity1,"Body","Subject")
17
17
  @entity2.send_message(@entity1,"Body","Subject")
18
- @entity1.unread_inbox_count.should == 2
18
+ expect(@entity1.unread_inbox_count).to eq 2
19
19
  @entity1.receipts.first.mark_as_read
20
- @entity1.unread_inbox_count.should == 1
20
+ expect(@entity1.unread_inbox_count).to eq 1
21
21
  @entity2.send_message(@entity1,"Body","Subject")
22
22
  @entity2.send_message(@entity1,"Body","Subject")
23
- @entity1.unread_inbox_count.should == 3
23
+ expect(@entity1.unread_inbox_count).to eq 3
24
24
  end
25
25
 
26
26
  it "should be able to send a message" do
@@ -39,62 +39,62 @@ describe "Mailboxer::Models::Messageable through User" do
39
39
 
40
40
  it "should be able to unread an owned Mailboxer::Receipt (mark as unread)" do
41
41
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
42
- @receipt.is_read.should==true
42
+ expect(@receipt.is_read).to eq true
43
43
  @entity1.mark_as_unread(@receipt)
44
- @receipt.is_read.should==false
44
+ expect(@receipt.is_read).to eq false
45
45
  end
46
46
 
47
47
  it "should be able to read an owned Mailboxer::Receipt (mark as read)" do
48
48
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
49
- @receipt.is_read.should==true
49
+ expect(@receipt.is_read).to eq true
50
50
  @entity1.mark_as_unread(@receipt)
51
51
  @entity1.mark_as_read(@receipt)
52
- @receipt.is_read.should==true
52
+ expect(@receipt.is_read).to eq true
53
53
  end
54
54
 
55
55
  it "should not be able to unread a not owned Mailboxer::Receipt (mark as unread)" do
56
56
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
57
- @receipt.is_read.should==true
57
+ expect(@receipt.is_read).to eq true
58
58
  @entity2.mark_as_unread(@receipt) #Should not change
59
- @receipt.is_read.should==true
59
+ expect(@receipt.is_read).to eq true
60
60
  end
61
61
 
62
62
  it "should not be able to read a not owned Mailboxer::Receipt (mark as read)" do
63
63
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
64
- @receipt.is_read.should==true
64
+ expect(@receipt.is_read).to eq true
65
65
  @entity1.mark_as_unread(@receipt) #From read to unread
66
66
  @entity2.mark_as_read(@receipt) #Should not change
67
- @receipt.is_read.should==false
67
+ expect(@receipt.is_read).to eq false
68
68
  end
69
69
 
70
70
  it "should be able to trash an owned Mailboxer::Receipt" do
71
71
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
72
- @receipt.trashed.should==false
72
+ expect(@receipt.trashed).to eq false
73
73
  @entity1.trash(@receipt)
74
- @receipt.trashed.should==true
74
+ expect(@receipt.trashed).to eq true
75
75
  end
76
76
 
77
77
  it "should be able to untrash an owned Mailboxer::Receipt" do
78
78
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
79
- @receipt.trashed.should==false
79
+ expect(@receipt.trashed).to eq false
80
80
  @entity1.trash(@receipt)
81
81
  @entity1.untrash(@receipt)
82
- @receipt.trashed.should==false
82
+ expect(@receipt.trashed).to eq false
83
83
  end
84
84
 
85
85
  it "should not be able to trash a not owned Mailboxer::Receipt" do
86
86
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
87
- @receipt.trashed.should==false
87
+ expect(@receipt.trashed).to eq false
88
88
  @entity2.trash(@receipt) #Should not change
89
- @receipt.trashed.should==false
89
+ expect(@receipt.trashed).to eq false
90
90
  end
91
91
 
92
92
  it "should not be able to untrash a not owned Mailboxer::Receipt" do
93
93
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
94
- @receipt.trashed.should==false
94
+ expect(@receipt.trashed).to eq false
95
95
  @entity1.trash(@receipt) #From read to unread
96
96
  @entity2.untrash(@receipt) #Should not change
97
- @receipt.trashed.should==true
97
+ expect(@receipt.trashed).to eq true
98
98
  end
99
99
 
100
100
 
@@ -102,69 +102,69 @@ describe "Mailboxer::Models::Messageable through User" do
102
102
  it "should be able to unread an owned Message (mark as unread)" do
103
103
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
104
104
  @message = @receipt.message
105
- @receipt.is_read.should==true
105
+ expect(@receipt.is_read).to eq true
106
106
  @entity1.mark_as_unread(@message)
107
- @message.receipt_for(@entity1).first.is_read.should==false
107
+ expect(@message.receipt_for(@entity1).first.is_read).to eq false
108
108
  end
109
109
 
110
110
  it "should be able to read an owned Message (mark as read)" do
111
111
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
112
112
  @message = @receipt.message
113
- @receipt.is_read.should==true
113
+ expect(@receipt.is_read).to eq true
114
114
  @entity1.mark_as_unread(@message)
115
115
  @entity1.mark_as_read(@message)
116
- @message.receipt_for(@entity1).first.is_read.should==true
116
+ expect(@message.receipt_for(@entity1).first.is_read).to eq true
117
117
  end
118
118
 
119
119
  it "should not be able to unread a not owned Message (mark as unread)" do
120
120
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
121
121
  @message = @receipt.message
122
- @receipt.is_read.should==true
122
+ expect(@receipt.is_read).to eq true
123
123
  @entity2.mark_as_unread(@message) #Should not change
124
- @message.receipt_for(@entity1).first.is_read.should==true
124
+ expect(@message.receipt_for(@entity1).first.is_read).to eq true
125
125
  end
126
126
 
127
127
  it "should not be able to read a not owned Message (mark as read)" do
128
128
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
129
129
  @message = @receipt.message
130
- @receipt.is_read.should==true
130
+ expect(@receipt.is_read).to eq true
131
131
  @entity1.mark_as_unread(@message) #From read to unread
132
132
  @entity2.mark_as_read(@message) #Should not change
133
- @message.receipt_for(@entity1).first.is_read.should==false
133
+ expect(@message.receipt_for(@entity1).first.is_read).to eq false
134
134
  end
135
135
 
136
136
  it "should be able to trash an owned Message" do
137
137
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
138
138
  @message = @receipt.message
139
- @receipt.trashed.should==false
139
+ expect(@receipt.trashed).to eq false
140
140
  @entity1.trash(@message)
141
- @message.receipt_for(@entity1).first.trashed.should==true
141
+ expect(@message.receipt_for(@entity1).first.trashed).to eq true
142
142
  end
143
143
 
144
144
  it "should be able to untrash an owned Message" do
145
145
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
146
146
  @message = @receipt.message
147
- @receipt.trashed.should==false
147
+ expect(@receipt.trashed).to eq false
148
148
  @entity1.trash(@message)
149
149
  @entity1.untrash(@message)
150
- @message.receipt_for(@entity1).first.trashed.should==false
150
+ expect(@message.receipt_for(@entity1).first.trashed).to eq false
151
151
  end
152
152
 
153
153
  it "should not be able to trash a not owned Message" do
154
154
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
155
155
  @message = @receipt.message
156
- @receipt.trashed.should==false
156
+ expect(@receipt.trashed).to eq false
157
157
  @entity2.trash(@message) #Should not change
158
- @message.receipt_for(@entity1).first.trashed.should==false
158
+ expect(@message.receipt_for(@entity1).first.trashed).to eq false
159
159
  end
160
160
 
161
161
  it "should not be able to untrash a not owned Message" do
162
162
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
163
163
  @message = @receipt.message
164
- @receipt.trashed.should==false
164
+ expect(@receipt.trashed).to eq false
165
165
  @entity1.trash(@message) #From read to unread
166
166
  @entity2.untrash(@message) #Should not change
167
- @message.receipt_for(@entity1).first.trashed.should==true
167
+ expect(@message.receipt_for(@entity1).first.trashed).to eq true
168
168
  end
169
169
 
170
170
 
@@ -172,69 +172,69 @@ describe "Mailboxer::Models::Messageable through User" do
172
172
  it "should be able to unread an owned Notification (mark as unread)" do
173
173
  @receipt = @entity1.notify("Subject","Body")
174
174
  @notification = @receipt.notification
175
- @receipt.is_read.should==false
175
+ expect(@receipt.is_read).to eq false
176
176
  @entity1.mark_as_read(@notification)
177
177
  @entity1.mark_as_unread(@notification)
178
- @notification.receipt_for(@entity1).first.is_read.should==false
178
+ expect(@notification.receipt_for(@entity1).first.is_read).to eq false
179
179
  end
180
180
 
181
181
  it "should be able to read an owned Notification (mark as read)" do
182
182
  @receipt = @entity1.notify("Subject","Body")
183
183
  @notification = @receipt.notification
184
- @receipt.is_read.should==false
184
+ expect(@receipt.is_read).to eq false
185
185
  @entity1.mark_as_read(@notification)
186
- @notification.receipt_for(@entity1).first.is_read.should==true
186
+ expect(@notification.receipt_for(@entity1).first.is_read).to eq true
187
187
  end
188
188
 
189
189
  it "should not be able to unread a not owned Notification (mark as unread)" do
190
190
  @receipt = @entity1.notify("Subject","Body")
191
191
  @notification = @receipt.notification
192
- @receipt.is_read.should==false
192
+ expect(@receipt.is_read).to eq false
193
193
  @entity1.mark_as_read(@notification)
194
194
  @entity2.mark_as_unread(@notification)
195
- @notification.receipt_for(@entity1).first.is_read.should==true
195
+ expect(@notification.receipt_for(@entity1).first.is_read).to eq true
196
196
  end
197
197
 
198
198
  it "should not be able to read a not owned Notification (mark as read)" do
199
199
  @receipt = @entity1.notify("Subject","Body")
200
200
  @notification = @receipt.notification
201
- @receipt.is_read.should==false
201
+ expect(@receipt.is_read).to eq false
202
202
  @entity2.mark_as_read(@notification)
203
- @notification.receipt_for(@entity1).first.is_read.should==false
203
+ expect(@notification.receipt_for(@entity1).first.is_read).to eq false
204
204
  end
205
205
 
206
206
  it "should be able to trash an owned Notification" do
207
207
  @receipt = @entity1.notify("Subject","Body")
208
208
  @notification = @receipt.notification
209
- @receipt.trashed.should==false
209
+ expect(@receipt.trashed).to eq false
210
210
  @entity1.trash(@notification)
211
- @notification.receipt_for(@entity1).first.trashed.should==true
211
+ expect(@notification.receipt_for(@entity1).first.trashed).to eq true
212
212
  end
213
213
 
214
214
  it "should be able to untrash an owned Notification" do
215
215
  @receipt = @entity1.notify("Subject","Body")
216
216
  @notification = @receipt.notification
217
- @receipt.trashed.should==false
217
+ expect(@receipt.trashed).to eq false
218
218
  @entity1.trash(@notification)
219
219
  @entity1.untrash(@notification)
220
- @notification.receipt_for(@entity1).first.trashed.should==false
220
+ expect(@notification.receipt_for(@entity1).first.trashed).to eq false
221
221
  end
222
222
 
223
223
  it "should not be able to trash a not owned Notification" do
224
224
  @receipt = @entity1.notify("Subject","Body")
225
225
  @notification = @receipt.notification
226
- @receipt.trashed.should==false
226
+ expect(@receipt.trashed).to eq false
227
227
  @entity2.trash(@notification)
228
- @notification.receipt_for(@entity1).first.trashed.should==false
228
+ expect(@notification.receipt_for(@entity1).first.trashed).to eq false
229
229
  end
230
230
 
231
231
  it "should not be able to untrash a not owned Notification" do
232
232
  @receipt = @entity1.notify("Subject","Body")
233
233
  @notification = @receipt.notification
234
- @receipt.trashed.should==false
234
+ expect(@receipt.trashed).to eq false
235
235
  @entity1.trash(@notification)
236
236
  @entity2.untrash(@notification)
237
- @notification.receipt_for(@entity1).first.trashed.should==true
237
+ expect(@notification.receipt_for(@entity1).first.trashed).to eq true
238
238
  end
239
239
 
240
240
 
@@ -242,75 +242,75 @@ describe "Mailboxer::Models::Messageable through User" do
242
242
  it "should be able to unread an owned Conversation (mark as unread)" do
243
243
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
244
244
  @conversation = @receipt.conversation
245
- @receipt.is_read.should==true
245
+ expect(@receipt.is_read).to eq true
246
246
  @entity1.mark_as_unread(@conversation)
247
- @conversation.receipts_for(@entity1).first.is_read.should==false
247
+ expect(@conversation.receipts_for(@entity1).first.is_read).to eq false
248
248
  end
249
249
 
250
250
  it "should be able to read an owned Conversation (mark as read)" do
251
251
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
252
252
  @conversation = @receipt.conversation
253
- @receipt.is_read.should==true
253
+ expect(@receipt.is_read).to eq true
254
254
  @entity1.mark_as_unread(@conversation)
255
255
  @entity1.mark_as_read(@conversation)
256
- @conversation.receipts_for(@entity1).first.is_read.should==true
256
+ expect(@conversation.receipts_for(@entity1).first.is_read).to eq true
257
257
  end
258
258
 
259
259
  it "should not be able to unread a not owned Conversation (mark as unread)" do
260
260
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
261
261
  @conversation = @receipt.conversation
262
- @receipt.is_read.should==true
262
+ expect(@receipt.is_read).to eq true
263
263
  @entity2.mark_as_unread(@conversation)
264
- @conversation.receipts_for(@entity1).first.is_read.should==true
264
+ expect(@conversation.receipts_for(@entity1).first.is_read).to eq true
265
265
  end
266
266
 
267
267
  it "should not be able to read a not owned Conversation (mark as read)" do
268
268
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
269
269
  @conversation = @receipt.conversation
270
- @receipt.is_read.should==true
270
+ expect(@receipt.is_read).to eq true
271
271
  @entity1.mark_as_unread(@conversation)
272
272
  @entity2.mark_as_read(@conversation)
273
- @conversation.receipts_for(@entity1).first.is_read.should==false
273
+ expect(@conversation.receipts_for(@entity1).first.is_read).to eq false
274
274
  end
275
275
 
276
276
  it "should be able to trash an owned Conversation" do
277
277
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
278
278
  @conversation = @receipt.conversation
279
- @receipt.trashed.should==false
279
+ expect(@receipt.trashed).to eq false
280
280
  @entity1.trash(@conversation)
281
- @conversation.receipts_for(@entity1).first.trashed.should==true
281
+ expect(@conversation.receipts_for(@entity1).first.trashed).to eq true
282
282
  end
283
283
 
284
284
  it "should be able to untrash an owned Conversation" do
285
285
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
286
286
  @conversation = @receipt.conversation
287
- @receipt.trashed.should==false
287
+ expect(@receipt.trashed).to eq false
288
288
  @entity1.trash(@conversation)
289
289
  @entity1.untrash(@conversation)
290
- @conversation.receipts_for(@entity1).first.trashed.should==false
290
+ expect(@conversation.receipts_for(@entity1).first.trashed).to eq false
291
291
  end
292
292
 
293
293
  it "should not be able to trash a not owned Conversation" do
294
294
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
295
295
  @conversation = @receipt.conversation
296
- @receipt.trashed.should==false
296
+ expect(@receipt.trashed).to eq false
297
297
  @entity2.trash(@conversation)
298
- @conversation.receipts_for(@entity1).first.trashed.should==false
298
+ expect(@conversation.receipts_for(@entity1).first.trashed).to eq false
299
299
  end
300
300
 
301
301
  it "should not be able to untrash a not owned Conversation" do
302
302
  @receipt = @entity1.send_message(@entity2,"Body","Subject")
303
303
  @conversation = @receipt.conversation
304
- @receipt.trashed.should==false
304
+ expect(@receipt.trashed).to eq false
305
305
  @entity1.trash(@conversation)
306
306
  @entity2.untrash(@conversation)
307
- @conversation.receipts_for(@entity1).first.trashed.should==true
307
+ expect(@conversation.receipts_for(@entity1).first.trashed).to eq true
308
308
  end
309
309
 
310
310
  it "should be able to read attachment" do
311
311
  @receipt = @entity1.send_message(@entity2, "Body", "Subject", nil, File.open('spec/testfile.txt'))
312
312
  @conversation = @receipt.conversation
313
- @conversation.messages.first.attachment_identifier.should=='testfile.txt'
313
+ expect(@conversation.messages.first.attachment_identifier).to eq 'testfile.txt'
314
314
  end
315
315
 
316
316
  it "should be the same message time as passed" do
@@ -319,10 +319,10 @@ describe "Mailboxer::Models::Messageable through User" do
319
319
  # We're going to compare the string representation, because ActiveSupport::TimeWithZone
320
320
  # has microsecond precision in ruby, but some databases don't support this level of precision.
321
321
  expected = message_time.utc.to_s
322
- receipt.message.created_at.utc.to_s.should == expected
323
- receipt.message.updated_at.utc.to_s.should == expected
324
- receipt.message.conversation.created_at.utc.to_s.should == expected
325
- receipt.message.conversation.updated_at.utc.to_s.should == expected
322
+ expect(receipt.message.created_at.utc.to_s).to eq expected
323
+ expect(receipt.message.updated_at.utc.to_s).to eq expected
324
+ expect(receipt.message.conversation.created_at.utc.to_s).to eq expected
325
+ expect(receipt.message.conversation.updated_at.utc.to_s).to eq expected
326
326
  end
327
327
 
328
328
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mailboxer::Message do
4
-
4
+
5
5
  before do
6
6
  @entity1 = FactoryGirl.create(:user)
7
7
  @entity2 = FactoryGirl.create(:user)
@@ -12,19 +12,19 @@ describe Mailboxer::Message do
12
12
  @message1 = @receipt1.notification
13
13
  @message4 = @receipt4.notification
14
14
  @conversation = @message1.conversation
15
- end
16
-
15
+ end
16
+
17
17
  it "should have right recipients" do
18
- @receipt1.notification.recipients.count.should==2
19
- @receipt2.notification.recipients.count.should==2
20
- @receipt3.notification.recipients.count.should==2
21
- @receipt4.notification.recipients.count.should==2
18
+ expect(@receipt1.notification.recipients.count).to eq 2
19
+ expect(@receipt2.notification.recipients.count).to eq 2
20
+ expect(@receipt3.notification.recipients.count).to eq 2
21
+ expect(@receipt4.notification.recipients.count).to eq 2
22
22
  end
23
23
 
24
24
  it "should be able to be marked as deleted" do
25
- @receipt1.deleted.should==false
25
+ expect(@receipt1.deleted).to be false
26
26
  @message1.mark_as_deleted @entity1
27
- @message1.is_deleted?(@entity1).should==true
27
+ expect(@message1.is_deleted?(@entity1)).to be true
28
28
  end
29
-
29
+
30
30
  end
@@ -18,67 +18,67 @@ describe Mailboxer::Notification do
18
18
  @entity1.notify("Subject", "Body")
19
19
 
20
20
  #Check getting ALL receipts
21
- @entity1.mailbox.receipts.size.should==1
21
+ expect(@entity1.mailbox.receipts.size).to eq 1
22
22
  receipt = @entity1.mailbox.receipts.first
23
23
  notification = receipt.notification
24
- notification.subject.should=="Subject"
25
- notification.body.should=="Body"
24
+ expect(notification.subject).to eq "Subject"
25
+ expect(notification.body).to eq "Body"
26
26
 
27
27
  #Check getting NOTIFICATION receipts only
28
- @entity1.mailbox.notifications.size.should==1
28
+ expect(@entity1.mailbox.notifications.size).to eq 1
29
29
  notification = @entity1.mailbox.notifications.first
30
- notification.subject.should=="Subject"
31
- notification.body.should=="Body"
30
+ expect(notification.subject).to eq "Subject"
31
+ expect(notification.body).to eq "Body"
32
32
  end
33
33
 
34
34
  it "should be unread by default" do
35
35
  @entity1.notify("Subject", "Body")
36
- @entity1.mailbox.receipts.size.should==1
36
+ expect(@entity1.mailbox.receipts.size).to eq 1
37
37
  notification = @entity1.mailbox.receipts.first.notification
38
- notification.should be_is_unread(@entity1)
38
+ expect(notification).to be_is_unread(@entity1)
39
39
  end
40
40
 
41
41
  it "should be able to marked as read" do
42
42
  @entity1.notify("Subject", "Body")
43
- @entity1.mailbox.receipts.size.should==1
43
+ expect(@entity1.mailbox.receipts.size).to eq 1
44
44
  notification = @entity1.mailbox.receipts.first.notification
45
45
  notification.mark_as_read(@entity1)
46
- notification.should be_is_read(@entity1)
46
+ expect(notification).to be_is_read(@entity1)
47
47
  end
48
48
 
49
49
  it "should notify several users" do
50
50
  recipients = [@entity1,@entity2,@entity3]
51
51
  Mailboxer::Notification.notify_all(recipients,"Subject","Body")
52
52
  #Check getting ALL receipts
53
- @entity1.mailbox.receipts.size.should==1
53
+ expect(@entity1.mailbox.receipts.size).to eq 1
54
54
  receipt = @entity1.mailbox.receipts.first
55
55
  notification = receipt.notification
56
- notification.subject.should=="Subject"
57
- notification.body.should=="Body"
58
- @entity2.mailbox.receipts.size.should==1
56
+ expect(notification.subject).to eq "Subject"
57
+ expect(notification.body).to eq "Body"
58
+ expect(@entity2.mailbox.receipts.size).to eq 1
59
59
  receipt = @entity2.mailbox.receipts.first
60
60
  notification = receipt.notification
61
- notification.subject.should=="Subject"
62
- notification.body.should=="Body"
63
- @entity3.mailbox.receipts.size.should==1
61
+ expect(notification.subject).to eq "Subject"
62
+ expect(notification.body).to eq "Body"
63
+ expect(@entity3.mailbox.receipts.size).to eq 1
64
64
  receipt = @entity3.mailbox.receipts.first
65
65
  notification = receipt.notification
66
- notification.subject.should=="Subject"
67
- notification.body.should=="Body"
66
+ expect(notification.subject).to eq "Subject"
67
+ expect(notification.body).to eq "Body"
68
68
 
69
69
  #Check getting NOTIFICATION receipts only
70
- @entity1.mailbox.notifications.size.should==1
70
+ expect(@entity1.mailbox.notifications.size).to eq 1
71
71
  notification = @entity1.mailbox.notifications.first
72
- notification.subject.should=="Subject"
73
- notification.body.should=="Body"
74
- @entity2.mailbox.notifications.size.should==1
72
+ expect(notification.subject).to eq "Subject"
73
+ expect(notification.body).to eq "Body"
74
+ expect(@entity2.mailbox.notifications.size).to eq 1
75
75
  notification = @entity2.mailbox.notifications.first
76
- notification.subject.should=="Subject"
77
- notification.body.should=="Body"
78
- @entity3.mailbox.notifications.size.should==1
76
+ expect(notification.subject).to eq "Subject"
77
+ expect(notification.body).to eq "Body"
78
+ expect(@entity3.mailbox.notifications.size).to eq 1
79
79
  notification = @entity3.mailbox.notifications.first
80
- notification.subject.should=="Subject"
81
- notification.body.should=="Body"
80
+ expect(notification.subject).to eq "Subject"
81
+ expect(notification.body).to eq "Body"
82
82
 
83
83
  end
84
84
 
@@ -86,17 +86,17 @@ describe Mailboxer::Notification do
86
86
  Mailboxer::Notification.notify_all(@entity1,"Subject","Body")
87
87
 
88
88
  #Check getting ALL receipts
89
- @entity1.mailbox.receipts.size.should==1
89
+ expect(@entity1.mailbox.receipts.size).to eq 1
90
90
  receipt = @entity1.mailbox.receipts.first
91
91
  notification = receipt.notification
92
- notification.subject.should=="Subject"
93
- notification.body.should=="Body"
92
+ expect(notification.subject).to eq "Subject"
93
+ expect(notification.body).to eq "Body"
94
94
 
95
95
  #Check getting NOTIFICATION receipts only
96
- @entity1.mailbox.notifications.size.should==1
96
+ expect(@entity1.mailbox.notifications.size).to eq 1
97
97
  notification = @entity1.mailbox.notifications.first
98
- notification.subject.should=="Subject"
99
- notification.body.should=="Body"
98
+ expect(notification.subject).to eq "Subject"
99
+ expect(notification.body).to eq "Body"
100
100
  end
101
101
 
102
102
  describe "scopes" do
@@ -107,21 +107,21 @@ describe Mailboxer::Notification do
107
107
  it "finds unread notifications" do
108
108
  unread_notification = scope_user.notify("Body", "Subject").notification
109
109
  notification.mark_as_read(scope_user)
110
- Mailboxer::Notification.unread.last.should == unread_notification
110
+ expect(Mailboxer::Notification.unread.last).to eq unread_notification
111
111
  end
112
112
  end
113
113
 
114
114
  describe ".expired" do
115
115
  it "finds expired notifications" do
116
116
  notification.update_attributes(expires: 1.day.ago)
117
- scope_user.mailbox.notifications.expired.count.should eq(1)
117
+ expect(scope_user.mailbox.notifications.expired.count).to eq(1)
118
118
  end
119
119
  end
120
120
 
121
121
  describe ".unexpired" do
122
122
  it "finds unexpired notifications" do
123
123
  notification.update_attributes(expires: 1.day.from_now)
124
- scope_user.mailbox.notifications.unexpired.count.should eq(1)
124
+ expect(scope_user.mailbox.notifications.unexpired.count).to eq(1)
125
125
  end
126
126
  end
127
127
  end
@@ -131,11 +131,11 @@ describe Mailboxer::Notification do
131
131
 
132
132
  describe "when the notification is already expired" do
133
133
  before do
134
- subject.stub(:expired? => true)
134
+ allow(subject).to receive(:expired?).and_return(true)
135
135
  end
136
136
  it 'should not update the expires attribute' do
137
- subject.should_not_receive :expires=
138
- subject.should_not_receive :save
137
+ expect(subject).not_to receive :expires=
138
+ expect(subject).not_to receive :save
139
139
  subject.expire
140
140
  end
141
141
  end
@@ -144,15 +144,15 @@ describe Mailboxer::Notification do
144
144
  let(:now) { Time.now }
145
145
  let(:one_second_ago) { now - 1.second }
146
146
  before do
147
- Time.stub(:now => now)
148
- subject.stub(:expired? => false)
147
+ allow(Time).to receive(:now).and_return(now)
148
+ allow(subject).to receive(:expired?).and_return(false)
149
149
  end
150
150
  it 'should update the expires attribute' do
151
- subject.should_receive(:expires=).with(one_second_ago)
151
+ expect(subject).to receive(:expires=).with(one_second_ago)
152
152
  subject.expire
153
153
  end
154
154
  it 'should not save the record' do
155
- subject.should_not_receive :save
155
+ expect(subject).not_to receive :save
156
156
  subject.expire
157
157
  end
158
158
  end
@@ -164,11 +164,11 @@ describe Mailboxer::Notification do
164
164
 
165
165
  describe "when the notification is already expired" do
166
166
  before do
167
- subject.stub(:expired? => true)
167
+ allow(subject).to receive(:expired?).and_return(true)
168
168
  end
169
169
  it 'should not call expire' do
170
- subject.should_not_receive :expire
171
- subject.should_not_receive :save
170
+ expect(subject).not_to receive :expire
171
+ expect(subject).not_to receive :save
172
172
  subject.expire!
173
173
  end
174
174
  end
@@ -177,15 +177,15 @@ describe Mailboxer::Notification do
177
177
  let(:now) { Time.now }
178
178
  let(:one_second_ago) { now - 1.second }
179
179
  before do
180
- Time.stub(:now => now)
181
- subject.stub(:expired? => false)
180
+ allow(Time).to receive(:now).and_return(now)
181
+ allow(subject).to receive(:expired?).and_return(false)
182
182
  end
183
183
  it 'should call expire' do
184
- subject.should_receive(:expire)
184
+ expect(subject).to receive(:expire)
185
185
  subject.expire!
186
186
  end
187
187
  it 'should save the record' do
188
- subject.should_receive :save
188
+ expect(subject).to receive :save
189
189
  subject.expire!
190
190
  end
191
191
  end
@@ -195,35 +195,35 @@ describe Mailboxer::Notification do
195
195
  describe "#expired?" do
196
196
  subject { described_class.new }
197
197
  context "when the expiration date is in the past" do
198
- before { subject.stub(:expires => Time.now - 1.second) }
198
+ before { allow(subject).to receive(:expires).and_return(Time.now - 1.second) }
199
199
  it 'should be expired' do
200
- subject.expired?.should be_true
200
+ expect(subject.expired?).to be true
201
201
  end
202
202
  end
203
203
 
204
204
  context "when the expiration date is now" do
205
205
  before {
206
206
  time = Time.now
207
- Time.stub(:now => time)
208
- subject.stub(:expires => time)
207
+ allow(Time).to receive(:now).and_return(time)
208
+ allow(subject).to receive(:expires).and_return(time)
209
209
  }
210
210
 
211
211
  it 'should not be expired' do
212
- subject.expired?.should be_false
212
+ expect(subject.expired?).to be false
213
213
  end
214
214
  end
215
215
 
216
216
  context "when the expiration date is in the future" do
217
- before { subject.stub(:expires => Time.now + 1.second) }
217
+ before { allow(subject).to receive(:expires).and_return(Time.now + 1.second) }
218
218
  it 'should not be expired' do
219
- subject.expired?.should be_false
219
+ expect(subject.expired?).to be false
220
220
  end
221
221
  end
222
222
 
223
223
  context "when the expiration date is not set" do
224
- before {subject.stub(:expires => nil)}
224
+ before { allow(subject).to receive(:expires).and_return(nil) }
225
225
  it 'should not be expired' do
226
- subject.expired?.should be_false
226
+ expect(subject.expired?).to be false
227
227
  end
228
228
  end
229
229