Sha256: 9414146e67993a3cc871c8779585b359a8d70b23fd5672f2e5e4b24c8469ec25

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe EmailSpec::MailExt do
  describe "#default_part" do
    it "prefers html_part over text_part" do
      email = Mail.new do
        text_part { body "This is text" }
        html_part { body "This is html" }
      end

      expect(email.default_part.body.to_s).to eq("This is html")
    end

    it "returns text_part if html_part not available" do
      email = Mail.new do
        text_part { body "This is text" }
      end

      expect(email.default_part.body.to_s).to eq("This is text")
    end

    it "returns the email if not multi-part" do
      email = Mail.new { body "This is the body" }
      expect(email.default_part.body.to_s).to eq("This is the body")
    end
  end

  describe "#default_part_body" do
    it "returns default_part.body" do
      email = Mail.new(:body => "hi")
      expect(email.default_part.body).to eq(email.default_part_body)
    end
  end

  describe "#html" do
    it "returns the html part body" do
      email = Mail.new do
        html_part { body "This is html" }
      end

      expect(email.html).to eq("This is html")
    end

    it "returns a String" do
      email = Mail.new do
        html_part { body "This is html" }
      end

      expect(email.html).to be_a(String)
    end

    it "returns nil for mail with no html part" do
      email = Mail.new
      expect(email.html).to be_nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
email_spec-2.1.1 spec/email_spec/mail_ext_spec.rb
email_spec-2.1.0 spec/email_spec/mail_ext_spec.rb