Sha256: 029ba0eae65d61a2282f1cc2429c2bd8d7a1df65079e994bccb17ac4c220257f

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

# coding: UTF-8

require 'spec_helper'

describe PremailerRails::Premailer do
  [ :nokogiri, :hpricot ].each do |adapter|
    context "when adapter is #{adapter}" do
      before { ::Premailer::Adapter.stubs(:use).returns(adapter) }

      describe '#to_plain_text' do
        it 'should include the text from the HTML part' do
          premailer = PremailerRails::Premailer.new(Fixtures::Message::HTML_PART)
          premailer.to_plain_text.gsub(/\s/, ' ').strip \
            .should == Fixtures::Message::TEXT_PART.gsub(/\s/, ' ').strip
        end
      end

      describe '#to_inline_css' do
        it 'should return the HTML with the CSS inlined' do
          PremailerRails::CSSHelper.stubs(:css_for_doc).returns('p { color: red; }')
          html = Fixtures::Message::HTML_PART
          premailer = PremailerRails::Premailer.new(html)
          premailer.to_inline_css.should include '<p style="color: red;">'
        end
      end
    end
  end

  describe '.new' do
    it 'should extract the CSS' do
      PremailerRails::CSSHelper.expects(:css_for_doc)
      PremailerRails::Premailer.new('some html')
    end

    it 'should pass on the configs' do
      PremailerRails3.config = { :foo => :bar }
      premailer = PremailerRails::Premailer.new('some html')
      premailer.instance_variable_get(:'@options')[:foo].should == :bar
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
premailer-rails3-1.0.2 spec/premailer-rails3/premailer_spec.rb