Sha256: 9dfdb487ec88081b6d576233a0a6eadb5611b5e8a74fda4968e44c0ec3d0dc2a

Contents?: true

Size: 1.71 KB

Versions: 18

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

describe SCSSLint::Linter::UnnecessaryParentReference do
  context 'when an amperand precedes a direct descendant operator' do
    let(:scss) { <<-SCSS }
      p {
        & > a {}
      }
    SCSS

    it { should report_lint line: 2 }
  end

  context 'when an amperand precedes a general child' do
    let(:scss) { <<-SCSS }
      p {
        & a {}
      }
    SCSS

    it { should report_lint line: 2 }
  end

  context 'when an amperand is chained with class' do
    let(:scss) { <<-SCSS }
      p {
        &.foo {}
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when an amperand follows a direct descendant operator' do
    let(:scss) { <<-SCSS }
      p {
        .foo > & {}
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when an ampersand precedes a sibling operator' do
    let(:scss) { <<-SCSS }
      p {
        & + & {}
        & ~ & {}
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when multiple ampersands exist with one concatenated' do
    let(:scss) { <<-SCSS }
      p {
        & + &:hover {}
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when an amperand is used in a comma sequence to DRY up code' do
    let(:scss) { <<-SCSS }
      p {
        &,
        .foo,
        .bar {
          margin: 0;
        }
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when an ampersand is used by itself' do
    let(:scss) { <<-SCSS }
      p {
        & {}
      }
    SCSS

    it { should report_lint line: 2 }
  end

  context 'when an ampersand is used in concatentation' do
    let(:scss) { <<-SCSS }
      .icon {
        &-small {}
      }
    SCSS

    it { should_not report_lint }
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
scss_lint-0.43.2 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.43.1 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.43.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.42.2 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.42.1 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.42.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.41.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.40.1 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.40.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.39.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss_lint-0.38.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.38.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-bliss-1.0.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.37.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.36.1 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.36.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.35.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.34.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb