Skip to content

Commit cb1ab54

Browse files
rambleraptornex3
authored andcommitted
Add test cases for Metadata (#1456)
1 parent a32988b commit cb1ab54

File tree

5 files changed

+79
-1
lines changed

5 files changed

+79
-1
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ gem "command_line_reporter", '~> 3.0'
55
gem "ruby-terminfo", '~> 0.1.1'
66
gem "diffy", '~> 3.1'
77
gem "hrx", '~> 1.0'
8+
9+
gem 'rspec'

Gemfile.lock

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,25 @@ GEM
44
colored (1.2)
55
command_line_reporter (3.3.6)
66
colored (>= 1.2)
7+
diff-lcs (1.3)
78
diffy (3.3.0)
89
hrx (1.0.0)
910
linked-list (~> 0.0.13)
1011
linked-list (0.0.13)
1112
minitest (5.11.3)
13+
rspec (3.8.0)
14+
rspec-core (~> 3.8.0)
15+
rspec-expectations (~> 3.8.0)
16+
rspec-mocks (~> 3.8.0)
17+
rspec-core (3.8.2)
18+
rspec-support (~> 3.8.0)
19+
rspec-expectations (3.8.4)
20+
diff-lcs (>= 1.2.0, < 2.0)
21+
rspec-support (~> 3.8.0)
22+
rspec-mocks (3.8.1)
23+
diff-lcs (>= 1.2.0, < 2.0)
24+
rspec-support (~> 3.8.0)
25+
rspec-support (3.8.2)
1226
ruby-terminfo (0.1.1)
1327

1428
PLATFORMS
@@ -19,7 +33,8 @@ DEPENDENCIES
1933
diffy (~> 3.1)
2034
hrx (~> 1.0)
2135
minitest (~> 5.8)
36+
rspec
2237
ruby-terminfo (~> 0.1.1)
2338

2439
BUNDLED WITH
25-
1.16.2
40+
2.0.2

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,11 @@ X. Exit testing.
283283
Any option can also be applied to all future occurences of that type of failure
284284
by adding `!` after it. For example, if you want to mark *all* failing specs as
285285
`:todo` for the current implementation you'd type `I!`.
286+
287+
## Tests
288+
The unit tests for the spec runner are located in the `tests/` directory. To
289+
run these unit tests, run:
290+
291+
```sh
292+
bundle exec rspec tests/
293+
```

tests/spec_helper.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# frozen_string_literal: true
2+
3+
require 'rspec'

tests/test_case_metadata_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'spec_helper'
4+
require 'sass_spec'
5+
6+
def create_options_yaml(folder, dictionary)
7+
FileUtils.mkdir_p("tests/fixtures/#{folder}")
8+
File.write("tests/fixtures/#{folder}/options.yml", dictionary.to_yaml)
9+
end
10+
11+
def cleanup(folder)
12+
FileUtils.remove_dir("tests/fixtures/#{folder}")
13+
end
14+
15+
describe SassSpec::TestCaseMetadata do
16+
context 'should ignore impl when given ignore_for' do
17+
before { create_options_yaml('ignore', ignore_for: ['dart_sass']) }
18+
after { cleanup('ignore') }
19+
subject { SassSpec::TestCaseMetadata.new(SassSpec::Directory.new('tests/fixtures/ignore')).ignore_for?('dart_sass') }
20+
it { is_expected.to be true }
21+
end
22+
23+
context 'should ignore impl when given only_on' do
24+
before { create_options_yaml('only_on', only_on: ['dart_sass']) }
25+
after { cleanup('only_on') }
26+
subject { SassSpec::TestCaseMetadata.new(SassSpec::Directory.new('tests/fixtures/only_on')).ignore_for?('libsass') }
27+
it { is_expected.to be true }
28+
end
29+
30+
context 'should have precision' do
31+
before { create_options_yaml('precision', precision: 10) }
32+
after { cleanup('precision') }
33+
subject { SassSpec::TestCaseMetadata.new(SassSpec::Directory.new('tests/fixtures/precision')).precision }
34+
it { is_expected.to eq 10 }
35+
end
36+
37+
context 'should have todos for an impl' do
38+
before { create_options_yaml('todo', todo: ['sass/libsass#2342']) }
39+
after { cleanup('todo') }
40+
subject { SassSpec::TestCaseMetadata.new(SassSpec::Directory.new('tests/fixtures/todo')).todo?('libsass') }
41+
it { is_expected.to be true }
42+
end
43+
44+
context 'should have warning todos for an impl' do
45+
before { create_options_yaml('warning', warning_todo: ['sass/libsass#2342']) }
46+
after { cleanup('warning') }
47+
subject { SassSpec::TestCaseMetadata.new(SassSpec::Directory.new('tests/fixtures/warning')).warning_todo?('libsass') }
48+
it { is_expected.to be true }
49+
end
50+
end

0 commit comments

Comments
 (0)