spec/unit/serializer/mbox_spec.rb in imap-backup-1.3.0 vs spec/unit/serializer/mbox_spec.rb in imap-backup-1.4.0

- old
+ new

@@ -1,9 +1,9 @@ require "spec_helper" describe Imap::Backup::Serializer::Mbox do - let(:stat) { double("File::Stat", mode: 0700) } + let(:stat) { double("File::Stat", mode: 0o700) } let(:base_path) { "/base/path" } let(:mbox_pathname) { "/base/path/my/folder.mbox" } let(:mbox_exists) { true } let(:imap_pathname) { "/base/path/my/folder.imap" } let(:imap_exists) { true } @@ -18,11 +18,12 @@ context "#initialize" do it "creates the containing directory" do described_class.new(base_path, "my/folder") - expect(Imap::Backup::Utils).to have_received(:make_folder).with(base_path, "my", 0700) + expect(Imap::Backup::Utils). + to have_received(:make_folder).with(base_path, "my", 0o700) end context "mbox and imap files" do context "if mbox exists and imap doesn't" do let(:imap_exists) { false } @@ -71,18 +72,20 @@ end context "#save" do let(:mbox_formatted_message) { "message in mbox format" } let(:message_uid) { "999" } - let(:message) { double("Email::Mboxrd::Message", to_s: mbox_formatted_message) } + let(:message) do + double("Email::Mboxrd::Message", to_serialized: mbox_formatted_message) + end let(:mbox_file) { double("File - mbox", write: nil, close: nil) } let(:imap_file) { double("File - imap", write: nil, close: nil) } before do allow(Email::Mboxrd::Message).to receive(:new).and_return(message) - allow(File).to receive(:open).with(mbox_pathname, "ab").and_return(mbox_file) - allow(File).to receive(:open).with(imap_pathname, "ab").and_return(imap_file) + allow(File).to receive(:open).with(mbox_pathname, "ab") { mbox_file } + allow(File).to receive(:open).with(imap_pathname, "ab") { imap_file } end it "saves the message to the mbox" do subject.save(message_uid, "The\nemail\n") @@ -95,10 +98,10 @@ expect(imap_file).to have_received(:write).with(message_uid + "\n") end context "when the message causes parsing errors" do before do - allow(message).to receive(:to_s).and_raise(ArgumentError) + allow(message).to receive(:to_serialized).and_raise(ArgumentError) end it "skips the message" do subject.save(message_uid, "The\nemail\n") expect(mbox_file).to_not have_received(:write)