Skip to content

Commit fa9f374

Browse files
authored
Merge pull request #237 from koic/replace_assert_empty_with_assert_equal_using_explicit_literals
Replace `assert_empty` with `assert_equal` using explicit literals
2 parents 37c3f0d + a44799b commit fa9f374

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

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_empty(annotations.to_h)
35+
assert_equal({}, annotations.to_h)
3636
end
3737

3838
def test_initialization_with_partial_attributes

test/mcp/client_test.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_tools_returns_empty_array_when_no_tools
4141
client = Client.new(transport: transport)
4242
tools = client.tools
4343

44-
assert_empty(tools)
44+
assert_equal([], tools)
4545
end
4646

4747
def test_call_tool_sends_request_to_transport_and_returns_content
@@ -102,7 +102,7 @@ def test_resources_returns_empty_array_when_no_resources
102102
client = Client.new(transport: transport)
103103
resources = client.resources
104104

105-
assert_empty(resources)
105+
assert_equal([], resources)
106106
end
107107

108108
def test_read_resource_sends_request_to_transport_and_returns_contents
@@ -142,7 +142,7 @@ def test_read_resource_returns_empty_array_when_no_contents
142142
client = Client.new(transport: transport)
143143
contents = client.read_resource(uri: uri)
144144

145-
assert_empty(contents)
145+
assert_equal([], contents)
146146
end
147147

148148
def test_resource_templates_sends_request_to_transport_and_returns_resource_templates_array
@@ -179,7 +179,7 @@ def test_resource_templates_returns_empty_array_when_no_resource_templates
179179
client = Client.new(transport: transport)
180180
resource_templates = client.resource_templates
181181

182-
assert_empty(resource_templates)
182+
assert_equal([], resource_templates)
183183
end
184184

185185
def test_prompts_sends_request_to_transport_and_returns_prompts_array
@@ -244,7 +244,7 @@ def test_prompts_returns_empty_array_when_no_prompts
244244
client = Client.new(transport: transport)
245245
prompts = client.prompts
246246

247-
assert_empty(prompts)
247+
assert_equal([], prompts)
248248
end
249249

250250
def test_get_prompt_sends_request_to_transport_and_returns_contents
@@ -290,7 +290,7 @@ def test_get_prompt_returns_empty_hash_when_no_contents
290290
client = Client.new(transport: transport)
291291
contents = client.get_prompt(name: name)
292292

293-
assert_empty(contents)
293+
assert_equal({}, contents)
294294
end
295295

296296
def test_get_prompt_returns_empty_hash
@@ -303,7 +303,7 @@ def test_get_prompt_returns_empty_hash
303303
client = Client.new(transport: transport)
304304
contents = client.get_prompt(name: name)
305305

306-
assert_empty(contents)
306+
assert_equal({}, contents)
307307
end
308308
end
309309
end

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_empty(icon.to_h)
26+
assert_equal({}, icon.to_h)
2727
end
2828

2929
def test_valid_theme_for_light

test/mcp/server/transports/stdio_notification_integration_test.rb

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

215215
# Start with no output
216-
assert_empty @mock_stdout.output
216+
assert_equal([], @mock_stdout.output)
217217

218218
# Add a prompt and notify
219219
@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_empty(response[:result])
48+
assert_equal({}, 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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class StreamableHTTPTransportTest < ActiveSupport::TestCase
4646
body = JSON.parse(response[2][0])
4747
assert_equal "2.0", body["jsonrpc"]
4848
assert_equal "123", body["id"]
49-
assert_empty(body["result"])
49+
assert_equal({}, body["result"])
5050
end
5151

5252
test "handles POST request with invalid JSON" do
@@ -362,7 +362,7 @@ class StreamableHTTPTransportTest < ActiveSupport::TestCase
362362
@transport.close
363363

364364
# Verify session was cleaned up
365-
assert_empty @transport.instance_variable_get(:@sessions)
365+
assert_equal({}, @transport.instance_variable_get(:@sessions))
366366
end
367367

368368
test "sends notification to correct session with multiple active sessions" do
@@ -1044,7 +1044,7 @@ class StreamableHTTPTransportTest < ActiveSupport::TestCase
10441044

10451045
response = stateless_transport.handle_request(request)
10461046
assert_equal 202, response[0]
1047-
assert_empty(response[1])
1047+
assert_equal({}, response[1])
10481048

10491049
body = response[2][0]
10501050
assert_nil(body)
@@ -1134,8 +1134,8 @@ class StreamableHTTPTransportTest < ActiveSupport::TestCase
11341134

11351135
response = @transport.handle_request(notif_request)
11361136
assert_equal 202, response[0]
1137-
assert_empty(response[1])
1138-
assert_empty(response[2])
1137+
assert_equal({}, response[1])
1138+
assert_equal([], response[2])
11391139
end
11401140

11411141
test "handles POST request with body including JSON-RPC response object and returns with no body" do
@@ -1160,8 +1160,8 @@ class StreamableHTTPTransportTest < ActiveSupport::TestCase
11601160

11611161
response = @transport.handle_request(request)
11621162
assert_equal 202, response[0]
1163-
assert_empty(response[1])
1164-
assert_empty(response[2])
1163+
assert_equal({}, response[1])
1164+
assert_equal([], response[2])
11651165
end
11661166

11671167
private

test/mcp/server_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ class Example < Tool
824824

825825
assert_equal "2.0", response[:jsonrpc]
826826
assert_equal 1, response[:id]
827-
assert_empty(response[:result])
827+
assert_equal({}, response[:result])
828828
refute response.key?(:error)
829829
end
830830

test/mcp/tool/input_schema_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class InputSchemaTest < ActiveSupport::TestCase
3333

3434
test "missing_required_arguments returns an empty array if no required arguments are missing" do
3535
input_schema = InputSchema.new(properties: { message: { type: "string" } }, required: ["message"])
36-
assert_empty input_schema.missing_required_arguments({ message: "Hello, world!" })
36+
assert_equal([], input_schema.missing_required_arguments({ message: "Hello, world!" }))
3737
end
3838

3939
test "valid schema initialization" do

test/mcp/tool/response_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ResponseTest < ActiveSupport::TestCase
107107
actual = response.to_h
108108

109109
assert_equal [:content, :isError, :structuredContent], actual.keys
110-
assert_empty actual[:content]
110+
assert_equal([], actual[:content])
111111
assert_equal structured_content, actual[:structuredContent]
112112
refute actual[:isError]
113113
end
@@ -118,7 +118,7 @@ class ResponseTest < ActiveSupport::TestCase
118118
actual = response.to_h
119119

120120
assert_equal [:content, :isError, :structuredContent], actual.keys
121-
assert_empty actual[:content]
121+
assert_equal([], actual[:content])
122122
assert_equal structured_content, actual[:structuredContent]
123123
refute actual[:isError]
124124
end

0 commit comments

Comments
 (0)