Skip to content

Commit

Permalink
Adding test cases for review
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-sandhu committed May 24, 2024
1 parent a0040bd commit c8f38c2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions bundler/helpers/v2/spec/definition_bundler_spec_set_patch_spec.rb
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
1 change: 1 addition & 0 deletions bundler/helpers/v2/spec/native_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Bundler monkey patches
require "definition_ruby_version_patch"
require "definition_bundler_version_patch"
require "definition_bundler_spec_set_patch"
require "git_source_patch"

require "functions"
Expand Down

0 comments on commit c8f38c2

Please sign in to comment.