Skip to content

Commit f43c340

Browse files
committed
fix tests
1 parent efac287 commit f43c340

File tree

9 files changed

+25
-145
lines changed

9 files changed

+25
-145
lines changed

lib/mcp/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# require_relative "shared/instrumentation"
55
# require_relative "shared/methods"
66

7-
module ModelContextProtocol
7+
module MCP
88
module Client
99
# Can be made an abstract class if we need shared behavior
1010

lib/mcp/client/http.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
module ModelContextProtocol
3+
module MCP
44
module Client
55
class Http
66
DEFAULT_VERSION = "0.1.0"
@@ -16,7 +16,7 @@ def initialize(url:, version: DEFAULT_VERSION, headers: {})
1616
def tools
1717
response = make_request(method: "tools/list").body
1818

19-
::ModelContextProtocol::Client::Tools.new(response)
19+
::MCP::Client::Tools.new(response)
2020
end
2121

2222
def call_tool(tool:, input:)

lib/mcp/client/tool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# typed: false
22
# frozen_string_literal: true
33

4-
module ModelContextProtocol
4+
module MCP
55
module Client
66
class Tool
77
attr_reader :payload

lib/mcp/client/tools.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# typed: false
22
# frozen_string_literal: true
33

4-
module ModelContextProtocol
4+
module MCP
55
module Client
66
class Tools
77
include Enumerable

test/model_context_protocol/client/http_test.rb renamed to test/mcp/client/http_test.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
require "faraday"
55
require "securerandom"
66
require "webmock/minitest"
7+
require "mcp/client/http"
8+
require "mcp/client/tool"
9+
require "mcp/client/tools"
10+
require "mcp/client"
711

8-
module ModelContextProtocol
12+
module MCP
913
module Client
1014
class HttpTest < Minitest::Test
1115
def test_initialization_with_default_version
@@ -15,13 +19,13 @@ def test_initialization_with_default_version
1519

1620
def test_initialization_with_custom_version
1721
custom_version = "1.2.3"
18-
client = Http.new(url:, version: custom_version)
22+
client = Http.new(url: url, version: custom_version)
1923
assert_equal(custom_version, client.version)
2024
end
2125

2226
def test_headers_are_added_to_the_request
2327
headers = { "Authorization" => "Bearer token" }
24-
client = Http.new(url:, headers:)
28+
client = Http.new(url: url, headers: headers)
2529
client.stubs(:request_id).returns(mock_request_id)
2630

2731
stub_request(:post, url)
@@ -467,7 +471,7 @@ def url
467471

468472
def client
469473
@client ||= begin
470-
client = Http.new(url:)
474+
client = Http.new(url: url)
471475
client.stubs(:request_id).returns(mock_request_id)
472476
client
473477
end

test/model_context_protocol/client/tool_test.rb renamed to test/mcp/client/tool_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# frozen_string_literal: true
22

33
require "test_helper"
4+
require "mcp/client/tool"
45

5-
module ModelContextProtocol
6+
module MCP
67
module Client
78
class ToolTest < Minitest::Test
89
def test_name_returns_name_from_payload

test/model_context_protocol/client/tools_test.rb renamed to test/mcp/client/tools_test.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# frozen_string_literal: true
22

33
require "test_helper"
4+
require "mcp/client/tools"
5+
require "mcp/client/tool"
46

5-
module ModelContextProtocol
7+
module MCP
68
module Client
79
class ToolsTest < Minitest::Test
810
def test_each_iterates_over_tools
@@ -43,23 +45,23 @@ def test_handles_empty_tools_array
4345
response = { "result" => { "tools" => [] } }
4446
tools = Tools.new(response)
4547

46-
assert_equal([], tools.all)
48+
assert_empty(tools.all)
4749
assert_equal(0, tools.count)
4850
end
4951

5052
def test_handles_missing_tools_key
5153
response = { "result" => {} }
5254
tools = Tools.new(response)
5355

54-
assert_equal([], tools.all)
56+
assert_empty(tools.all)
5557
assert_equal(0, tools.count)
5658
end
5759

5860
def test_handles_missing_result_key
5961
response = {}
6062
tools = Tools.new(response)
6163

62-
assert_equal([], tools.all)
64+
assert_empty(tools.all)
6365
assert_equal(0, tools.count)
6466
end
6567

@@ -87,9 +89,9 @@ def test_includes_enumerable
8789
response = { "result" => { "tools" => [] } }
8890
tools = Tools.new(response)
8991

90-
assert(tools.respond_to?(:map))
91-
assert(tools.respond_to?(:select))
92-
assert(tools.respond_to?(:find))
92+
assert_respond_to(tools, :map)
93+
assert_respond_to(tools, :select)
94+
assert_respond_to(tools, :find)
9395
end
9496
end
9597
end

test/model_context_protocol/client_test.rb renamed to test/mcp/client_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "test_helper"
44

5-
module ModelContextProtocol
5+
module MCP
66
class ClientTest < Minitest::Test
77
end
88
end

test/model_context_protocol/server/transports/stdio_transport_test.rb

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)