Sha256: c61db3e15ca17cb03e05ed10c3cfc1b8bad6ab9bd339bf601ffbe1919b0ed40d

Contents?: true

Size: 1.69 KB

Versions: 5

Compression:

Stored size: 1.69 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 multiple ampersands exist with one concatenated' do
    let(:css) { <<-CSS }
      p {
        & + &:hover {}
      }
    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

5 entries across 5 versions & 1 rubygems

Version Path
scss-lint-0.33.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.32.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.31.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.30.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb
scss-lint-0.29.0 spec/scss_lint/linter/unnecessary_parent_reference_spec.rb