require 'spec_helper' require 'mail' module GhostInThePost describe MailGhost do let(:email) { Mail.new } let(:included_scripts) { ["application.js"] } subject(:ghost) { MailGhost.new(email, 1000, "wait", included_scripts) } it "takes an email and options" do expect(ghost.email).to eq(email) expect(ghost.timeout).to eq(1000) expect(ghost.wait_event).to eq("wait") expect(ghost.included_scripts).to eq(included_scripts) end context "with an plaintext email" do let(:email) do Mail.new do body "Hello world" end end it "returns the email without doing anything" do expect(ghost.execute).to eq(email) expect(email.html_part).to be_nil expect(email.body.decoded).to eq("Hello world") end it "works fine when given nil included_scripts" do ghost = MailGhost.new(email, nil) expect { ghost.execute }.to_not raise_error expect(ghost.included_scripts).to eq([]) end end context "with an HTML email" do let(:html) { "