Skip to content

Commit d32902c

Browse files
committed
Fix defs a bit
1 parent c64eea8 commit d32902c

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

config/rails_best_practices.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RemoveEmptyHelpersCheck: { }
2424
#RemoveTabCheck: { }
2525
RemoveTrailingWhitespaceCheck: { }
2626
# RemoveUnusedMethodsInControllersCheck: { except_methods: [] }
27-
RemoveUnusedMethodsInHelpersCheck: { except_methods: [] }
27+
# RemoveUnusedMethodsInHelpersCheck: { except_methods: [] }
2828
# RemoveUnusedMethodsInModelsCheck: { except_methods: [] }
2929
ReplaceComplexCreationWithFactoryMethodCheck: { attribute_assignment_count: 2 }
3030
ReplaceInstanceVariableWithLocalVariableCheck: { }

lib/tool_forge/tool_definition.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ def to_mcp_tool
231231
required_params << param_def[:name].to_s if param_def[:required]
232232
end
233233

234-
input_schema(
235-
properties: properties,
236-
required: required_params
237-
)
234+
schema_args = { properties: properties }
235+
schema_args[:required] = required_params if required_params.any?
236+
237+
input_schema(**schema_args)
238238

239239
# Create a helper object that contains all the helper methods
240240
helper_class = Class.new do

lib/tool_forge/version.rb

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

33
module ToolForge
44
# The current version of the ToolForge gem
5-
VERSION = '0.2.1'
5+
VERSION = '0.2.2'
66
end

spec/spec_helper.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
require 'simplecov'
44

5-
SimpleCov.start do
5+
SimpleCov.start 'rails' do
6+
# NOTE: ViewComponent compiles templates via class_eval; with Ruby 4 + PRISM
7+
# and branch coverage for eval, this can segfault. So we disable it here.
8+
# enable_coverage_for_eval
9+
610
enable_coverage :branch
11+
primary_coverage :branch
712
end
813

914
require 'tool_forge'

spec/tool_forge/tool_definition_to_mcp_spec.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
tool_class = tool.to_mcp_tool
4848
schema = tool_class.input_schema.to_h
4949

50-
expect(schema[:properties]).to have_key('name')
51-
expect(schema[:properties]['name'][:type]).to eq('string')
52-
expect(schema[:properties]['name'][:description]).to eq('User name')
50+
expect(schema[:properties]).to have_key(:name)
51+
expect(schema[:properties][:name][:type]).to eq('string')
52+
expect(schema[:properties][:name][:description]).to eq('User name')
5353

54-
expect(schema[:properties]).to have_key('age')
55-
expect(schema[:properties]['age'][:type]).to eq('integer')
56-
expect(schema[:properties]['age'][:description]).to eq('User age')
54+
expect(schema[:properties]).to have_key(:age)
55+
expect(schema[:properties][:age][:type]).to eq('integer')
56+
expect(schema[:properties][:age][:description]).to eq('User age')
5757

58-
expect(schema[:required]).to eq([:name])
58+
expect(schema[:required]).to eq(['name'])
5959
end
6060

6161
it 'creates a call method that executes the block' do
@@ -107,9 +107,9 @@
107107
tool_class = tool.to_mcp_tool
108108
schema = tool_class.input_schema.to_h
109109

110-
expect(schema[:properties]['name'][:type]).to eq('string')
111-
expect(schema[:properties]['count'][:type]).to eq('integer')
112-
expect(schema[:properties]['active'][:type]).to eq('boolean')
110+
expect(schema[:properties][:name][:type]).to eq('string')
111+
expect(schema[:properties][:count][:type]).to eq('integer')
112+
expect(schema[:properties][:active][:type]).to eq('boolean')
113113

114114
result = tool_class.call(server_context: nil, name: 'test', count: 5, active: true)
115115
expect(result).to be_a(MCP::Tool::Response)
@@ -128,11 +128,11 @@
128128
tool_class = tool.to_mcp_tool
129129
schema = tool_class.input_schema.to_h
130130

131-
expect(schema[:properties]['str'][:type]).to eq('string')
132-
expect(schema[:properties]['int'][:type]).to eq('integer')
133-
expect(schema[:properties]['bool'][:type]).to eq('boolean')
134-
expect(schema[:properties]['arr'][:type]).to eq('array')
135-
expect(schema[:properties]['obj'][:type]).to eq('object')
131+
expect(schema[:properties][:str][:type]).to eq('string')
132+
expect(schema[:properties][:int][:type]).to eq('integer')
133+
expect(schema[:properties][:bool][:type]).to eq('boolean')
134+
expect(schema[:properties][:arr][:type]).to eq('array')
135+
expect(schema[:properties][:obj][:type]).to eq('object')
136136
end
137137

138138
describe 'return value formatting' do

0 commit comments

Comments
 (0)