|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | | -describe Config do |
4 | | - context 'validation' do |
5 | | - around(:each) do |example| |
6 | | - Config.reset |
7 | | - example.run |
8 | | - Config.reset |
9 | | - end |
| 3 | +if RUBY_VERSION >= '2.1' |
| 4 | + describe Config do |
| 5 | + context 'validation' do |
| 6 | + around(:each) do |example| |
| 7 | + Config.reset |
| 8 | + example.run |
| 9 | + Config.reset |
| 10 | + end |
10 | 11 |
|
11 | | - it 'should raise if schema is present and validation fails' do |
12 | | - Config.setup do |config| |
13 | | - config.schema do |
14 | | - required(:youtube).schema do |
15 | | - required(:nonexist_field).filled |
| 12 | + it 'should raise if schema is present and validation fails' do |
| 13 | + Config.setup do |config| |
| 14 | + config.schema do |
| 15 | + required(:youtube).schema do |
| 16 | + required(:nonexist_field).filled |
| 17 | + end |
16 | 18 | end |
17 | 19 | end |
18 | | - end |
19 | 20 |
|
20 | | - expect { Config.load_files("#{fixture_path}/validation/config.yml") }. |
21 | | - to raise_error(Config::Validation::Error, /youtube.nonexist_field: is missing/) |
22 | | - end |
| 21 | + expect { Config.load_files("#{fixture_path}/validation/config.yml") }. |
| 22 | + to raise_error(Config::Validation::Error, /youtube.nonexist_field: is missing/) |
| 23 | + end |
23 | 24 |
|
24 | | - it 'should work if validation passes' do |
25 | | - Config.setup do |config| |
26 | | - config.schema do |
27 | | - required(:youtube).schema do |
28 | | - required(:api_key).filled |
| 25 | + it 'should work if validation passes' do |
| 26 | + Config.setup do |config| |
| 27 | + config.schema do |
| 28 | + required(:youtube).schema do |
| 29 | + required(:api_key).filled |
| 30 | + end |
29 | 31 | end |
30 | 32 | end |
31 | | - end |
32 | 33 |
|
33 | | - expect { Config.load_files("#{fixture_path}/validation/config.yml") }. |
34 | | - to_not raise_error |
| 34 | + expect { Config.load_files("#{fixture_path}/validation/config.yml") }. |
| 35 | + to_not raise_error |
| 36 | + end |
35 | 37 | end |
36 | 38 | end |
37 | 39 | end |
0 commit comments