Skip to content

Commit 8093995

Browse files
committed
use full file path (with DLEXT)
1 parent 3e1f84b commit 8093995

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

lib/sqlite_extensions/uuid.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# frozen_string_literal: true
22

3+
require "rbconfig"
4+
35
module SqliteExtensions
46
module UUID
57
def self.to_path
68
spec = Gem.loaded_specs["sqlite_extensions-uuid"]
7-
File.join(spec.require_path, "sqlite_extensions/uuid/uuid")
9+
path = File.join(spec.require_path, "sqlite_extensions/uuid/uuid")
10+
path + "." + RbConfig::CONFIG.fetch("DLEXT")
811
end
912
end
1013
end

spec/sqlite_extensions/uuid_spec.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,36 @@
66
end
77

88
describe "#to_path" do
9+
subject { described_class.to_path }
10+
911
before do
1012
gemspec = instance_double(Gem::Specification, require_path: "foo")
1113
allow(Gem).to receive(:loaded_specs).and_return("sqlite_extensions-uuid" => gemspec)
14+
allow(RbConfig::CONFIG).to receive(:fetch).with("DLEXT").and_return("so")
15+
end
16+
17+
context "when linux" do
18+
before do
19+
allow(RbConfig::CONFIG).to receive(:fetch).with("DLEXT").and_return("so")
20+
end
21+
22+
it { is_expected.to eq "foo/sqlite_extensions/uuid/uuid.so" }
23+
end
24+
25+
context "when mac with .dylib extension" do
26+
before do
27+
allow(RbConfig::CONFIG).to receive(:fetch).with("DLEXT").and_return("dylib")
28+
end
29+
30+
it { is_expected.to eq "foo/sqlite_extensions/uuid/uuid.dylib" }
1231
end
1332

14-
it "returns the path to the compiled extension" do
15-
path = described_class.to_path
33+
context "when mac with .bundle extension" do
34+
before do
35+
allow(RbConfig::CONFIG).to receive(:fetch).with("DLEXT").and_return("bundle")
36+
end
1637

17-
expect(path).to eq "foo/sqlite_extensions/uuid/uuid"
38+
it { is_expected.to eq "foo/sqlite_extensions/uuid/uuid.bundle" }
1839
end
1940
end
2041

0 commit comments

Comments
 (0)