Sha256: 3b805e37997e66151c84cd4b8cf12ba5d3fae98af33abdb40d08a81561166405

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

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

    it { should report_lint line: 2 }
  end

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

    it { should report_lint line: 2 }
  end

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

    it { should_not report_lint }
  end

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

    it { should_not report_lint }
  end

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

    it { should_not report_lint }
  end

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

    it { should_not report_lint }
  end

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

    it { should report_lint line: 2 }
  end

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

    it { should_not report_lint }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scss-lint-0.28.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.27.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb