fixture1 = File.read(File.join(File.dirname(__FILE__), "..", "fixtures", "mail1")) fixture2 = File.read(File.join(File.dirname(__FILE__), "..", "fixtures", "mail2")) describe PixelatedService::Mail do describe "#read" do context("simple email") do subject(:mail) { PixelatedService::Mail.read(fixture1) } it "reads the subject correctly" do expect(mail.subject).to eq("Doloremque aliquid a facilis et sit numquam libero.") end it "reads the from correctly" do expect(mail.from).to eq("kenneth@willmsmckenzie.org") end it "reads the to correctly" do expect(mail.to).to eq("antonio@beier.biz") end it "reads and parses date" do expect(mail.headers[:date]).to eq(DateTime.parse("2014-05-29T18:56:41 -0300")) end it "reads the body correctly" do expect(mail.body).to eq(<
Mime-Version: 1.0 Subject: Doloremque aliquid a facilis et sit numquam libero. To: antonio@beier.biz X-TW-Pixelated-Ident: Quia tempora quas laboriosam. Dolorem dolor fuga a aut minima sint. Ullam suscipit consectetur nihil. Incidunt velit aut reprehenderit. Laborum blanditiis praesentium soluta dolorem laudantium a. Molestiae excepturi laudantium at eos velit. Commodi quaerat suscipit laudantium sapiente aut omnis. Qui iure impedit ea dolores. Et debitis non est tempora id autem. Atque officia architecto sed assumenda. Inventore quia minus. Doloribus amet reiciendis ipsam aut. MAIL end end context("with multiple recipients") do subject(:mail) { PixelatedService::Mail.read(fixture2) } it "writes correct output" do expect(mail.to_s).to eq(<