brew/Library/Homebrew/test/formula_pin_spec.rb
Mike McQuaid 5e1806e796 test: rubocop-rspec style auto-corrects.
There’s too many warnings to start enabling `rubocop-rspec` by default
but let’s at least apply the cleanups it does automatically.
2018-03-25 13:30:37 +01:00

43 lines
1.0 KiB
Ruby

require "formula_pin"
describe FormulaPin do
subject { described_class.new(formula) }
let(:name) { "double" }
let(:formula) { double(Formula, name: name, rack: HOMEBREW_CELLAR/name) }
before do
formula.rack.mkpath
allow(formula).to receive(:installed_prefixes) do
formula.rack.directory? ? formula.rack.subdirs.sort : []
end
allow(formula).to receive(:installed_kegs) do
formula.installed_prefixes.map { |prefix| Keg.new(prefix) }
end
end
it "is not pinnable by default" do
expect(subject).not_to be_pinnable
end
it "is pinnable if the Keg exists" do
(formula.rack/"0.1").mkpath
expect(subject).to be_pinnable
end
specify "#pin and #unpin" do
(formula.rack/"0.1").mkpath
subject.pin
expect(subject).to be_pinned
expect(HOMEBREW_PINNED_KEGS/name).to be_a_directory
expect(HOMEBREW_PINNED_KEGS.children.count).to eq(1)
subject.unpin
expect(subject).not_to be_pinned
expect(HOMEBREW_PINNED_KEGS).not_to be_a_directory
end
end