diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-05-09 11:10:49 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2022-05-25 08:33:11 -0700 |
commit | 00229670c88053daaa2ca7e43a74d32db5c47abf (patch) | |
tree | 8270093a94a05074f045e372974979d10e283966 | |
parent | 0a5c10d4ce604d46c093719f5d15241090adc839 (diff) | |
download | rack-00229670c88053daaa2ca7e43a74d32db5c47abf.tar.gz |
Add 100% line/branch coverage to rack/builder.rb
Change error message for .ru file with embedded options, since it's not just deprecated, the support has been fully removed. Coverage after this commit: 3282 relevant lines, 3282 lines covered and 0 lines missed. ( 100.0% ) 1110 total branches, 1068 branches covered and 42 branches missed. ( 96.22% )
-rw-r--r-- | lib/rack/builder.rb | 4 | ||||
-rw-r--r-- | test/spec_builder.rb | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/rack/builder.rb b/lib/rack/builder.rb index b85eb8ed..992bf059 100644 --- a/lib/rack/builder.rb +++ b/lib/rack/builder.rb @@ -88,7 +88,7 @@ module Rack config.slice!(/\A#{UTF_8_BOM}/) if config.encoding == Encoding::UTF_8 if config[/^#\\(.*)/] - fail "Parsing options from the first comment line is deprecated: #{path}" + fail "Parsing options from the first comment line is no longer supported: #{path}" end config.sub!(/^__END__\n.*\Z/m, '') @@ -152,7 +152,9 @@ module Rack end @use << proc { |app| middleware.new(app, *args, &block) } end + # :nocov: ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true) + # :nocov: # Takes an argument that is an object that responds to #call and returns a Rack response. # The simplest form of this is a lambda object: diff --git a/test/spec_builder.rb b/test/spec_builder.rb index 5cea34a3..3b02bcc1 100644 --- a/test/spec_builder.rb +++ b/test/spec_builder.rb @@ -238,6 +238,13 @@ describe Rack::Builder do File.join(File.dirname(__FILE__), 'builder', name) end + it "raises if parses commented options" do + proc do + Rack::Builder.parse_file config_file('options.ru') + end.must_raise(RuntimeError). + message.must_include('Parsing options from the first comment line is no longer supported') + end + it "removes __END__ before evaluating app" do app, _ = Rack::Builder.parse_file config_file('end.ru') Rack::MockRequest.new(app).get("/").body.to_s.must_equal 'OK' |