Sha256: 2662c096c4484055eb24d2a56b7551789b3ee19b81909f62a1eeb4cff95b3eaa

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "../../spec_helper"))
describe WebResourceBundler::CssUrlRewriter do
  describe "#rewrite_relative_path" do
    it "returns absolute path using url and css file path" do
      tests = {
        "../image.gif" => "/styles/image.gif",
        "./image.gif" => "/styles/skin/image.gif",
        "../../image.gif" => "/image.gif",
        "../.././1.gif" => '/1.gif',
        '.././../styles/./../styles/3.jpg' => '/styles/3.jpg'
      }
      css_file_path = "/styles/skin/1.css"
      tests.each do |key, value|
        CssUrlRewriter.rewrite_relative_path(css_file_path, key).should == value 
      end
    end
  end
  describe "#rewrite_content_urls" do
    it "rewrites all urls in css block" do
      css = "abracada: url\t('../image.gif'); \n backaground-image: url(\"../../image.gif\");background: url(./i/backgrounds/menu.png) repeat-x 0 100%; }"
      result = "abracada: url('\/styles\/image.gif'); \n backaground-image: url('\/image.gif');background: url('/styles/skin/i/backgrounds/menu.png') repeat-x 0 100%; }"
      CssUrlRewriter.rewrite_content_urls!("/styles/skin/1.css", css).should == result
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
web_resource_bundler-0.0.23 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.22 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.21 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.20 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.19 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.18 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.16 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.15 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.14 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb
web_resource_bundler-0.0.13 spec/web_resource_bundler/content_management/css_url_rewriter_spec.rb