Skip to content

Commit 378a128

Browse files
Move configs into fixtures
1 parent 7464614 commit 378a128

File tree

6 files changed

+71
-86
lines changed

6 files changed

+71
-86
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
defaults: &defaults
2+
base_url: http://0.0.0.0:9292
3+
css_paths:
4+
- /test.css
5+
- /test2.css
6+
routes:
7+
- /
8+
- /new_route
9+
10+
development:
11+
<<: *defaults
12+
13+
test:
14+
<<: *defaults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
defaults: &defaults
2+
base_url: http://0.0.0.0:9292
3+
manifest_name: application
4+
routes:
5+
- /
6+
7+
development:
8+
<<: *defaults
9+
10+
test:
11+
<<: *defaults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
defaults: &defaults
2+
base_url: http://0.0.0.0:9292
3+
css_paths:
4+
- /test.css
5+
- /test2.css
6+
routes:
7+
- /
8+
- /new_route
9+
- /newer_route
10+
11+
development:
12+
<<: *defaults
13+
14+
test:
15+
<<: *defaults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
defaults: &defaults
2+
base_url: http://0.0.0.0:9292
3+
css_path: /test.css
4+
css_paths:
5+
- /test.css
6+
- /test2.css
7+
routes:
8+
- /
9+
- /new_route
10+
11+
development:
12+
<<: *defaults
13+
14+
test:
15+
<<: *defaults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
defaults: &defaults
2+
base_url: http://0.0.0.0:9292
3+
css_path: /test.css
4+
routes:
5+
- /
6+
7+
development:
8+
<<: *defaults
9+
10+
test:
11+
<<: *defaults

spec/lib/critical_path_css/rails/config_loader_spec.rb

+5-86
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,7 @@
99
end
1010

1111
context 'when single css_path is specified' do
12-
let(:config_file) {
13-
<<~CONFIG
14-
defaults: &defaults
15-
base_url: http://0.0.0.0:9292
16-
css_path: /test.css
17-
routes:
18-
- /
19-
20-
development:
21-
<<: *defaults
22-
23-
test:
24-
<<: *defaults
25-
CONFIG
26-
}
12+
let(:config_file) { file_fixture('config/single-css-path.yml').read }
2713

2814
it 'sets css_path with the path' do
2915
expect(subject.config['css_path']).to eq '/app/spec/internal/public/test.css'
@@ -35,24 +21,7 @@
3521
end
3622

3723
context 'when multiple css_paths are specified' do
38-
let(:config_file) {
39-
<<~CONFIG
40-
defaults: &defaults
41-
base_url: http://0.0.0.0:9292
42-
css_paths:
43-
- /test.css
44-
- /test2.css
45-
routes:
46-
- /
47-
- /new_route
48-
49-
development:
50-
<<: *defaults
51-
52-
test:
53-
<<: *defaults
54-
CONFIG
55-
}
24+
let(:config_file) { file_fixture('config/mutliple-css-paths.yml').read }
5625

5726
it 'sets css_path to empty string' do
5827
expect(subject.config['css_path']).to eq ''
@@ -64,21 +33,7 @@
6433
end
6534

6635
context 'when no paths are specified' do
67-
let(:config_file) {
68-
<<~CONFIG
69-
defaults: &defaults
70-
base_url: http://0.0.0.0:9292
71-
manifest_name: application
72-
routes:
73-
- /
74-
75-
development:
76-
<<: *defaults
77-
78-
test:
79-
<<: *defaults
80-
CONFIG
81-
}
36+
let(:config_file) { file_fixture('config/no-paths-specified.yml').read }
8237

8338
it 'sets css_path with the path' do
8439
expect(subject.config['css_path']).to eq '/stylesheets/application.css'
@@ -90,51 +45,15 @@
9045
end
9146

9247
context 'when single css_path and multiple css_paths are both specified' do
93-
let(:config_file) {
94-
<<~CONFIG
95-
defaults: &defaults
96-
base_url: http://0.0.0.0:9292
97-
css_path: /test.css
98-
css_paths:
99-
- /test.css
100-
- /test2.css
101-
routes:
102-
- /
103-
- /new_route
104-
105-
development:
106-
<<: *defaults
107-
108-
test:
109-
<<: *defaults
110-
CONFIG
111-
}
48+
let(:config_file) { file_fixture('config/paths-both-specified.yml').read }
11249

11350
it 'raises an error' do
11451
expect { subject }.to raise_error LoadError, 'Cannot specify both css_path and css_paths'
11552
end
11653
end
11754

11855
context 'when css_paths and routes are not the same length' do
119-
let(:config_file) {
120-
<<~CONFIG
121-
defaults: &defaults
122-
base_url: http://0.0.0.0:9292
123-
css_paths:
124-
- /test.css
125-
- /test2.css
126-
routes:
127-
- /
128-
- /new_route
129-
- /newer_route
130-
131-
development:
132-
<<: *defaults
133-
134-
test:
135-
<<: *defaults
136-
CONFIG
137-
}
56+
let(:config_file) { file_fixture('config/paths-and-routes-not-same-length.yml').read }
13857

13958
it 'raises an error' do
14059
expect { subject }.to raise_error LoadError, 'Must specify css_paths for each route'

0 commit comments

Comments
 (0)