Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run specs in CI #250

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -26,9 +27,10 @@ PLATFORMS

DEPENDENCIES
appraisal (< 1.0)
jruby-openssl
rack
rake (~> 13.2)
rspec
rspec (~> 3.13)

BUNDLED WITH
2.4.19
8 changes: 0 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

<properties>
<jruby.version>9.4.7.0</jruby.version>
<vendor.gems.path>vendor/gems</vendor.gems.path>
<bundler.version>2.4.19</bundler.version>
<bundler.local>false</bundler.local> <!-- true by default -->
<jruby.maven.plugins.version>3.0.3</jruby.maven.plugins.version>
Expand Down Expand Up @@ -146,13 +145,6 @@
<version>3.2.10.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>jruby-openssl</artifactId>
<version>0.9.6</version>
<type>gem</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>bundler</artifactId>
Expand Down
38 changes: 19 additions & 19 deletions src/spec/ruby/action_controller/session/java_servlet_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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'
Expand All @@ -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!
Expand All @@ -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
Expand All @@ -240,15 +240,15 @@
@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)
end

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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/spec/ruby/jruby/rack/app_layout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@

shared_examples "FileSystemLayout" do

@@__work_dir__ = Dir.pwd
__work_dir__ = Dir.pwd

before do
require 'tmpdir'
Dir.chdir Dir.mktmpdir
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
Expand Down
12 changes: 6 additions & 6 deletions src/spec/ruby/jruby/rack/booter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/spec/ruby/jruby/rack/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/spec/ruby/jruby/rack/queues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/spec/ruby/jruby/rack/rails_booter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/spec/ruby/jruby/rack/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading