File tree Expand file tree Collapse file tree 3 files changed +6
-18
lines changed
spec/lib/critical_path_css/rails Expand file tree Collapse file tree 3 files changed +6
-18
lines changed Original file line number Diff line number Diff line change @@ -28,14 +28,10 @@ def self.fetch(route)
2828 end
2929
3030 def self . fetcher
31- @fetcher ||= CssFetcher . new ( Configuration . new ( config ) )
31+ @fetcher ||= CssFetcher . new ( Configuration . new ( config_loader . config ) )
3232 end
3333
34- def self . config
35- @config ||= begin
36- loader = CriticalPathCss ::Rails ::ConfigLoader . new
37- loader . load
38- loader . config
39- end
34+ def self . config_loader
35+ @config_loader ||= CriticalPathCss ::Rails ::ConfigLoader . new
4036 end
4137end
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module Rails
33 class ConfigLoader
44 CONFIGURATION_FILENAME = 'critical_path_css.yml' . freeze
55
6- def load
6+ def initialize
77 validate_css_paths
88 format_css_paths
99 end
Original file line number Diff line number Diff line change 2525 CONFIG
2626 }
2727
28- before do
29- subject . load
30- end
31-
3228 it 'sets css_path with the path' do
3329 expect ( subject . config [ 'css_path' ] ) . to eq '/app/spec/internal/public/test.css'
3430 end
5854 CONFIG
5955 }
6056
61- before do
62- subject . load
63- end
64-
6557 it 'sets css_path to empty string' do
6658 expect ( subject . config [ 'css_path' ] ) . to eq ''
6759 end
9385 }
9486
9587 it 'raises an error' do
96- expect { subject . load } . to raise_error LoadError , 'Cannot specify both css_path and css_paths'
88+ expect { subject } . to raise_error LoadError , 'Cannot specify both css_path and css_paths'
9789 end
9890 end
9991
119111 }
120112
121113 it 'raises an error' do
122- expect { subject . load } . to raise_error LoadError , 'Must specify css_paths for each route'
114+ expect { subject } . to raise_error LoadError , 'Must specify css_paths for each route'
123115 end
124116 end
125117 end
You can’t perform that action at this time.
0 commit comments