Skip to content

Commit e872811

Browse files
committed
style: Fix RuboCop offenses in TableFunction
- Add empty lines before assertions (auto-correctable) - Disable EmptyClass warning (acceptable for C extension placeholder) - Refactor long test method into helper methods - Rename short parameter names to meet 3-char minimum All 6 tests still passing.
1 parent cb128fa commit e872811

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

lib/duckdb/table_function.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ module DuckDB
2525
# conn.register_table_function(tf)
2626
# end
2727
#
28+
# rubocop:disable Lint/EmptyClass
2829
class TableFunction
2930
# TableFunction.create is defined in C extension
31+
# Additional Ruby methods can be added here in future phases
3032
end
33+
# rubocop:enable Lint/EmptyClass
3134
end

test/duckdb_test/table_function_test.rb

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class TableFunctionTest < Minitest::Test
77
# Test 1: Create and destroy
88
def test_create_and_destroy
99
tf = DuckDB::TableFunction.create
10+
1011
assert_instance_of DuckDB::TableFunction, tf
1112
tf.destroy
1213
end
@@ -47,27 +48,38 @@ def test_create_with_block
4748
tf.name = 'my_function'
4849
:block_result
4950
end
51+
5052
assert_equal :block_result, result
5153
end
5254

5355
# Test 7: Register without callbacks (should fail gracefully)
5456
# TODO: Enable this test once database connection issue is resolved
5557
def _test_register_without_callbacks
56-
db = DuckDB::Database.new
57-
conn = db.connect
58-
59-
tf = DuckDB::TableFunction.create
60-
tf.name = 'incomplete_function'
61-
tf.add_parameter(DuckDB::LogicalType::BIGINT)
58+
database, conn, table_function = setup_incomplete_function
6259

6360
# Should fail because no bind/init/execute callbacks set
6461
assert_raises(DuckDB::Error) do
65-
conn.register_table_function(tf)
62+
conn.register_table_function(table_function)
6663
end
6764

68-
tf.destroy
65+
cleanup_function(table_function, conn, database)
66+
end
67+
68+
private
69+
70+
def setup_incomplete_function
71+
database = DuckDB::Database.new
72+
conn = database.connect
73+
table_function = DuckDB::TableFunction.create
74+
table_function.name = 'incomplete_function'
75+
table_function.add_parameter(DuckDB::LogicalType::BIGINT)
76+
[database, conn, table_function]
77+
end
78+
79+
def cleanup_function(table_function, conn, database)
80+
table_function.destroy
6981
conn.disconnect
70-
db.close
82+
database.close
7183
end
7284
end
7385
end

0 commit comments

Comments
 (0)