Sha256: bf76c2e3c2e5489a1b5dc64e10187c22db0186d59217413afa2928fa863a397a

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe SCSSLint::Linter::UrlFormat do
  shared_examples_for 'UrlFormat linter' do
    context 'when URL contains protocol' do
      let(:url) { 'https://something.com/image.png' }

      it { should report_lint }
    end

    context 'when URL contains domain with protocol-less double slashes' do
      let(:url) { '//something.com/image.png' }

      it { should report_lint }
    end

    context 'when URL contains absolute path' do
      let(:url) { '/absolute/path/to/image.png' }

      it { should_not report_lint }
    end

    context 'when URL contains relative path' do
      let(:url) { 'relative/path/to/image.png' }

      it { should_not report_lint }
    end

    context 'when URL is a data URI' do
      let(:url) { 'data:image/png;base64,iVBORI=' }

      it { should_not report_lint }
    end
  end

  context 'when URL is enclosed in quotes' do
    let(:css) { <<-CSS }
      .block {
        background: url('#{url}');
      }
    CSS

    it_should_behave_like 'UrlFormat linter'
  end

  context 'when URL is not enclosed in quotes' do
    let(:css) { <<-CSS }
      .block {
        background: url(#{url});
      }
    CSS

    it_should_behave_like 'UrlFormat linter'
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
scss-lint-0.33.0 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.32.0 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.31.0 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.30.0 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.29.0 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.28.0 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.27.0 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.26.2 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.26.1 spec/scss_lint/linter/url_format_spec.rb
scss-lint-0.26.0 spec/scss_lint/linter/url_format_spec.rb