diff options
| author | Markus Reiter | 2017-03-05 06:31:36 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-03-05 23:08:14 +0100 |
| commit | 9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2 (patch) | |
| tree | 43e99a683329471c1dc965dcc92daccb57df7e8d /Library/Homebrew/test/cask/scopes_spec.rb | |
| parent | 67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff) | |
| download | brew-9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2.tar.bz2 | |
Move Cask specs into `brew tests`.
Diffstat (limited to 'Library/Homebrew/test/cask/scopes_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/cask/scopes_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cask/scopes_spec.rb b/Library/Homebrew/test/cask/scopes_spec.rb new file mode 100644 index 000000000..330683b2a --- /dev/null +++ b/Library/Homebrew/test/cask/scopes_spec.rb @@ -0,0 +1,37 @@ +describe Hbc::Scopes, :cask do + describe "installed" do + it "returns a list installed Casks by loading Casks for all the dirs that exist in the caskroom" do + allow(Hbc).to receive(:load) { |token| "loaded-#{token}" } + + Hbc.caskroom.join("cask-bar").mkpath + Hbc.caskroom.join("cask-foo").mkpath + + installed_casks = Hbc.installed + + expect(Hbc).to have_received(:load).with("cask-bar") + expect(Hbc).to have_received(:load).with("cask-foo") + expect(installed_casks).to eq( + %w[ + loaded-cask-bar + loaded-cask-foo + ], + ) + end + + it "optimizes performance by resolving to a fully qualified path before calling Hbc.load" do + fake_tapped_cask_dir = Pathname.new(Dir.mktmpdir).join("Casks") + absolute_path_to_cask = fake_tapped_cask_dir.join("some-cask.rb") + + allow(Hbc).to receive(:load) + allow(Hbc).to receive(:all_tapped_cask_dirs) { [fake_tapped_cask_dir] } + + Hbc.caskroom.join("some-cask").mkdir + fake_tapped_cask_dir.mkdir + FileUtils.touch(absolute_path_to_cask) + + Hbc.installed + + expect(Hbc).to have_received(:load).with(absolute_path_to_cask) + end + end +end |
