Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Spec file for scss-lint NestSelector lint
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
You can’t perform that action at this time.