Skip to content

Commit

Permalink
Passthrough to_path for bodies when running specs in LINT mode
Browse files Browse the repository at this point in the history
This allows running the sinatra_helpers send_file to_path spec.

However, as as Rack::Lint in older versions of Rack does
not passthrough body.to_path, only run the spec in Lint mode
on Rack 3+.
  • Loading branch information
jeremyevans committed Feb 24, 2025
1 parent f1d833e commit da8781c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spec/plugin/sinatra_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def o.each; yield 'Hello World' end

it "returns response body implementing to_path" do
req[2].to_path.must_equal @file
end unless ENV['LINT']
end if !ENV['LINT'] || Rack.release >= '3'

it 'sets the Content-Type response header if a mime-type can be located' do
header(RodaResponseHeaders::CONTENT_TYPE).must_equal 'text/css'
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def _req(app, env)
orig = a[2]
a[2] = a[2].to_enum(:each).to_a
orig.close if orig.respond_to?(:close)
a[2].define_singleton_method(:to_path){orig.to_path} if orig.respond_to?(:to_path)
end

a
Expand Down

0 comments on commit da8781c

Please sign in to comment.