Skip to content

Commit

Permalink
adding sass specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdiebolt committed Mar 4, 2015
1 parent acf910b commit 5027102
Show file tree
Hide file tree
Showing 10 changed files with 1,379 additions and 439 deletions.
8 changes: 4 additions & 4 deletions spec/scss_lint/linter/color_variable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
it { should report_lint line: 2 }
end

context 'sass' do
xcontext 'sass' do
let(:sass) { <<-SASS }
p
color: #f00
Expand All @@ -51,7 +51,7 @@
it { should report_lint line: 2 }
end

context 'sass' do
xcontext 'sass' do
let(:sass) { <<-SASS }
p
color: my-func(#f00)
Expand All @@ -72,7 +72,7 @@
it { should report_lint line: 2 }
end

context 'sass' do
xcontext 'sass' do
let(:sass) { <<-SASS }
p
+my-mixin(#f00)
Expand All @@ -93,7 +93,7 @@
it { should report_lint line: 2 }
end

context 'sass' do
xcontext 'sass' do
let(:sass) { <<-SASS }
p
border: 1px solid #f00
Expand Down
232 changes: 164 additions & 68 deletions spec/scss_lint/linter/else_placement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,201 @@

describe SCSSLint::Linter::ElsePlacement do
context 'when @if contains no accompanying @else' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
}
SCSS
context 'scss' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
}
SCSS

it { should_not report_lint }
it { should_not report_lint }
end

context 'sass' do
let(:sass) { <<-SASS }
@if $condition
$var: 1
SASS

it { should_not report_lint }
end
end

context 'when @else is on different line' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
}
@else {
$var: 0;
}
SCSS

it { should report_lint line: 4 }
end
context 'scss' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
}
@else {
$var: 0;
}
SCSS

context 'when @else is on the same line as previous curly' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
} @else {
$var: 0;
}
SCSS

it { should_not report_lint }
end
it { should report_lint line: 4 }
end

context 'when `@else if` is on different line' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
}
@else if $other_condition {
$var: 2;
}
@else {
$var: 0;
}
SCSS

it { should report_lint line: 4 }
it { should report_lint line: 7 }
end
context 'sass' do
let(:sass) { <<-SASS }
@if $condition
$var: 1
@else
$var: 0
SASS

context 'when `@else if` is on the same line as previous curly' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
} @else if $other_condition {
$var: 2;
} @else {
$var: 0;
}
SCSS

it { should_not report_lint }
it { should report_lint line: 3 }
end
end

context 'when @else is on same line as @if' do
let(:scss) { <<-SCSS }
@if $condition { $var: 1; } @else { $var: 0; }
SCSS
context 'when @else is on the same line as previous curly' do
context 'scss' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
} @else {
$var: 0;
}
SCSS

it { should_not report_lint }
end
it { should_not report_lint }
end

context 'when placement of @else on a new line is preferred' do
let(:linter_config) { { 'style' => 'new_line' } }
xcontext 'sass' do
let(:sass) { <<-SASS }
@if $condition
$var: 1
@else
$var: 0
SASS

context 'when @else is on a new line' do
it { should_not report_lint }
end
end

context 'when `@else if` is on different line' do
context 'scss' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
}
@else if $other_condition {
$var: 2;
}
@else {
$var: 0;
}
SCSS

it { should_not report_lint }
it { should report_lint line: 4 }
it { should report_lint line: 7 }
end

context 'when @else is on the same line as previous curly brace' do
xcontext 'sass' do
let(:sass) { <<-SASS }
@if $condition
$var: 1
@else if $other_condition
$var: 2
@else
$var: 0
SASS

it { should report_lint line: 3 }
it { should report_lint line: 5 }
end
end

context 'when `@else if` is on the same line as previous curly' do
context 'scss' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
} @else if $other_condition {
$var: 2;
} @else {
$var: 0;
}
SCSS

it { should report_lint line: 3 }
it { should_not report_lint }
end

xcontext 'sass' do
let(:sass) { <<-SASS }
@if $condition
$var: 1
@else if $other_condition
$var: 2
@else
$var: 0
SASS

it { should_not report_lint }
end
end

context 'when @else is on same line as @if' do
context 'scss' do
let(:scss) { <<-SCSS }
@if $condition { $var: 1; } @else { $var: 0; }
SCSS

it { should_not report_lint }
end
end

context 'when placement of @else on a new line is preferred' do
let(:linter_config) { { 'style' => 'new_line' } }

context 'when @else is on a new line' do
context 'scss' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
}
@else {
$var: 0;
}
SCSS

it { should_not report_lint }
end

xcontext 'sass' do
let(:sass) { <<-SASS }
@if $condition
$var: 1
@else
$var: 0
SASS

it { should_not report_lint }
end
end

context 'when @else is on the same line as previous curly brace' do
context 'scss' do
let(:scss) { <<-SCSS }
@if $condition {
$var: 1;
} @else {
$var: 0;
}
SCSS

it { should report_lint line: 3 }
end

xcontext 'sass' do
let(:sass) { <<-SASS }
@if $condition
$var: 1
@else
$var: 0
SASS

it { should report_lint line: 3 }
end
end
end
end
Loading

0 comments on commit 5027102

Please sign in to comment.