Skip to content

Commit bd644c8

Browse files
committed
It's an ArgumentError
1 parent 44f1b55 commit bd644c8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/phlex-sinatra.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
module Phlex
77
module Sinatra
88
Error = Class.new(StandardError)
9-
IncompatibleOptionError = Class.new(Error)
9+
ArgumentError = Class.new(Error)
1010

1111
class TypeError < Error
1212
MAX_SIZE = 32
@@ -47,6 +47,10 @@ def phlex(
4747
)
4848
raise Phlex::Sinatra::TypeError.new(obj) unless obj.is_a?(Phlex::SGML)
4949

50+
if layout && stream
51+
raise Phlex::Sinatra::ArgumentError.new('streaming is not compatible with layout')
52+
end
53+
5054
content_type ||= :svg if obj.is_a?(Phlex::SVG) && !layout
5155
self.content_type(content_type) if content_type
5256

@@ -55,10 +59,6 @@ def phlex(
5559
layout = @default_layout if layout == true
5660

5761
if stream
58-
raise Phlex::Sinatra::IncompatibleOptionError.new(
59-
'streaming is not compatible with layout'
60-
) if layout
61-
6262
self.stream do |out|
6363
obj.call(out, view_context: self)
6464
end

spec/general_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ def app
179179
expect(last_response.body).to start_with('<main><pre>')
180180
end
181181

182-
it 'raises an error stream=true' do
182+
it 'raises an error if stream=true' do
183183
expect {
184184
get('/stream-with-layout')
185-
}.to raise_error(Phlex::Sinatra::IncompatibleOptionError)
185+
}.to raise_error(Phlex::Sinatra::ArgumentError)
186186
end
187187

188188
it 'works with non-ERB templates' do

0 commit comments

Comments
 (0)