Skip to content

Commit bae53ad

Browse files
committed
refactor: Format test code with RuboCop
1 parent eecb4e3 commit bae53ad

File tree

3 files changed

+106
-106
lines changed

3 files changed

+106
-106
lines changed

spec/chdb/data_path_spec.rb

+38-38
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
require "fileutils"
3+
require 'spec_helper'
4+
require 'fileutils'
55

66
RSpec.describe ChDB::DataPath do
7-
let(:test_db_path) { File.join(__dir__, "testdb") }
7+
let(:test_db_path) { File.join(__dir__, 'testdb') }
88

99
before do
1010
FileUtils.rm_rf(test_db_path) if Dir.exist?(test_db_path)
1111
end
1212

1313
after { FileUtils.remove_entry(test_db_path) if Dir.exist?(test_db_path) }
1414

15-
describe "#initialize" do
16-
it "parses URI with memory path" do
17-
path = described_class.new("file::memory:?key1=value1", {})
15+
describe '#initialize' do
16+
it 'parses URI with memory path' do
17+
path = described_class.new('file::memory:?key1=value1', {})
1818
expect(path.dir_path).to match(/chdb_/)
1919
expect(path.is_tmp).to be true
20-
expect(path.query_params.transform_keys(&:to_s)).to include("key1" => "value1")
20+
expect(path.query_params.transform_keys(&:to_s)).to include('key1' => 'value1')
2121
FileUtils.remove_entry(path.dir_path)
2222
end
2323

24-
it "parses URI with file path" do
24+
it 'parses URI with file path' do
2525
path = described_class.new("file:#{test_db_path}?key1=value1", {})
2626
expect(path.dir_path).to eq(test_db_path)
27-
expect(path.query_params.transform_keys(&:to_s)).to include("key1" => "value1")
27+
expect(path.query_params.transform_keys(&:to_s)).to include('key1' => 'value1')
2828
end
2929

30-
it "parses URI with query parameters" do
31-
path = described_class.new("testdb?key1=value1&readonly=1", {})
32-
expect(path.query_params).to include("key1" => "value1", "readonly" => "1")
30+
it 'parses URI with query parameters' do
31+
path = described_class.new('testdb?key1=value1&readonly=1', {})
32+
expect(path.query_params).to include('key1' => 'value1', 'readonly' => '1')
3333
end
3434

35-
it "merges options with URI params1" do
36-
path = described_class.new("test?key1=value1", { results_as_hash: true })
37-
expect(path.query_params.transform_keys(&:to_s)).to include("key1" => "value1", "results_as_hash" => true)
35+
it 'merges options with URI params1' do
36+
path = described_class.new('test?key1=value1', { results_as_hash: true })
37+
expect(path.query_params.transform_keys(&:to_s)).to include('key1' => 'value1', 'results_as_hash' => true)
3838
end
3939

40-
it "merges options with URI params2" do
41-
path = described_class.new("test?key1=value1&results_as_hash=true", { results_as_hash: false })
42-
expect(path.query_params.transform_keys(&:to_s)).to include("key1" => "value1", "results_as_hash" => false)
40+
it 'merges options with URI params2' do
41+
path = described_class.new('test?key1=value1&results_as_hash=true', { results_as_hash: false })
42+
expect(path.query_params.transform_keys(&:to_s)).to include('key1' => 'value1', 'results_as_hash' => false)
4343
end
4444
end
4545

46-
describe "#generate_arguments" do
47-
it "filters special parameters" do
48-
path = described_class.new(":memory:", results_as_hash: true, flags: 3)
46+
describe '#generate_arguments' do
47+
it 'filters special parameters' do
48+
path = described_class.new(':memory:', results_as_hash: true, flags: 3)
4949
args = path.generate_arguments
5050
expect(args).not_to include(a_string_matching(/results_as_hash/))
5151
expect(args).not_to include(a_string_matching(/flags/))
5252
end
5353

54-
it "generates UDF arguments" do
55-
path = described_class.new("testdb", { udf_path: "/custom/udf" })
54+
it 'generates UDF arguments' do
55+
path = described_class.new('testdb', { udf_path: '/custom/udf' })
5656
args = path.generate_arguments
57-
expect(args).to include("--user_scripts_path=/custom/udf")
58-
expect(args).to include("--user_defined_executable_functions_config=/custom/udf/*.xml")
57+
expect(args).to include('--user_scripts_path=/custom/udf')
58+
expect(args).to include('--user_defined_executable_functions_config=/custom/udf/*.xml')
5959
end
6060

61-
it "handles normal parameters" do
62-
path = described_class.new("testdb", { key1: "value1" })
61+
it 'handles normal parameters' do
62+
path = described_class.new('testdb', { key1: 'value1' })
6363
args = path.generate_arguments
64-
expect(args).to include("--key1=value1")
64+
expect(args).to include('--key1=value1')
6565
end
6666
end
6767

68-
describe "directory handling" do
69-
it "creates temp dir for :memory:" do
70-
path = described_class.new(":memory:", {})
68+
describe 'directory handling' do
69+
it 'creates temp dir for :memory:' do
70+
path = described_class.new(':memory:', {})
7171
expect(path.dir_path).to match(/chdb_/)
7272
expect(path.is_tmp).to be true
7373
FileUtils.remove_entry(path.dir_path)
7474
end
7575

76-
it "uses existing directory" do
76+
it 'uses existing directory' do
7777
FileUtils.mkdir_p(test_db_path, mode: 0o755) unless Dir.exist?(test_db_path)
7878
path = described_class.new(test_db_path, { flags: 2 })
7979
expect(path.dir_path).to eq(File.expand_path(test_db_path))
8080
expect(path.is_tmp).to be false
8181
FileUtils.remove_entry(path.dir_path)
8282
end
8383

84-
it "raises error when directory not exist without CREATE flag" do
84+
it 'raises error when directory not exist without CREATE flag' do
8585
FileUtils.rm_rf(test_db_path) if Dir.exist?(test_db_path)
8686

8787
expect do
@@ -92,15 +92,15 @@
9292
end
9393
end
9494

95-
describe "mode flags" do
96-
it "sets readonly mode" do
97-
path = described_class.new("test", { readonly: true })
95+
describe 'mode flags' do
96+
it 'sets readonly mode' do
97+
path = described_class.new('test', { readonly: true })
9898
expect(path.mode & ChDB::Constants::Open::READONLY).not_to be_zero
9999
end
100100

101-
it "raises error on conflicting flags" do
101+
it 'raises error on conflicting flags' do
102102
expect do
103-
described_class.new("test", { readonly: true, flags: ChDB::Constants::Open::READWRITE })
103+
described_class.new('test', { readonly: true, flags: ChDB::Constants::Open::READWRITE })
104104
end.to raise_error(ChDB::InvalidArgumentException)
105105
end
106106
end

0 commit comments

Comments
 (0)