diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4fddfba9..36778ffb 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -27,8 +27,14 @@ jobs: java-version: '8' distribution: 'temurin' cache: maven + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 'jruby' + bundler-cache: true - name: Build with Maven run: mvn -B install --file pom.xml + - name: Run specs + run: rake spec # Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph diff --git a/Gemfile b/Gemfile index cbf214e6..0b015ed9 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,5 @@ group :development do end gem 'rake', '~> 13.2', :group => :test, :require => nil -gem 'rspec', :group => :test -gem 'jruby-openssl', :group => :test if JRUBY_VERSION < '1.7.0' +gem 'rspec', '~> 3.13', :group => :test +gem 'jruby-openssl', :group => :test diff --git a/Gemfile.lock b/Gemfile.lock index 43b978fd..14497ecc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,6 +5,7 @@ GEM bundler rake diff-lcs (1.5.1) + jruby-openssl (0.14.5-java) rack (3.0.11) rake (13.2.1) rspec (3.13.0) @@ -26,9 +27,10 @@ PLATFORMS DEPENDENCIES appraisal (< 1.0) + jruby-openssl rack rake (~> 13.2) - rspec + rspec (~> 3.13) BUNDLED WITH 2.4.19 diff --git a/pom.xml b/pom.xml index e43aeff2..f3261e23 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,6 @@ 9.4.7.0 - vendor/gems 2.4.19 false 3.0.3 @@ -146,13 +145,6 @@ 3.2.10.RELEASE test - - rubygems - jruby-openssl - 0.9.6 - gem - provided - rubygems bundler diff --git a/src/spec/ruby/action_controller/session/java_servlet_store_spec.rb b/src/spec/ruby/action_controller/session/java_servlet_store_spec.rb index 832cd711..b473fc6e 100644 --- a/src/spec/ruby/action_controller/session/java_servlet_store_spec.rb +++ b/src/spec/ruby/action_controller/session/java_servlet_store_spec.rb @@ -57,7 +57,7 @@ it "should load the session when accessed" do @request.should_receive(:getSession).with(false).and_return @session @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']['foo'] end @session_store.call(@env) @@ -73,7 +73,7 @@ it "should report session loaded when accessed" do @request.should_receive(:getSession).with(false).and_return @session @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']['foo'] end @session_store.call(@env) @@ -84,7 +84,7 @@ it "should use custom session hash when loading session" do @request.should_receive(:getSession).with(false).and_return @session @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']["foo"] = "bar" end @session_store.call(@env) @@ -106,7 +106,7 @@ @session.should_receive(:getAttributeNames).and_return [session_key] @session.should_receive(:getAttribute).with(session_key).and_return marshal_data.to_java_bytes @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']["foo"].should == 1 env['rack.session']["bar"].should == true end @@ -120,7 +120,7 @@ @session.should_receive(:getAttribute).with("foo").and_return hash["foo"] @session.should_receive(:getAttribute).with("bar").and_return hash["bar"] @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']["foo"].should == hash["foo"] env['rack.session']["bar"].should == hash["bar"] end @@ -132,7 +132,7 @@ @session.should_receive(:getAttributeNames).and_return ["foo"] @session.should_receive(:getAttribute).with("foo").and_return java.lang.Object.new @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']["foo"].should be_kind_of(java.lang.Object) end @session_store.call(@env) @@ -143,7 +143,7 @@ @session.stub(:getAttribute).and_return nil; @session.stub(:getCreationTime).and_return 1 @session.should_receive(:setAttribute).with(ActionController::Session::JavaServletStore::RAILS_SESSION_KEY, an_instance_of(Java::byte[])) - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']['foo'] = Object.new end @session_store.call(@env) @@ -154,7 +154,7 @@ @request.should_receive(:getSession).with(true).ordered.and_return @session @session.should_receive(:setAttribute).with(ActionController::Session::JavaServletStore::RAILS_SESSION_KEY, an_instance_of(Java::byte[])) - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']['foo'] = Object.new end @session_store.call(@env) @@ -164,7 +164,7 @@ @request.should_receive(:getSession).with(false).and_return @session @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 @session.should_receive(:setAttribute).with("foo", "bar") - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']["foo"] = "bar" end @session_store.call(@env) @@ -176,7 +176,7 @@ @session.should_receive(:setAttribute).with("foo", true) @session.should_receive(:setAttribute).with("bar", 20) @session.should_receive(:setAttribute).with("baz", false) - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']["foo"] = true env['rack.session']["bar"] = 20 env['rack.session']["baz"] = false @@ -188,7 +188,7 @@ @request.should_receive(:getSession).with(false).and_return @session @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 @session.should_receive(:setAttribute).with("foo", an_instance_of(java.lang.Object)) - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']["foo"] = java.lang.Object.new end @session_store.call(@env) @@ -200,7 +200,7 @@ @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1 @session.should_receive(:removeAttribute).with("foo") @session.should_receive(:removeAttribute).with("baz") - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session'].delete('foo') env['rack.session']['baz'] = nil env['rack.session']['bar'] = 'x' @@ -212,7 +212,7 @@ @request.should_receive(:getSession).with(false).and_return @session @session.stub(:getId).and_return(nil) @session.should_receive(:invalidate).ordered - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session.options'].delete(:id) #env['rack.session'] = new_session_hash(env) env['rack.session'].send :load! @@ -224,7 +224,7 @@ session = double_http_session(nil); session.invalidate @request.should_receive(:getSession).with(false).and_return session - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session.options'].delete(:id) env['rack.session'].send :load! end @@ -240,7 +240,7 @@ @request.should_receive(:getSession).ordered. with(true).and_return new_session = double_http_session - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session']['foo'] = 'bar' end @session_store.call(@env) @@ -248,7 +248,7 @@ it "should do nothing on session reset if no session is established" do @request.should_receive(:getSession).with(false).and_return nil - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session.options'].delete(:id) env['rack.session'] = new_session_hash(env) # not loaded? end @@ -260,7 +260,7 @@ @request.should_receive(:getSession).and_return @session @session.should_receive(:getLastAccessedTime).and_return time @session.stub(:setAttribute) - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session'].getLastAccessedTime.should == time lambda { env['rack.session'].blah_blah }.should raise_error(NoMethodError) end @@ -274,7 +274,7 @@ new_session = double_http_session @request.should_receive(:getSession).ordered.with(true).and_return(new_session) - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session.options'] = { :id => sid, :renew => true, :defer => true } env['rack.session']['_csrf_token'] = 'v3PrzsdkWug9Q3xCthKkEzUMbZSzgQ9Bt+43lH0bEF8=' end @@ -292,7 +292,7 @@ it "handles the skip session option" do @request.should_receive(:getSession).with(false).and_return @session @session.should_not_receive(:setAttribute) - @app.should_receive(:call).and_return do |env| + @app.should_receive(:call) do |env| env['rack.session.options'][:skip] = true env['rack.session']['foo'] = 'bar' end diff --git a/src/spec/ruby/jruby/rack/app_layout_spec.rb b/src/spec/ruby/jruby/rack/app_layout_spec.rb index 2dcd9099..ac59c754 100644 --- a/src/spec/ruby/jruby/rack/app_layout_spec.rb +++ b/src/spec/ruby/jruby/rack/app_layout_spec.rb @@ -89,7 +89,7 @@ shared_examples "FileSystemLayout" do - @@__work_dir__ = Dir.pwd + __work_dir__ = Dir.pwd before do require 'tmpdir' @@ -97,7 +97,7 @@ end after do - Dir.chdir @@__work_dir__ + Dir.chdir __work_dir__ end it "sets app and public uri defaults based on a typical (Rails/Rack) app" do diff --git a/src/spec/ruby/jruby/rack/booter_spec.rb b/src/spec/ruby/jruby/rack/booter_spec.rb index 7a8cdd1c..8d4be331 100644 --- a/src/spec/ruby/jruby/rack/booter_spec.rb +++ b/src/spec/ruby/jruby/rack/booter_spec.rb @@ -16,14 +16,14 @@ after(:all) { JRuby::Rack.context = nil } - @@rack_env = ENV['RACK_ENV'] - @@gem_path = Gem.path.dup - @@env_gem_path = ENV['GEM_PATH'] + rack_env = ENV['RACK_ENV'] + gem_path = Gem.path.dup + env_gem_path = ENV['GEM_PATH'] after do - @@rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = @@rack_env - Gem.path.replace(@@gem_path) - @@env_gem_path.nil? ? ENV.delete('GEM_PATH') : ENV['GEM_PATH'] = @@env_gem_path + rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = rack_env + Gem.path.replace(gem_path) + env_gem_path.nil? ? ENV.delete('GEM_PATH') : ENV['GEM_PATH'] = env_gem_path end it "should determine the public html root from the 'public.root' init parameter" do diff --git a/src/spec/ruby/jruby/rack/integration_spec.rb b/src/spec/ruby/jruby/rack/integration_spec.rb index 77a0c3cb..96a1f009 100644 --- a/src/spec/ruby/jruby/rack/integration_spec.rb +++ b/src/spec/ruby/jruby/rack/integration_spec.rb @@ -423,7 +423,7 @@ def expect_to_have_monkey_patched_chunked should_eval_as_eql_to script, "1\nsecond" end - ENV_COPY = ENV.dup + ENV_COPY = ENV.to_h def initialize_rails(env = nil, servlet_context = @servlet_context) if ! servlet_context || servlet_context.is_a?(String) diff --git a/src/spec/ruby/jruby/rack/queues_spec.rb b/src/spec/ruby/jruby/rack/queues_spec.rb index 55a775c3..4f6e3064 100644 --- a/src/spec/ruby/jruby/rack/queues_spec.rb +++ b/src/spec/ruby/jruby/rack/queues_spec.rb @@ -175,7 +175,7 @@ def mock_message(text) it "should unmarshal the message if the marshal payload property is set" do @message.should_receive(:getBooleanProperty).with(JRuby::Rack::Queues::MARSHAL_PAYLOAD).and_return true first = false - @message.should_receive(:readBytes).twice.and_return do |byte_array| + @message.should_receive(:readBytes).twice do |byte_array| if first -1 else diff --git a/src/spec/ruby/jruby/rack/rails_booter_spec.rb b/src/spec/ruby/jruby/rack/rails_booter_spec.rb index 8c34e202..169a8e6d 100644 --- a/src/spec/ruby/jruby/rack/rails_booter_spec.rb +++ b/src/spec/ruby/jruby/rack/rails_booter_spec.rb @@ -25,11 +25,11 @@ booter.app_path.should == "./WEB-INF" end - @@rails_env = ENV['RAILS_ENV']; @@rack_env = ENV['RACK_ENV'] + rails_env = ENV['RAILS_ENV']; rack_env = ENV['RACK_ENV'] after do - @@rails_env.nil? ? ENV.delete('RAILS_ENV') : ENV['RAILS_ENV'] = @@rails_env - @@rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = @@rack_env + rails_env.nil? ? ENV.delete('RAILS_ENV') : ENV['RAILS_ENV'] = rails_env + rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = rack_env end it "should default rails path to /WEB-INF" do diff --git a/src/spec/ruby/jruby/rack/response_spec.rb b/src/spec/ruby/jruby/rack/response_spec.rb index e547f5ce..a005204a 100644 --- a/src/spec/ruby/jruby/rack/response_spec.rb +++ b/src/spec/ruby/jruby/rack/response_spec.rb @@ -181,7 +181,7 @@ class << value; undef_method :each; end if value.respond_to?(:each) response.write_headers(response_environment) times = 0 - stream.should_receive(:write).exactly(6).times.with do |bytes| + stream.should_receive(:write).exactly(6).times.with no_args do |bytes| str = String.from_java_bytes(bytes) str = str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) case times += 1 @@ -223,7 +223,7 @@ class << value; undef_method :each; end if value.respond_to?(:each) response.write_headers(response_environment) times = 0 - stream.should_receive(:write).exactly(3).times.with do |bytes| + stream.should_receive(:write).exactly(3).times.with no_args do |bytes| str = String.from_java_bytes(bytes) case times += 1 when 1 then str.should == "1\r\n1\r\n" @@ -258,7 +258,7 @@ class << value; undef_method :each; end if value.respond_to?(:each) response.write_headers(response_environment) times = 0 - stream.should_receive(:write).exactly(5).times.with do |bytes| + stream.should_receive(:write).exactly(5).times.with no_args do |bytes| str = String.from_java_bytes(bytes) case times += 1 when 1 then str.should == "1" @@ -404,7 +404,7 @@ def wrap_file_body(path) # Rails style when doing #send_file path = File.expand_path('../../files/image.jpg', File.dirname(__FILE__)) response = JRuby::Rack::Response.new [ 200, {}, FileBody.new(path) ] - response.should_receive(:send_file).with do |path, response| + response.should_receive(:send_file).with no_args do |path, response| expect( path ).to eql path expect( response).to be response_environment end @@ -526,11 +526,11 @@ def with_swallow_client_abort(client_abort = true) private - def update_response_headers(headers, response = response) + def update_response_headers(headers, response) response.to_java.getHeaders.update(headers) end - def new_response_environment(servlet_response = servlet_response) + def new_response_environment(servlet_response) org.jruby.rack.RackResponseEnvironment.impl do |name, *args| servlet_response.send(name, *args) end diff --git a/src/spec/ruby/rack/application_spec.rb b/src/spec/ruby/rack/application_spec.rb index 5edc8e07..43bc2236 100644 --- a/src/spec/ruby/rack/application_spec.rb +++ b/src/spec/ruby/rack/application_spec.rb @@ -26,7 +26,7 @@ let(:servlet_context) do servlet_context = double("servlet_context") - servlet_context.stub(:getInitParameter).and_return do |name| + servlet_context.stub(:getInitParameter) do |name| name && nil # return null end servlet_context @@ -182,7 +182,7 @@ def createRackServletWrapper(runtime, rackup); end @app_factory.init @rack_context @app_factory.rackup_script.should == nil - @rack_context.should_receive(:log).with do |*args| + @rack_context.should_receive(:log).with no_args do |*args| expect( args.first.to_s ).to eql 'WARN' if args.size > 1 args.last.should =~ /no rackup script found/ end @@ -221,7 +221,7 @@ def newRuntime() # use the current runtime instead of creating new @rack_context.stub(:getInitParameter).and_return nil @rack_context.stub(:getResourcePaths).and_return nil @rack_context.stub(:getRealPath) { |path| path } - #@rack_context.stub(:log).with do |*args| + #@rack_context.stub(:log).with no_args do |*args| #puts args.inspect #end end @@ -458,18 +458,11 @@ def newRuntime() # use the current runtime instead of creating new should_eval_as_eql_to "require 'yaml'", true # -ryaml not processed end - it "handles jruby.compat.version == '1.9' and starts in 1.9 mode" do - set_config 'jruby.compat.version', '1.9' - #@rack_config.stub(:getCompatVersion).and_return org.jruby.CompatVersion::RUBY1_9 - @runtime = app_factory.new_runtime - @runtime.is1_9.should be_true - end - it "handles jruby.runtime.arguments == '-X+O -Ke' and start with object space enabled and KCode EUC" do set_config 'jruby.runtime.arguments', '-X+O -Ke' #@rack_config.stub(:getRuntimeArguments).and_return ['-X+O', '-Ke'].to_java(:String) @runtime = app_factory.new_runtime - @runtime.object_space_enabled.should be_true + @runtime.object_space_enabled.should be true @runtime.kcode.should == Java::OrgJrubyUtil::KCode::EUC end @@ -688,7 +681,7 @@ def createRackServletWrapper(runtime, rackup); end it "creates applications during initialization according to the jruby.min.runtimes context parameter" do @factory.stub(:init) - @factory.stub(:newApplication).and_return do + @factory.stub(:newApplication) do app = double "app" app.should_receive(:init) app @@ -721,7 +714,7 @@ def createRackServletWrapper(runtime, rackup); end it "forces the maximum size to be greater or equal to the initial size" do @factory.stub(:init) - @factory.stub(:newApplication).and_return do + @factory.stub(:newApplication) do app = double "app" app.should_receive(:init) app @@ -743,9 +736,9 @@ def createRackServletWrapper(runtime, rackup); end it "waits till initial runtimes get initialized (with wait set to true)" do @factory.stub(:init) - @factory.stub(:newApplication).and_return do + @factory.stub(:newApplication) do app = double "app" - app.stub(:init).and_return do + app.stub(:init) do sleep(0.10) end app @@ -762,9 +755,9 @@ def createRackServletWrapper(runtime, rackup); end "(even when only a single application initialization fails)" do @factory.stub(:init) app_count = java.util.concurrent.atomic.AtomicInteger.new(0) - @factory.stub(:newApplication).and_return do + @factory.stub(:newApplication) do app = double "app" - app.stub(:init).and_return do + app.stub(:init) do if app_count.addAndGet(1) == 2 raise org.jruby.rack.RackInitializationException.new('failed app init') end @@ -794,9 +787,9 @@ def createRackServletWrapper(runtime, rackup); end it "wait until pool is filled when invoking getApplication (with wait set to false)" do @factory.stub(:init) - @factory.stub(:newApplication).and_return do + @factory.stub(:newApplication) do app = double "app" - app.stub(:init).and_return { sleep(0.2) } + app.stub(:init) { sleep(0.2) } app end @rack_config.stub(:getBooleanProperty).with("jruby.runtime.init.wait").and_return false @@ -812,9 +805,9 @@ def createRackServletWrapper(runtime, rackup); end it "waits acquire timeout till an application is available from the pool (than raises)" do @factory.stub(:init) - @factory.should_receive(:newApplication).twice.and_return do + @factory.should_receive(:newApplication).twice do app = double "app" - app.should_receive(:init).and_return { sleep(0.2) } + app.should_receive(:init) { sleep(0.2) } app end @rack_config.stub(:getBooleanProperty).with("jruby.runtime.init.wait").and_return false @@ -842,9 +835,9 @@ def createRackServletWrapper(runtime, rackup); end it "gets and initializes new applications until maximum allows to create more" do @factory.stub(:init) - @factory.should_receive(:newApplication).twice.and_return do + @factory.should_receive(:newApplication).twice do app = double "app (new)" - app.should_receive(:init).and_return { sleep(0.1) } + app.should_receive(:init) { sleep(0.1) } app end @rack_config.stub(:getBooleanProperty).with("jruby.runtime.init.wait").and_return false @@ -858,7 +851,7 @@ def createRackServletWrapper(runtime, rackup); end 2.times { @pooling_factory.getApplication.should_not be nil } }.should_not raise_error - @factory.should_receive(:getApplication).twice.and_return do + @factory.should_receive(:getApplication).twice do app = double "app (get)"; sleep(0.15); app end @@ -879,9 +872,9 @@ def createRackServletWrapper(runtime, rackup); end it "initializes initial runtimes in paralel (with wait set to false)" do @factory.stub(:init) - @factory.stub(:newApplication).and_return do + @factory.stub(:newApplication) do app = double "app" - app.stub(:init).and_return do + app.stub(:init) do sleep(0.15) end app @@ -902,9 +895,9 @@ def createRackServletWrapper(runtime, rackup); end it "throws from init when application initialization in thread failed" do @factory.stub(:init) - @factory.stub(:newApplication).and_return do + @factory.stub(:newApplication) do app = double "app" - app.stub(:init).and_return do + app.stub(:init) do sleep(0.05); raise "app.init raising" end app @@ -913,7 +906,7 @@ def createRackServletWrapper(runtime, rackup); end @rack_config.stub(:getMaximumRuntimes).and_return 2 raise_error_logged = 0 - @rack_context.stub(:log).with do |level, msg, e| + @rack_context.stub(:log).with no_args do |level, msg, e| if level.to_s == 'ERROR' expect( msg ).to eql 'unable to initialize application' expect( e ).to be_a org.jruby.exceptions.RaiseException @@ -944,9 +937,9 @@ def createRackServletWrapper(runtime, rackup); end it "initializes initial runtimes in serial order" do @factory.should_receive(:init).with(@rack_context) - @factory.stub(:newApplication).and_return do + @factory.stub(:newApplication) do app = double "app" - app.stub(:init).and_return do + app.stub(:init) do sleep(0.05) end app @@ -981,7 +974,7 @@ def createRackServletWrapper(runtime, rackup); end @factory.should_receive(:init).with(@rack_context) @factory.should_receive(:getApplication).and_raise java.lang.ArithmeticException.new('42') - @rack_context.should_receive(:log).with do |level, msg, e| + @rack_context.should_receive(:log).with no_args do |level, msg, e| if level == 'ERROR' expect( e ).to be_a java.lang.ArithmeticException else diff --git a/src/spec/ruby/rack/filter_spec.rb b/src/spec/ruby/rack/filter_spec.rb index b310f118..e5a99109 100644 --- a/src/spec/ruby/rack/filter_spec.rb +++ b/src/spec/ruby/rack/filter_spec.rb @@ -39,7 +39,7 @@ def stub_request(path_info) end it "should dispatch the filter chain and finish if the chain resulted in a successful response" do - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.setStatus(200) end @response.should_receive(:setStatus).ordered.with(200) @@ -47,7 +47,7 @@ def stub_request(path_info) end it "should finish if the chain resulted in a redirect" do - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendRedirect("/some/url") end @response.should_receive(:sendRedirect).ordered.with("/some/url") @@ -55,7 +55,7 @@ def stub_request(path_info) end it "dispatches to the rack dispatcher if the chain resulted in a 404" do - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(404) end @response.should_receive(:reset).ordered @@ -67,7 +67,7 @@ def stub_request(path_info) it "dispatches to the rack dispatcher if the chain resulted in a 403" do # sending a PUT up the chain results in a 403 on Tomcat # @see https://github.com/jruby/jruby-rack/issues/105 - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(403) end @response.should_receive(:reset).ordered @@ -78,7 +78,7 @@ def stub_request(path_info) it "dispatches to the rack dispatcher if the chain resulted in a 405" do # PUT/DELETE up the chain end up as HTTP 405 on Jetty # @see https://github.com/jruby/jruby-rack/issues/109 - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(405) end @response.should_receive(:reset).ordered @@ -89,7 +89,7 @@ def stub_request(path_info) it "dispatches to the rack dispatcher if the chain resulted in a 501" do # non standard verbs like PATCH produce HTTP 501 # see also http://httpstatus.es/501 and http://tools.ietf.org/html/rfc5789 - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(501) end @response.should_receive(:reset) @@ -106,7 +106,7 @@ def wrapResponse(response) end end.new(dispatcher, @rack_context) - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(442) end @response.should_receive(:reset).ordered @@ -115,7 +115,7 @@ def wrapResponse(response) end it "allows downstream entities to flush the buffer in the case of a successful response" do - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.setStatus(200) resp.flushBuffer end @@ -126,7 +126,7 @@ def wrapResponse(response) end it "does not allow downstream entities in the chain to flush the buffer in the case of an 404" do - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(404) resp.flushBuffer end @@ -137,7 +137,7 @@ def wrapResponse(response) end it "only resets the buffer for a 404 if configured so" do - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(404) resp.flushBuffer end @@ -150,7 +150,7 @@ def wrapResponse(response) end it "allows an error response from the filter chain (and flushes the buffer)" do - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(401) resp.flushBuffer end @@ -170,7 +170,7 @@ def isHandled(arg); getStatus < 400; end end end.new(dispatcher, @rack_context) - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(401) resp.flushBuffer end @@ -185,7 +185,7 @@ def isHandled(arg); getStatus < 400; end request.stub(:getPathInfo).and_return path_info request.stub(:getServletPath).and_return "/some/uri" end - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getPathInfo.should == "/index.html" req.getServletPath.should == "/some/uri" req.getRequestURI.should == "/some/uri/index.html" @@ -196,12 +196,12 @@ def isHandled(arg); getStatus < 400; end end it "should set status to 404 when dispatcher's status is not found" do - chain.should_receive(:doFilter).ordered.and_return do |_, resp| + chain.should_receive(:doFilter).ordered do |_, resp| resp.sendError(404) # 404 status is irrelevant here ! end @response.should_receive(:reset).ordered @request.should_receive(:setAttribute).ordered.with(org.jruby.rack.RackEnvironment::DYNAMIC_REQS_ONLY, true) - dispatcher.should_receive(:process).ordered.and_return do |_, resp| + dispatcher.should_receive(:process).ordered do |_, resp| resp.setStatus(404) end @response.should_receive(:setStatus).ordered.with(404) @@ -216,7 +216,7 @@ def isHandled(arg); getStatus < 400; end it "should dispatch /some/uri/index.html unchanged" do stub_request("/index.html") - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getRequestURI.should == "/some/uri/index.html" resp.setStatus(200) end @@ -226,7 +226,7 @@ def isHandled(arg); getStatus < 400; end it "should convert / to /index.html" do stub_request("/") - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getServletPath.should == "/some/uri/index.html" resp.setStatus(200) end @@ -239,7 +239,7 @@ def isHandled(arg); getStatus < 400; end request.stub(:getPathInfo).and_return nil request.stub(:getServletPath).and_return "/some/uri/index.html" end - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getPathInfo.should == nil req.getServletPath.should == "/some/uri/index.html" req.getRequestURI.should == "/some/uri/" @@ -251,7 +251,7 @@ def isHandled(arg); getStatus < 400; end it "should add .html to the path" do stub_request("") - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getServletPath.should == "/some/uri.html" resp.setStatus(200) end @@ -261,7 +261,7 @@ def isHandled(arg); getStatus < 400; end it "should process dispatching when chain throws a FileNotFoundException (WAS 8.0 behavior)" do stub_request("/foo") - chain.should_receive(:doFilter).ordered.and_return do + chain.should_receive(:doFilter).ordered do raise java.io.FileNotFoundException.new("/foo.html") end dispatcher.should_receive(:process) @@ -277,7 +277,7 @@ def isHandled(arg); getStatus < 400; end end it "dispatches /some/uri/index unchanged" do - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getServletPath.should == "/some/uri/index" req.getRequestURI.should == "/some/uri/index" resp.setStatus(200) @@ -295,7 +295,7 @@ def isHandled(arg); getStatus < 400; end end it "dispatches /some/uri/index unchanged if the resource does not exist" do - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getRequestURI.should == "/some/uri/index" resp.setStatus(200) end @@ -305,7 +305,7 @@ def isHandled(arg); getStatus < 400; end it "should dispatch /some/uri/index to the filter chain as /some/uri/index.html if the resource exists" do @rack_context.should_receive(:getResource).with("/some/uri/index.html").and_return java.net.URL.new("file://some/uri/index.html") - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getRequestURI.should == "/some/uri/index.html" resp.setStatus(200) end @@ -316,7 +316,7 @@ def isHandled(arg); getStatus < 400; end it "should dispatch /some/uri/ to /some/uri/index.html if the resource exists" do @rack_context.should_receive(:getResource).with("/some/uri/index.html").and_return java.net.URL.new("file://some/uri/index.html") stub_request("/") - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getRequestURI.should == "/some/uri/index.html" resp.setStatus(200) end @@ -327,7 +327,7 @@ def isHandled(arg); getStatus < 400; end it "should dispatch to /some/uri.html if the resource exists and there is no path info" do @rack_context.should_receive(:getResource).with("/some/uri.html").and_return java.net.URL.new("file://some/uri.html") stub_request("") - chain.should_receive(:doFilter).ordered.and_return do |req,resp| + chain.should_receive(:doFilter).ordered do |req,resp| req.getServletPath.should == "/some/uri.html" resp.setStatus(200) end diff --git a/src/spec/ruby/rack/jms_spec.rb b/src/spec/ruby/rack/jms_spec.rb index 9455a521..e94c999d 100644 --- a/src/spec/ruby/rack/jms_spec.rb +++ b/src/spec/ruby/rack/jms_spec.rb @@ -7,9 +7,9 @@ require File.expand_path('spec_helper', File.dirname(__FILE__) + '/..') -import org.jruby.rack.jms.QueueContextListener -import org.jruby.rack.jms.QueueManager -import org.jruby.rack.jms.DefaultQueueManager +java_import org.jruby.rack.jms.QueueContextListener +java_import org.jruby.rack.jms.QueueManager +java_import org.jruby.rack.jms.DefaultQueueManager describe QueueContextListener do before :each do diff --git a/src/spec/ruby/rack/tag_spec.rb b/src/spec/ruby/rack/tag_spec.rb index 167078e3..1ca37d3c 100644 --- a/src/spec/ruby/rack/tag_spec.rb +++ b/src/spec/ruby/rack/tag_spec.rb @@ -69,13 +69,12 @@ def call(request) end it 'should override the path, query params, and http method of the request' do - @application.should_receive(:call).and_return do |wrapped_request| + @application.should_receive(:call) do |wrapped_request| wrapped_request.servlet_path.should == "" wrapped_request.path_info.should == '/controller/action/id' wrapped_request.query_string.should == 'fruit=apple&horse_before=cart' wrapped_request.request_uri.should == '/controller/action/id?fruit=apple&horse_before=cart' wrapped_request.method.should == 'GET' - @result end @tag.doEndTag diff --git a/src/spec/ruby/spec_helper.rb b/src/spec/ruby/spec_helper.rb index b1650e28..b8ffbd05 100644 --- a/src/spec/ruby/spec_helper.rb +++ b/src/spec/ruby/spec_helper.rb @@ -138,7 +138,7 @@ def should_eval_as_eql_to(code, expected, options = {}) runtime, options = options, {} end message = options[:message] || "expected eval #{code.inspect} to be == $expected but was $actual" - be_flag = options.has_key?(:should) ? options[:should] : be_true + be_flag = options.has_key?(:should) ? options[:should] : (be true) expected = expected.inspect.to_java actual = runtime.evalScriptlet(code).inspect.to_java @@ -146,7 +146,7 @@ def should_eval_as_eql_to(code, expected, options = {}) end def should_eval_as_not_eql_to(code, expected, options = {}) - should_eval_as_eql_to(code, expected, options.merge(:should => be_false, + should_eval_as_eql_to(code, expected, options.merge(:should => (be false), :message => options[:message] || "expected eval #{code.inspect} to be != $expected but was not") ) end @@ -157,7 +157,7 @@ def should_eval_as_nil(code, runtime = @runtime) end def should_eval_as_not_nil(code, runtime = @runtime) - should_eval_as_eql_to code, nil, :should => be_false, :runtime => runtime, + should_eval_as_eql_to code, nil, :should => (be false), :runtime => runtime, :message => "expected eval #{code.inspect} to not be nil but was" end diff --git a/vendor/gems/jruby-openssl-0.9.4.gem b/vendor/gems/jruby-openssl-0.9.4.gem deleted file mode 100644 index fc892593..00000000 Binary files a/vendor/gems/jruby-openssl-0.9.4.gem and /dev/null differ