Skip to content

Commit 0e694e3

Browse files
committed
test: fix existing rubocop offenses
Replace empty literal assert_equal calls with assert_empty across the existing test suite so rake rubocop passes cleanly on main.
1 parent 23af995 commit 0e694e3

16 files changed

Lines changed: 35 additions & 35 deletions

test/mcp/annotations_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_initialization_by_default
3232
assert_nil(annotations.priority)
3333
assert_nil(annotations.last_modified)
3434

35-
assert_equal({}, annotations.to_h)
35+
assert_empty(annotations.to_h)
3636
end
3737

3838
def test_initialization_with_partial_attributes

test/mcp/client_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_tools_returns_empty_array_when_no_tools
119119
client = Client.new(transport: transport)
120120
tools = client.tools
121121

122-
assert_equal([], tools)
122+
assert_empty(tools)
123123
end
124124

125125
def test_call_tool_sends_request_to_transport_and_returns_content
@@ -206,7 +206,7 @@ def test_resources_returns_empty_array_when_no_resources
206206
client = Client.new(transport: transport)
207207
resources = client.resources
208208

209-
assert_equal([], resources)
209+
assert_empty(resources)
210210
end
211211

212212
def test_read_resource_sends_request_to_transport_and_returns_contents
@@ -246,7 +246,7 @@ def test_read_resource_returns_empty_array_when_no_contents
246246
client = Client.new(transport: transport)
247247
contents = client.read_resource(uri: uri)
248248

249-
assert_equal([], contents)
249+
assert_empty(contents)
250250
end
251251

252252
def test_resource_templates_sends_request_to_transport_and_returns_resource_templates_array
@@ -283,7 +283,7 @@ def test_resource_templates_returns_empty_array_when_no_resource_templates
283283
client = Client.new(transport: transport)
284284
resource_templates = client.resource_templates
285285

286-
assert_equal([], resource_templates)
286+
assert_empty(resource_templates)
287287
end
288288

289289
def test_prompts_sends_request_to_transport_and_returns_prompts_array
@@ -348,7 +348,7 @@ def test_prompts_returns_empty_array_when_no_prompts
348348
client = Client.new(transport: transport)
349349
prompts = client.prompts
350350

351-
assert_equal([], prompts)
351+
assert_empty(prompts)
352352
end
353353

354354
def test_get_prompt_sends_request_to_transport_and_returns_contents
@@ -394,7 +394,7 @@ def test_get_prompt_returns_empty_hash_when_no_contents
394394
client = Client.new(transport: transport)
395395
contents = client.get_prompt(name: name)
396396

397-
assert_equal({}, contents)
397+
assert_empty(contents)
398398
end
399399

400400
def test_get_prompt_returns_empty_hash
@@ -407,7 +407,7 @@ def test_get_prompt_returns_empty_hash
407407
client = Client.new(transport: transport)
408408
contents = client.get_prompt(name: name)
409409

410-
assert_equal({}, contents)
410+
assert_empty(contents)
411411
end
412412

413413
def test_call_tool_includes_meta_progress_token_when_provided
@@ -762,7 +762,7 @@ def test_complete_returns_default_when_result_is_missing
762762
argument: { name: "arg", value: "" },
763763
)
764764

765-
assert_equal([], result["values"])
765+
assert_empty(result["values"])
766766
refute(result["hasMore"])
767767
end
768768

@@ -780,7 +780,7 @@ def test_ping_sends_request_and_returns_empty_hash
780780
client = Client.new(transport: transport)
781781
result = client.ping
782782

783-
assert_equal({}, result)
783+
assert_empty(result)
784784
end
785785

786786
def test_ping_raises_server_error_on_error_response

test/mcp/icon_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_initialization_by_default
2323
assert_nil(icon.src)
2424
assert_nil(icon.theme)
2525

26-
assert_equal({}, icon.to_h)
26+
assert_empty(icon.to_h)
2727
end
2828

2929
def test_valid_theme_for_light

test/mcp/instrumentation_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def instrumented_method_that_raises_with_error_set
124124
error = assert_raises(RuntimeError) { subject.instrumented_method }
125125
assert_equal("boom before", error.message)
126126
assert_same(error, reported_exception)
127-
assert_equal({}, reported_context)
127+
assert_empty(reported_context)
128128
assert_equal(:internal_error, subject.instrumentation_data_received[:error])
129129
assert(subject.instrumentation_data_received.key?(:duration))
130130
end
@@ -167,7 +167,7 @@ def instrumented_method_that_raises_with_error_set
167167
end
168168

