spec/unit/imap/backup/account/folder_spec.rb in imap-backup-2.1.1 vs spec/unit/imap/backup/account/folder_spec.rb in imap-backup-2.2.0
- old
+ new
@@ -26,11 +26,11 @@
let(:append_response) { nil }
describe "#uids" do
let(:uids) { [5678, 123] }
- before { allow(imap).to receive(:uid_search).and_return(uids) }
+ before { allow(imap).to receive(:uid_search) { uids } }
it "lists available messages" do
expect(subject.uids).to eq(uids.reverse)
end
@@ -81,16 +81,10 @@
it "is nil" do
expect(subject.fetch(123)).to be_nil
end
end
-
- it "sets the encoding on the message" do
- subject.fetch(123)
-
- expect(message_body).to have_received(:force_encoding).with("utf-8")
- end
end
describe "#folder" do
it "is the name" do
expect(subject.folder).to eq("my_folder")
@@ -115,25 +109,26 @@
end
end
describe "#create" do
context "when the folder exists" do
- before { subject.create }
-
it "is does not create the folder" do
- expect(imap).to_not have_received(:create)
+ expect(imap).to_not receive(:create)
+
+ subject.create
end
end
context "when the folder doesn't exist" do
before do
allow(imap).to receive(:examine).and_raise(missing_mailbox_error)
- subject.create
end
it "is does not create the folder" do
- expect(imap).to have_received(:create)
+ expect(imap).to receive(:create)
+
+ subject.create
end
end
end
describe "#uid_validity" do
@@ -166,29 +161,30 @@
end
let(:message_date) { Time.new(2010, 10, 10, 9, 15, 22, 0) }
let(:append_response) do
OpenStruct.new(data: OpenStruct.new(code: OpenStruct.new(data: "1 2")))
end
- let(:result) { subject.append(message) }
- before do
- result
- end
-
it "appends the message" do
- expect(imap).to have_received(:append)
+ expect(imap).to receive(:append)
+
+ subject.append(message)
end
it "sets the date and time" do
- expect(imap).to have_received(:append).
+ expect(imap).to receive(:append).
with(anything, anything, anything, message_date)
+
+ subject.append(message)
end
it "returns the new uid" do
- expect(result).to eq(2)
+ expect(subject.append(message)).to eq(2)
end
it "set the new uid validity" do
+ subject.append(message)
+
expect(subject.uid_validity).to eq(1)
end
end
end