Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #52, Manage cask's install directories
This commit adds directory resources for homebrew-cask, fixing #52. * include the Homebrew::Mixin module only on the Chef::Resource class, making this easier to test * Use owner attribute otherwise fallback to the homebrew owner lookup method * Add ChefSpec scaffolding * Add a delightful variety of ChefSpec tests for default and non-default users
- Loading branch information
jtimberman
committed
Jan 12, 2015
1 parent
f7573fb
commit 5185961
Showing
4 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require_relative '../spec_helper' | ||
|
||
describe 'homebrew::cask' do | ||
context 'default user' do | ||
let(:chef_run) do | ||
ChefSpec::SoloRunner.new.converge(described_recipe) | ||
end | ||
|
||
before(:each) do | ||
allow_any_instance_of(Chef::Resource).to receive(:homebrew_owner).and_return('vagrant') | ||
end | ||
|
||
it 'updates homebrew cask as vagrant' do | ||
expect(chef_run).to run_execute('update homebrew cask from github').with( | ||
:user => 'vagrant' | ||
) | ||
end | ||
|
||
it 'manages the homebrew-cask directory' do | ||
expect(chef_run).to create_directory('/opt/homebrew-cask').with( | ||
:user => 'vagrant', | ||
:mode => 00775 | ||
) | ||
end | ||
|
||
it 'manages the Caskroom directory' do | ||
expect(chef_run).to create_directory('/opt/homebrew-cask/Caskroom').with( | ||
:user => 'vagrant', | ||
:mode => 00775 | ||
) | ||
end | ||
end | ||
|
||
context 'non-default, specified by attribute user' do | ||
let(:chef_run) do | ||
ChefSpec::SoloRunner.new do |node| | ||
node.set['homebrew']['owner'] = 'alaska' | ||
end.converge(described_recipe) | ||
end | ||
|
||
it 'updates homebrew cask as alaska' do | ||
expect(chef_run).to run_execute('update homebrew cask from github').with( | ||
:user => 'alaska' | ||
) | ||
end | ||
|
||
it 'manages the homebrew-cask directory' do | ||
expect(chef_run).to create_directory('/opt/homebrew-cask').with( | ||
:user => 'alaska', | ||
:mode => 00775 | ||
) | ||
end | ||
|
||
it 'manages the Caskroom directory' do | ||
expect(chef_run).to create_directory('/opt/homebrew-cask/Caskroom').with( | ||
:user => 'alaska', | ||
:mode => 00775 | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'chefspec' | ||
require 'chefspec/berkshelf' | ||
|
||
# Require all our libraries | ||
Dir['libraries/*.rb'].each { |f| require File.expand_path(f) } | ||
|
||
RSpec.configure do |config| | ||
config.log_level = :fatal | ||
config.order = 'random' | ||
config.color = true | ||
config.formatter = 'documentation' | ||
end |