Skip to content

Commit 4c7f6c8

Browse files
Add breaking test for #fetch_route
1 parent 3470ef8 commit 4c7f6c8

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

spec/lib/critical_path_css/css_fetcher_spec.rb

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
11
require 'spec_helper'
22

33
RSpec.describe 'CssFetcher' do
4-
describe '#fetch' do
5-
let(:subject) { CriticalPathCss::CssFetcher.new(config) }
6-
let(:response) {
7-
['foo','', OpenStruct.new(exitstatus: 0)]
8-
}
9-
let(:routes) { ['/', '/new_route'] }
10-
let(:config) do
11-
OpenStruct.new(
12-
base_url: 'http://0.0.0.0:9292',
13-
css_path: css_path,
14-
css_paths: css_paths,
15-
penthouse_options: {},
16-
routes: routes
17-
)
4+
let(:subject) { CriticalPathCss::CssFetcher.new(config) }
5+
let(:response) { ['foo','', OpenStruct.new(exitstatus: 0)] }
6+
let(:routes) { ['/', '/new_route'] }
7+
let(:config) do
8+
OpenStruct.new(
9+
base_url: 'http://0.0.0.0:9292',
10+
css_path: css_path,
11+
css_paths: css_paths,
12+
penthouse_options: {},
13+
routes: routes
14+
)
15+
end
16+
17+
describe '#fetch_route' do
18+
context 'when a single css_path is configured' do
19+
let(:css_path) { '/test.css' }
20+
let(:css_paths) { [] }
21+
22+
it 'generates css for the single route' do
23+
expect(Open3).to receive(:capture3) do |arg1, arg2, arg3|
24+
options = JSON.parse(arg3)
25+
expect(options['css']).to eq '/test.css'
26+
end.once.and_return(response)
27+
28+
subject.fetch_route(routes.first)
29+
end
1830
end
31+
end
1932

33+
describe '#fetch' do
2034
context 'when a single css_path is configured' do
2135
let(:css_path) { '/test.css' }
2236
let(:css_paths) { [] }

0 commit comments

Comments
 (0)