-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0040bd
commit c8f38c2
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
bundler/helpers/v2/spec/definition_bundler_spec_set_patch_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
require "native_spec_helper" | ||
require "shared_contexts" | ||
|
||
RSpec.describe Bundler::LazySpecification do | ||
let(:specification) do | ||
spec = Bundler::LazySpecification.new("example", "1.1.0", nil) | ||
spec.extend(BundlerSpecSetPatch) | ||
spec | ||
end | ||
|
||
describe "#default_gem?" do | ||
let(:default_spec_dir) { "/mocked/default/spec/dir" } | ||
before do | ||
allow(Gem).to receive(:default_specifications_dir).and_return(default_spec_dir) | ||
end | ||
|
||
context "when the gem is a default gem" do | ||
it "returns true if the loaded_from path is in the default specifications directory" do | ||
specification.loaded_from = File.join(default_spec_dir, "example-1.1.0.gemspec") | ||
expect(specification.default_gem?).to be true | ||
end | ||
end | ||
|
||
context "when loaded_from is nil" do | ||
it "returns false" do | ||
specification.loaded_from = nil | ||
expect(specification.default_gem?).to be false | ||
end | ||
end | ||
|
||
context "when the gem is not a default gem" do | ||
it "returns false if the loaded_from path is not in the default specifications directory" do | ||
non_default_dir = "/path/to/non/default/directory" | ||
specification.loaded_from = File.join(non_default_dir, "example-1.1.0.gemspec") | ||
expect(specification.default_gem?).to be false | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters