Skip to content

Commit

Permalink
Fixes for rspec and JRuby changes
Browse files Browse the repository at this point in the history
These were not real failures; rather they are changes in how rspec
or JRuby works since the specs were last green.
  • Loading branch information
headius committed May 23, 2024
1 parent 784c81e commit 1e9c996
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 86 deletions.
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
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
8 changes: 4 additions & 4 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
Loading

0 comments on commit 1e9c996

Please sign in to comment.