Skip to content

Commit f83855b

Browse files
hsbtclaude
andcommitted
Add specs for Plugin::UnloadedSource equality
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7acf040 commit f83855b

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe Bundler::Plugin::UnloadedSource do
4+
let(:uri) { "uri://to/test" }
5+
6+
def source(type)
7+
described_class.new("uri" => uri, "type" => type)
8+
end
9+
10+
describe "equality" do
11+
it "treats sources with the same uri and type as equal" do
12+
a = source("type_a")
13+
b = source("type_a")
14+
15+
expect(a).to eq(b)
16+
expect(a).to eql(b)
17+
expect(a.hash).to eq(b.hash)
18+
end
19+
20+
it "treats sources with the same uri but different types as not equal" do
21+
a = source("type_a")
22+
b = source("type_b")
23+
24+
expect(a).not_to eq(b)
25+
expect(a).not_to eql(b)
26+
expect(a.hash).not_to eq(b.hash)
27+
end
28+
29+
it "is not equal to a real plugin source with the same uri and type" do
30+
klass = Class.new
31+
klass.send :include, Bundler::Plugin::API::Source
32+
33+
expect(source("type_a")).not_to eq(klass.new("uri" => uri, "type" => "type_a"))
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)