blob: dae9f3cfba9f40e3b92fd93047370328c5a76aef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# frozen_string_literal: true
RSpec.describe Bundler::StubSpecification do
let(:with_bundler_stub_spec) do
gemspec = Gem::Specification.new do |s|
s.name = "gemname"
s.version = "1.0.0"
s.loaded_from = __FILE__
s.extensions = "ext/gemname"
end
described_class.from_stub(gemspec)
end
describe "#from_stub" do
it "returns the same stub if already a Bundler::StubSpecification" do
stub = described_class.from_stub(with_bundler_stub_spec)
expect(stub).to be(with_bundler_stub_spec)
end
end
describe "#gem_build_complete_path" do
it "StubSpecification should have equal gem_build_complete_path as Specification" do
spec_path = File.join(File.dirname(__FILE__), "specifications", "foo.gemspec")
spec = Gem::Specification.load(spec_path)
gem_stub = Gem::StubSpecification.new(spec_path, File.dirname(__FILE__),"","")
stub = described_class.from_stub(gem_stub)
expect(stub.gem_build_complete_path).to eq spec.gem_build_complete_path
end
end
describe "#manually_installed?" do
it "returns true if installed_by_version is nil or 0" do
stub = described_class.from_stub(with_bundler_stub_spec)
expect(stub.manually_installed?).to be true
end
it "returns false if installed_by_version is greater than 0" do
stub = described_class.from_stub(with_bundler_stub_spec)
stub.installed_by_version = Gem::Version.new(1)
expect(stub.manually_installed?).to be false
end
end
describe "#missing_extensions?" do
it "returns false if manually_installed?" do
stub = described_class.from_stub(with_bundler_stub_spec)
expect(stub.missing_extensions?).to be false
end
it "returns true if not manually_installed?" do
stub = described_class.from_stub(with_bundler_stub_spec)
stub.installed_by_version = Gem::Version.new(1)
expect(stub.missing_extensions?).to be true
end
end
end
|