Sha256: 8d3af44200b08418b5ee2b7ec918cd00761ffdfcf53317bfa22cbdb78e05f3ad

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 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

    context 'when URL contains a variable' do
      let(:scss) { <<-SCSS }
        .block {
          background: url('${url}');
        }
      SCSS

      it { should_not report_lint }
    end
  end

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

    it_should_behave_like 'UrlFormat linter'
  end

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

    it_should_behave_like 'UrlFormat linter'
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
scss_lint-0.60.0 spec/scss_lint/linter/url_format_spec.rb
scss_lint-0.59.0 spec/scss_lint/linter/url_format_spec.rb
scss_lint-0.58.0 spec/scss_lint/linter/url_format_spec.rb
scss_lint-0.57.1 spec/scss_lint/linter/url_format_spec.rb
scss_lint-0.57.0 spec/scss_lint/linter/url_format_spec.rb
scss_lint-0.56.0 spec/scss_lint/linter/url_format_spec.rb
scss_lint-0.55.0 spec/scss_lint/linter/url_format_spec.rb
scss_lint-0.54.0 spec/scss_lint/linter/url_format_spec.rb
scss_lint-0.53.0 spec/scss_lint/linter/url_format_spec.rb