File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3+ require "rbconfig"
4+
35module 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
1013end
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments