Sha256: a46a88645eaf961a662dbeb21f87d15a3487fe41cb5ca30b6cbf4f2cd5130796

Contents?: true

Size: 1.92 KB

Versions: 17

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'

describe SCSSLint::Linter::ColorKeyword do
  context 'when a color is specified as a hex' do
    let(:scss) { <<-SCSS }
      p {
        color: #fff;
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when a color is specified as a keyword' do
    let(:scss) { <<-SCSS }
      p {
        color: white;
      }
    SCSS

    it { should report_lint line: 2 }
  end

  context 'when a color keyword exists in a shorthand property' do
    let(:scss) { <<-SCSS }
      p {
        border: 1px solid black;
      }
    SCSS

    it { should report_lint line: 2 }
  end

  context 'when a property contains a color keyword as a string' do
    let(:scss) { <<-SCSS }
      p {
        content: 'white';
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when a function call contains a color keyword' do
    let(:scss) { <<-SCSS }
      p {
        color: function(red);
      }
    SCSS

    it { should report_lint line: 2 }
  end

  context 'when a mixin include contains a color keyword' do
    let(:scss) { <<-SCSS }
      p {
        @include some-mixin(red);
      }
    SCSS

    it { should report_lint line: 2 }
  end

  context 'when the "transparent" color keyword is used' do
    let(:scss) { <<-SCSS }
      p {
        @include mixin(transparent);
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when color keyword appears in a string identifier' do
    let(:scss) { <<-SCSS }
      p {
        content: content-with-blue-in-name;
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when a color keyword is used in a map declaration as keys' do
    let(:scss) { <<-SCSS }
      $palette: (
        white: (
          first:   #fff,
          second:  #ccc,
          third:   #000
        ),
        'black': (
          first:   #000,
          second:  #ccc,
          third:   #fff
        )
      );
    SCSS

    it { should_not report_lint }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
scss_lint-0.49.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.48.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.47.1 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.47.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.46.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.45.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.44.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.43.2 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.43.1 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.43.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.42.2 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.42.1 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.42.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.41.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.40.1 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.40.0 spec/scss_lint/linter/color_keyword_spec.rb
scss_lint-0.39.0 spec/scss_lint/linter/color_keyword_spec.rb