Skip to content

Instantly share code, notes, and snippets.

@nschonni
Created April 21, 2014 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nschonni/11133280 to your computer and use it in GitHub Desktop.
Save nschonni/11133280 to your computer and use it in GitHub Desktop.
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