169169
assert_raises(StandardError) { subject.instrumented_with_skip }
170-
assert_equal([], reported)
170+
assert_empty(reported)
171171
end
172172

173173
test "#instrument_call reports when exception_already_reported returns false for a new exception" do
@@ -245,7 +245,7 @@ def instrumented_method_that_raises_with_error_set
245245
end
246246

247247
assert_raises(RuntimeError) { subject.instrumented_with_truthy_predicate }
248-
assert_equal([], reported)
248+
assert_empty(reported)
249249
end
250250

251251
test "#instrument_call reports when exception_already_reported returns nil" do

test/mcp/resource/contents_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class ContentsTest < ActiveSupport::TestCase
140140
result = contents.to_h
141141

142142
assert result.key?(:_meta)
143-
assert_equal({}, result[:_meta])
143+
assert_empty(result[:_meta])
144144
end
145145
end
146146
end

test/mcp/server/pagination_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class PaginationHost
6969
test "paginate with empty items returns empty array" do
7070
result = @host.paginate([], cursor: nil, page_size: 2, request: @request)
7171

72-
assert_equal [], result[:items]
72+
assert_empty result[:items]
7373
assert_nil result[:next_cursor]
7474
end
7575

test/mcp/server/transports/stdio_notification_integration_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def puts(message)
212212
# This test verifies the complete integration from server to transport
213213

214214
# Start with no output
215-
assert_equal([], @mock_stdout.output)
215+
assert_empty(@mock_stdout.output)
216216

217217
# Add a prompt and notify
218218
@server.define_prompt(

test/mcp/server/transports/stdio_transport_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class StdioTransportTest < ActiveSupport::TestCase
4545
response = JSON.parse(output.string, symbolize_names: true)
4646
assert_equal("2.0", response[:jsonrpc])
4747
assert_equal("123", response[:id])
48-
assert_equal({}, response[:result])
48+
assert_empty(response[:result])
4949
refute(@transport.instance_variable_get(:@open))
5050
ensure
5151
$stdin = original_stdin

test/mcp/server/transports/streamable_http_transport_test.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def string
7777
body = JSON.parse(io.string.match(/^data: (.+)$/)[1])
7878
assert_equal "2.0", body["jsonrpc"]
7979
assert_equal "123", body["id"]
80-
assert_equal({}, body["result"])
80+
assert_empty(body["result"])
8181
end
8282

8383
test "handles POST request with invalid JSON" do
@@ -278,7 +278,7 @@ def string
278278

279279
body = JSON.parse(response[2][0])
280280
assert_equal JsonRpcHandler::ErrorCode::INVALID_REQUEST, body["error"]["code"]
281-
assert_equal({}, @transport.instance_variable_get(:@sessions))
281+
assert_empty(@transport.instance_variable_get(:@sessions))
282282
end
283283

284284
test "rejects non-Hash JSON-RPC body with HTTP 400 and -32600" do
@@ -766,7 +766,7 @@ def string
766766
@transport.close
767767

768768
# Verify session was cleaned up
769-
assert_equal({}, @transport.instance_variable_get(:@sessions))
769+
assert_empty(@transport.instance_variable_get(:@sessions))
770770
end
771771

772772
test "cleanup_session_unsafe closes request_streams" do
@@ -2086,7 +2086,7 @@ def string
20862086

20872087
response = stateless_transport.handle_request(request)
20882088
assert_equal 202, response[0]
2089-
assert_equal({}, response[1])
2089+
assert_empty(response[1])
20902090

20912091
body = response[2][0]
20922092
assert_nil(body)
@@ -3410,8 +3410,8 @@ def string
34103410

34113411
response = @transport.handle_request(notif_request)
34123412
assert_equal 202, response[0]
3413-
assert_equal({}, response[1])
3414-
assert_equal([], response[2])
3413+
assert_empty(response[1])
3414+
assert_empty(response[2])
34153415
end
34163416

34173417
test "expired session returns 404 on GET request" do
@@ -3809,8 +3809,8 @@ def string
38093809

38103810
response = @transport.handle_request(request)
38113811
assert_equal 202, response[0]
3812-
assert_equal({}, response[1])
3813-
assert_equal([], response[2])
3812+
assert_empty(response[1])
3813+
assert_empty(response[2])
38143814
end
38153815

38163816
test "POST response without session ID returns 400" do

test/mcp/server_context_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ServerContextTest < ActiveSupport::TestCase
7878

7979
result = server_context.ping
8080

81-
assert_equal({}, result)
81+
assert_empty(result)
8282
end
8383

8484
test "ServerContext#ping raises NoMethodError when notification_target does not respond" do

0 commit comments

Comments
 (0)