Sha256: 99d30ecdbfb22eec545ff16bd53816a50cb0929aa5292c8bf10c0d1895578e82

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe Premailer::Rails::CSSLoaders::FileSystemLoader do
  before do
    allow(Rails.configuration)
      .to receive(:assets).and_return(double(prefix: '/assets'))
    allow(Rails)
      .to receive(:root).and_return(Pathname.new('/rails_root'))
  end

  describe '#file_name' do
    subject { described_class.file_name(asset) }
    let(:relative_url_root) { nil }

    before do
      config = double(relative_url_root: relative_url_root)
      allow(Rails).to receive(:configuration).and_return(config)
    end

    context 'when relative_url_root is not set' do
      let(:asset) { '/assets/application.css' }
      it { is_expected.to eq(File.join(Rails.root, 'public/assets/application.css')) }
    end

    context 'when relative_url_root is set' do
      let(:relative_url_root) { '/foo' }
      let(:asset) { '/foo/assets/application.css' }
      it { is_expected.to eq(File.join(Rails.root, 'public/assets/application.css')) }
    end

    context 'when relative_url_root has a trailing slash' do
      let(:relative_url_root) { '/foo/' }
      let(:asset) { '/foo/assets/application.css' }
      it { is_expected.to eq(File.join(Rails.root, 'public/assets/application.css')) }
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
premailer-rails-1.12.0 spec/unit/css_loaders/file_system_loader_spec.rb
premailer-rails-revived-1.12.0 spec/unit/css_loaders/file_system_loader_spec.rb
premailer-rails-1.11.1 spec/unit/css_loaders/file_system_loader_spec.rb
premailer-rails-1.11.0 spec/unit/css_loaders/file_system_loader_spec.rb
premailer-rails-1.10.3 spec/unit/css_loaders/file_system_loader_spec.rb
premailer-rails-1.10.2 spec/unit/css_loaders/file_system_loader_spec.rb
premailer-rails-1.10.1 spec/unit/css_loaders/file_system_loader_spec.rb
premailer-rails-1.10.0 spec/unit/css_loaders/file_system_loader_spec.rb
premailer-rails-1.9.7 spec/unit/css_loaders/file_system_loader_spec.rb