Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
89 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
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,76 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
module Pod | ||
describe Installer::InstallationOptions do | ||
describe 'registered options' do | ||
{ | ||
'clean' => true, | ||
'deduplicate_targets' => true, | ||
'deterministic_uuids' => true, | ||
'integrate_targets' => true, | ||
'lock_pod_sources' => true, | ||
}.each do |option, default| | ||
it "includes `#{option}` defaulting to `#{default}`" do | ||
Installer::InstallationOptions.defaults.fetch(option).should == default | ||
Installer::InstallationOptions.new.send(option).should == default | ||
end | ||
end | ||
end | ||
|
||
describe '.from_podfile' do | ||
it 'raises for a non-cocoapods install' do | ||
podfile = Podfile.new { install! 'foo', :key => 'value' } | ||
exception = should.raise(Informative) { Installer::InstallationOptions.from_podfile(podfile) } | ||
exception.message.should.include 'Currently need to specify a `cocoapods` install, you chose `foo`.' | ||
end | ||
|
||
it 'parses the name in a case-insensitive manner' do | ||
podfile = Podfile.new { install! 'CoCoApOdS' } | ||
should.not.raise(Informative) { Installer::InstallationOptions.from_podfile(podfile) } | ||
end | ||
|
||
it 'uses the installation method options to create the options' do | ||
options = { :integrate_targets => false } | ||
podfile = Podfile.new { install! 'cocoapods', options } | ||
installation_options = Installer::InstallationOptions.from_podfile(podfile) | ||
installation_options.should == Installer::InstallationOptions.new(options) | ||
end | ||
end | ||
|
||
describe '#initialize' do | ||
it 'uses all defaults when no options are specified' do | ||
Installer::InstallationOptions.new.to_h(:include_defaults => false).should.be.empty | ||
end | ||
|
||
it 'sets the values as specified in the options' do | ||
installation_options = Installer::InstallationOptions.new(:deterministic_uuids => false) | ||
installation_options.deterministic_uuids.should.be.false | ||
end | ||
|
||
it 'raises when unknown keys are encountered' do | ||
exception = should.raise(Informative) { Installer::InstallationOptions.new(:a => 'a', :b => 'b', :c => 'c') } | ||
exception.message.should.include 'Unknown installation options: a, b, and c.' | ||
end | ||
end | ||
|
||
describe '#to_h' do | ||
it 'includes all options by default' do | ||
installation_options = Installer::InstallationOptions.new(:deterministic_uuids => false) | ||
installation_options.to_h.should == { | ||
'clean' => true, | ||
'deduplicate_targets' => true, | ||
'deterministic_uuids' => false, | ||
'integrate_targets' => true, | ||
'lock_pod_sources' => true, | ||
} | ||
end | ||
|
||
it 'removes default values when specified' do | ||
installation_options = Installer::InstallationOptions.new(:deterministic_uuids => false) | ||
installation_options.to_h(:include_defaults => false).should == { | ||
'deterministic_uuids' => false, | ||
} | ||
end | ||
end | ||
end | ||
end |