Created
April 21, 2014 05:41
-
-
Save nschonni/11133280 to your computer and use it in GitHub Desktop.
Spec file for scss-lint NestSelector lint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe SCSSLint::Linter::NestSelector do | |
context 'when single root' do | |
let(:css) { <<-CSS } | |
p { | |
} | |
CSS | |
it { should_not report_lint } | |
end | |
context 'when single comma separated rules' do | |
let(:css) { <<-CSS } | |
p, a { | |
} | |
CSS | |
it { should_not report_lint } | |
end | |
context 'when single different roots' do | |
let(:css) { <<-CSS } | |
p { | |
background: #000; | |
margin: 5px; | |
} | |
a { | |
background: #000; | |
margin: 5px; | |
} | |
CSS | |
it { should_not report_lint } | |
end | |
context 'when nested rules' do | |
let(:css) { <<-CSS } | |
.warn { | |
color: #f00; | |
a { | |
color: #ccc; | |
} | |
} | |
CSS | |
it { should_not report_lint } | |
end | |
context 'when single selector with space' do | |
let(:css) { <<-CSS } | |
.foo .bar { | |
font-weight: bold; | |
} | |
CSS | |
it { should report_lint } | |
end | |
context 'when single selector with space followed by comma' do | |
let(:css) { <<-CSS } | |
.foo .bar, a { | |
font-weight: bold; | |
} | |
CSS | |
it { should_not report_lint } | |
end | |
context 'when single selector with compound classes' do | |
let(:css) { <<-CSS } | |
.foo.bar { | |
font-weight: bold; | |
} | |
CSS | |
it { should report_lint } | |
end | |
context 'when single selector with compound classes' do | |
let(:css) { <<-CSS } | |
.foo.bar { | |
font-weight: bold; | |
} | |
CSS | |
it { should report_lint } | |
end | |
context 'when inner selector with compound classes' do | |
let(:css) { <<-CSS } | |
a { | |
.foo.bar { | |
font-weight: bold; | |
} | |
} | |
CSS | |
it { should report_lint } | |
end | |
context 'when pseudo selector' do | |
let(:css) { <<-CSS } | |
a:hover { | |
font-weight: bold; | |
} | |
CSS | |
it { should report_lint } | |
end | |
# Advanced optimization, may ignore at the begining | |
context 'when comma separate rules with common root' do | |
let(:css) { <<-CSS } | |
.foo.bar, .foo.baz { | |
font-weight: bold; | |
} | |
CSS | |
it { should report_lint } | |
end | |
context 'when root with ancestor selector' do | |
let(:css) { <<-CSS } | |
.foo > .bar { | |
font-weight: bold; | |
} | |
CSS | |
it { should report_lint } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment