Commit 8c920151 authored by Kyle Fuller's avatar Kyle Fuller

[Specs] Stop using `sut`

parent cdf94bda
......@@ -356,14 +356,14 @@ module Pod
before do
# TODO Use class methods
@sut = Command::Spec.new(CLAide::ARGV.new([]))
@command = Command::Spec.new(CLAide::ARGV.new([]))
end
describe '#get_path_of_spec' do
it 'returns the path of the specification with the given name' do
path = @sut.send(:get_path_of_spec, 'AFNetworking')
path = @command.send(:get_path_of_spec, 'AFNetworking')
path.should == fixture('spec-repos') + 'master/Specs/AFNetworking/2.4.1/AFNetworking.podspec.json'
end
......@@ -373,16 +373,16 @@ module Pod
it 'should return a valid index for the given array' do
UI.next_input = "1\n"
index = @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message')
index = @command.send(:choose_from_array, %w(item1 item2 item3), 'A message')
UI.output.should.include "1: item1\n2: item2\n3: item3\nA message\n"
index.should == 0
end
it 'should raise when the index is out of bounds' do
UI.next_input = "4\n"
lambda { @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
lambda { @command.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
UI.next_input = "0\n"
lambda { @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
lambda { @command.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
end
end
......
......@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Config do
before do
@sut = Config.new(false)
@config = Config.new(false)
end
#-------------------------------------------------------------------------#
......@@ -11,35 +11,35 @@ module Pod
describe 'In general' do
it 'returns the singleton config instance' do
@sut.should.be.instance_of Config
@config.should.be.instance_of Config
end
it 'returns the path to the home dir' do
@sut.home_dir.should == Pathname.new('~/.cocoapods').expand_path
@config.home_dir.should == Pathname.new('~/.cocoapods').expand_path
end
it 'returns the path to the spec-repos dir' do
@sut.repos_dir.should == Pathname.new('~/.cocoapods/repos').expand_path
@config.repos_dir.should == Pathname.new('~/.cocoapods/repos').expand_path
end
it 'returns the path to the templates dir' do
@sut.templates_dir.should == Pathname.new('~/.cocoapods/templates').expand_path
@config.templates_dir.should == Pathname.new('~/.cocoapods/templates').expand_path
end
it 'returns the path of the default podfiles' do
@sut.default_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.default').expand_path
@sut.default_test_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.test').expand_path
@config.default_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.default').expand_path
@config.default_test_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.test').expand_path
end
it 'allows to specify the home dir with an environment variable' do
ENV['CP_HOME_DIR'] = '~/custom_home_dir'
@sut.home_dir.should == Pathname.new('~/custom_home_dir').expand_path
@config.home_dir.should == Pathname.new('~/custom_home_dir').expand_path
ENV.delete('CP_HOME_DIR')
end
it 'allows to specify the repos dir with an environment variable' do
ENV['CP_REPOS_DIR'] = '~/custom_repos_dir'
@sut.repos_dir.should == Pathname.new('~/custom_repos_dir').expand_path
@config.repos_dir.should == Pathname.new('~/custom_repos_dir').expand_path
ENV.delete('CP_REPOS_DIR')
end
end
......@@ -51,7 +51,7 @@ module Pod
it 'returns the working directory as the installation root if a Podfile can be found' do
Dir.chdir(temporary_directory) do
File.open('Podfile', 'w') {}
@sut.installation_root.should == temporary_directory
@config.installation_root.should == temporary_directory
end
end
......@@ -61,54 +61,54 @@ module Pod
sub_dir = temporary_directory + 'sub_dir'
sub_dir.mkpath
Dir.chdir(sub_dir) do
@sut.installation_root.should == temporary_directory
@config.installation_root.should == temporary_directory
end
end
end
it 'it returns the working directory as the installation root if no Podfile can be found' do
Dir.chdir(temporary_directory) do
@sut.installation_root.should == temporary_directory
@config.installation_root.should == temporary_directory
end
end
before do
@sut.installation_root = temporary_directory
@config.installation_root = temporary_directory
end
it 'returns the path to the project root' do
@sut.installation_root.should == temporary_directory
@config.installation_root.should == temporary_directory
end
it 'returns the path to the project Podfile if it exists' do
(temporary_directory + 'Podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'Podfile'
@config.podfile_path.should == temporary_directory + 'Podfile'
end
it 'can detect yaml Podfiles' do
(temporary_directory + 'CocoaPods.podfile.yaml').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile.yaml'
@config.podfile_path.should == temporary_directory + 'CocoaPods.podfile.yaml'
end
it 'can detect files named `CocoaPods.podfile`' do
(temporary_directory + 'CocoaPods.podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile'
@config.podfile_path.should == temporary_directory + 'CocoaPods.podfile'
end
it 'returns the path to the Pods directory that holds the dependencies' do
@sut.sandbox_root.should == temporary_directory + 'Pods'
@config.sandbox_root.should == temporary_directory + 'Pods'
end
it 'returns the Podfile path' do
Dir.chdir(temporary_directory) do
File.open('Podfile', 'w') {}
@sut.podfile_path.should == temporary_directory + 'Podfile'
@config.podfile_path.should == temporary_directory + 'Podfile'
end
end
it 'returns nils if the Podfile if no paths exists' do
Dir.chdir(temporary_directory) do
@sut.podfile_path.should.nil?
@config.podfile_path.should.nil?
end
end
......@@ -116,12 +116,12 @@ module Pod
Dir.chdir(temporary_directory) do
File.open('Podfile', 'w') {}
File.open('Podfile.lock', 'w') {}
@sut.lockfile_path.should == temporary_directory + 'Podfile.lock'
@config.lockfile_path.should == temporary_directory + 'Podfile.lock'
end
end
it 'returns the search index file' do
@sut.search_index_file.to_s.should.end_with?('search_index.yaml')
@config.search_index_file.to_s.should.end_with?('search_index.yaml')
end
end
......@@ -131,19 +131,19 @@ module Pod
describe 'Default settings' do
it 'prints out normal information' do
@sut.should.not.be.silent
@config.should.not.be.silent
end
it 'does not print verbose information' do
@sut.should.not.be.verbose
@config.should.not.be.verbose
end
it 'cleans SCM dirs in dependency checkouts' do
@sut.should.clean
@config.should.clean
end
it 'returns the cache root' do
@sut.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
@config.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
end
end
......@@ -152,13 +152,13 @@ module Pod
describe 'Private helpers' do
it 'returns the path of the user settings file' do
@sut.send(:user_settings_file).should == Pathname.new('~/.cocoapods/config.yaml').expand_path
@config.send(:user_settings_file).should == Pathname.new('~/.cocoapods/config.yaml').expand_path
end
it 'can be configured with a hash' do
hash = { :verbose => true }
@sut.send(:configure_with, hash)
@sut.should.be.verbose
@config.send(:configure_with, hash)
@config.should.be.verbose
end
#----------------------------------------#
......@@ -168,26 +168,26 @@ module Pod
it 'detects the CocoaPods.podfile.yaml file' do
expected = temporary_directory + 'CocoaPods.podfile.yaml'
File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path = @config.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it 'detects the CocoaPods.podfile file' do
expected = temporary_directory + 'CocoaPods.podfile'
File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path = @config.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it 'detects the Podfile file' do
expected = temporary_directory + 'Podfile'
File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path = @config.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it 'returns nils if the Podfile is not available' do
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path = @config.send(:podfile_path_in_dir, temporary_directory)
path.should.nil?
end
......
......@@ -77,7 +77,7 @@ module Pod
describe 'Private Helpers' do
before do
@sut = PrivatePodXCConfig.new(stub, stub)
@config = PrivatePodXCConfig.new(stub, stub)
end
#----------------------------------------#
......@@ -87,21 +87,21 @@ module Pod
it 'appends to the values of the keys of the destination the value of the keys of the source' do
source_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/MyPod' }
destination_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result = @config.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders ${PREFIX_HEADER_SEARCH_PATHS}' }
end
it 'uses the key of the destination xcconfig if not present in the source' do
source_config = {}
destination_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result = @config.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
end
it 'preserves any value of the source not present in the destination' do
source_config = { 'EXCLUDED_SOURCE_FILE_NAMES' => 'ZBarReaderViewImpl_Simulator.m' }
destination_config = {}
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result = @config.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'EXCLUDED_SOURCE_FILE_NAMES' => '${PREFIX_EXCLUDED_SOURCE_FILE_NAMES}' }
end
......@@ -112,12 +112,12 @@ module Pod
describe '#conditional_less_key' do
it 'returns the key without the xcconfig conditional syntax if present' do
result = @sut.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*][arch=*]')
result = @config.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*][arch=*]')
result.should == 'EXCLUDED_SOURCE_FILE_NAMES'
end
it 'returns the key as it is if no conditional syntax is present' do
result = @sut.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES')
result = @config.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES')
result.should == 'EXCLUDED_SOURCE_FILE_NAMES'
end
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment