Commit 83a5d347 authored by Samuel E. Giddins's avatar Samuel E. Giddins Committed by Samuel Giddins

Start migrating to rspec

parent a4581388
--format documentation
--color
...@@ -27,15 +27,11 @@ group :development do ...@@ -27,15 +27,11 @@ group :development do
gem 'cocoapods-dependencies' gem 'cocoapods-dependencies'
gem 'bacon' gem 'rspec'
gem 'mocha'
gem 'mocha-on-bacon'
gem 'prettybacon'
gem 'webmock' gem 'webmock'
gem 'inch' gem 'inch'
# Integration tests # Integration tests
gem 'diffy'
gem 'clintegracon' gem 'clintegracon'
gem 'rubocop' gem 'rubocop'
end end
......
...@@ -119,6 +119,7 @@ GEM ...@@ -119,6 +119,7 @@ GEM
colored (1.2) colored (1.2)
crack (0.4.2) crack (0.4.2)
safe_yaml (~> 1.0.0) safe_yaml (~> 1.0.0)
diff-lcs (1.2.5)
diffy (3.0.7) diffy (3.0.7)
escape (0.0.4) escape (0.0.4)
ffi (1.9.6) ffi (1.9.6)
...@@ -137,21 +138,14 @@ GEM ...@@ -137,21 +138,14 @@ GEM
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9) rb-inotify (>= 0.9)
rb-kqueue (>= 0.2) rb-kqueue (>= 0.2)
metaclass (0.0.4)
method_source (0.8.2) method_source (0.8.2)
minitest (5.8.1) minitest (5.8.1)
mocha (1.1.0)
metaclass (~> 0.0.1)
mocha-on-bacon (0.2.2)
mocha (>= 0.13.0)
nap (1.0.0) nap (1.0.0)
netrc (0.7.8) netrc (0.7.8)
notify (0.5.2) notify (0.5.2)
parser (2.2.2.6) parser (2.2.2.6)
ast (>= 1.1, < 3.0) ast (>= 1.1, < 3.0)
powerpack (0.1.1) powerpack (0.1.1)
prettybacon (0.0.2)
bacon (~> 1.2)
pry (0.10.1) pry (0.10.1)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
...@@ -163,6 +157,19 @@ GEM ...@@ -163,6 +157,19 @@ GEM
ffi (>= 0.5.0) ffi (>= 0.5.0)
rb-kqueue (0.2.3) rb-kqueue (0.2.3)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
rubocop (0.34.2) rubocop (0.34.2)
astrolabe (~> 1.3) astrolabe (~> 1.3)
parser (>= 2.2.2.5, < 3.0) parser (>= 2.2.2.5, < 3.0)
...@@ -190,7 +197,7 @@ PLATFORMS ...@@ -190,7 +197,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
awesome_print awesome_print
bacon bacon (~> 1.1)
bundler (~> 1.3) bundler (~> 1.3)
claide! claide!
clintegracon clintegracon
...@@ -203,16 +210,13 @@ DEPENDENCIES ...@@ -203,16 +210,13 @@ DEPENDENCIES
cocoapods-stats! cocoapods-stats!
cocoapods-trunk! cocoapods-trunk!
cocoapods-try! cocoapods-try!
diffy
inch inch
json (= 1.7.7) json (= 1.7.7)
kicker kicker
mocha
mocha-on-bacon
molinillo! molinillo!
prettybacon
rake (~> 10.0) rake (~> 10.0)
rb-fsevent rb-fsevent
rspec
rubocop rubocop
ruby-prof ruby-prof
webmock webmock
......
...@@ -131,10 +131,10 @@ begin ...@@ -131,10 +131,10 @@ begin
puts "\033[0;32mUsing #{`ruby --version`}\033[0m" puts "\033[0;32mUsing #{`ruby --version`}\033[0m"
title 'Running the specs' title 'Running the specs'
sh "bundle exec bacon #{specs('**/*')}" sh "bundle exec rspec #{specs('**/*')}"
title 'Running Integration tests' title 'Running Integration tests'
sh 'bundle exec bacon spec/integration.rb' sh 'bundle exec rspec spec/integration.rb'
title 'Running examples' title 'Running examples'
Rake::Task['examples:build'].invoke Rake::Task['examples:build'].invoke
......
...@@ -2,8 +2,8 @@ require File.expand_path('../../../../spec_helper', __FILE__) ...@@ -2,8 +2,8 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module Pod module Pod
describe Command::Cache::Clean do describe Command::Cache::Clean do
extend SpecHelper::Command include SpecHelper::Command
extend SpecHelper::TemporaryCache include SpecHelper::TemporaryCache
before do before do
SpecHelper::TemporaryCache.set_up_test_cache SpecHelper::TemporaryCache.set_up_test_cache
......
...@@ -78,7 +78,7 @@ module Pod ...@@ -78,7 +78,7 @@ module Pod
out.should.match /target_definitions:/ out.should.match /target_definitions:/
out.should.match /platform: ios/ out.should.match /platform: ios/
out.should.match /- SSZipArchive:/ out.should.match /- SSZipArchive:/
out.should.end_with?("\n\r\n") out.should.end_with("\n\r\n")
end end
end end
......
...@@ -14,7 +14,7 @@ module Pod ...@@ -14,7 +14,7 @@ module Pod
[/BananaLib/, [/BananaLib/,
/JSONKit/, /JSONKit/,
/\d+ pods were found/, /\d+ pods were found/,
].each { |regex| out.should =~ regex } ].each { |regex| out.should.match regex }
end end
it 'presents the known pods with versions' do it 'presents the known pods with versions' do
...@@ -25,7 +25,7 @@ module Pod ...@@ -25,7 +25,7 @@ module Pod
[/BananaLib 1.0/, [/BananaLib 1.0/,
/JSONKit #{jsonkit_set.versions.first}/, /JSONKit #{jsonkit_set.versions.first}/,
/\d+ pods were found/, /\d+ pods were found/,
].each { |regex| out.should =~ regex } ].each { |regex| out.should.match regex }
end end
end end
end end
...@@ -212,68 +212,72 @@ module Pod ...@@ -212,68 +212,72 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
def it_should_check_for_existence(command) module CommandHelpers
it "errors if a given podspec doesn't exist" do def it_should_check_for_existence(command)
e = lambda { command('spec', command, 'some_pod_that_doesnt_exist').run }.should.raise Informative it "errors if a given podspec doesn't exist" do
e.message.should.match /Unable to find a pod with/ e = lambda { command('spec', command, 'some_pod_that_doesnt_exist').run }.should.raise Informative
e.message.should.match /Unable to find a pod with/
end
end end
end
def it_should_check_for_ambiguity(command) def it_should_check_for_ambiguity(command)
it 'complains provided spec name is ambigious' do it 'complains provided spec name is ambigious' do
e = lambda { command('spec', command, 'AF').run }.should.raise Informative e = lambda { command('spec', command, 'AF').run }.should.raise Informative
e.message.should.match /More than one/ e.message.should.match /More than one/
end
end end
end
def describe_regex_support(command, raise_class = nil) def describe_regex_support(command, raise_class = nil)
describe 'RegEx support' do describe 'RegEx support' do
before do before do
@test_source = Source.new(fixture('spec-repos/test_repo')) @test_source = Source.new(fixture('spec-repos/test_repo'))
Source::Aggregate.any_instance.stubs(:sources).returns([@test_source]) Source::Aggregate.any_instance.stubs(:sources).returns([@test_source])
SourcesManager.updated_search_index = nil SourcesManager.updated_search_index = nil
yield if block_given? yield if block_given?
end end
it 'raise when using an invalid regex' do it 'raise when using an invalid regex' do
lambda { run_command('spec', command, '--regex', '+') }.should.raise CLAide::Help lambda { run_command('spec', command, '--regex', '+') }.should.raise CLAide::Help
end end
it 'does not try to validate the query as a regex with plain-text mode' do it 'does not try to validate the query as a regex with plain-text mode' do
l = lambda { run_command('spec', command, '+') } l = lambda { run_command('spec', command, '+') }
if raise_class if raise_class
l.should.raise raise_class l.should.raise raise_class
else else
l.should.not.raise CLAide::Help l.should.not.raise CLAide::Help
end
end end
end
it 'uses regex search when asked for regex mode' do it 'uses regex search when asked for regex mode' do
l = lambda { run_command('spec', command, '--regex', 'Ba(na)+Lib') } l = lambda { run_command('spec', command, '--regex', 'Ba(na)+Lib') }
if raise_class if raise_class
l.should.raise raise_class l.should.raise raise_class
else else
l.should.not.raise l.should.not.raise
end
UI.output.should.include? 'BananaLib'
UI.output.should.not.include? 'Pod+With+Plus+Signs'
UI.output.should.not.include? 'JSONKit'
end end
UI.output.should.include? 'BananaLib'
UI.output.should.not.include? 'Pod+With+Plus+Signs'
UI.output.should.not.include? 'JSONKit'
end
it 'uses plain-text search when not asked for regex mode' do it 'uses plain-text search when not asked for regex mode' do
l = lambda { run_command('spec', command, 'Pod+With+Plus+Signs') } l = lambda { run_command('spec', command, 'Pod+With+Plus+Signs') }
if raise_class if raise_class
l.should.raise raise_class l.should.raise raise_class
else else
l.should.not.raise l.should.not.raise
end
UI.output.should.include? 'Pod+With+Plus+Signs'
UI.output.should.not.include? 'BananaLib'
end end
UI.output.should.include? 'Pod+With+Plus+Signs'
UI.output.should.not.include? 'BananaLib'
end end
end end
end end
describe Command::Spec::Which do describe Command::Spec::Which do
extend CommandHelpers
it_should_check_for_existence('which') it_should_check_for_existence('which')
it_should_check_for_ambiguity('which') it_should_check_for_ambiguity('which')
...@@ -289,6 +293,8 @@ module Pod ...@@ -289,6 +293,8 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe Command::Spec::Cat do describe Command::Spec::Cat do
extend CommandHelpers
it_should_check_for_existence('cat') it_should_check_for_existence('cat')
it_should_check_for_ambiguity('cat') it_should_check_for_ambiguity('cat')
...@@ -309,6 +315,8 @@ module Pod ...@@ -309,6 +315,8 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe Command::Spec::Edit do describe Command::Spec::Edit do
extend CommandHelpers
before do before do
@path_saved = ENV['PATH'] @path_saved = ENV['PATH']
end end
......
...@@ -150,29 +150,29 @@ describe_cli 'pod' do ...@@ -150,29 +150,29 @@ describe_cli 'pod' do
# Test subspecs inheritance # Test subspecs inheritance
describe 'Integrates a project with CocoaPods' do describe 'Integrates a project with CocoaPods' do
behaves_like cli_spec 'install_new', it_behaves_like cli_spec 'install_new',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Adds a Pod to an existing installation' do describe 'Adds a Pod to an existing installation' do
behaves_like cli_spec 'install_add_pod', it_behaves_like cli_spec 'install_add_pod',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Removes a Pod from an existing installation' do describe 'Removes a Pod from an existing installation' do
behaves_like cli_spec 'install_remove_pod', it_behaves_like cli_spec 'install_remove_pod',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Creates an installation with multiple target definitions' do describe 'Creates an installation with multiple target definitions' do
behaves_like cli_spec 'install_multiple_targets', it_behaves_like cli_spec 'install_multiple_targets',
'install --no-repo-update' 'install --no-repo-update'
end end
description = 'Installs a Pod with different subspecs activated across different targets' description = 'Installs a Pod with different subspecs activated across different targets'
if has_mercurial if has_mercurial
describe description do describe description do
behaves_like cli_spec 'install_subspecs', it_behaves_like cli_spec 'install_subspecs',
'install --no-repo-update' 'install --no-repo-update'
end end
else else
...@@ -180,19 +180,19 @@ describe_cli 'pod' do ...@@ -180,19 +180,19 @@ describe_cli 'pod' do
end end
describe 'Installs a Pod with subspecs and does not duplicate the prefix header' do describe 'Installs a Pod with subspecs and does not duplicate the prefix header' do
behaves_like cli_spec 'install_subspecs_no_duplicate_prefix', it_behaves_like cli_spec 'install_subspecs_no_duplicate_prefix',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Installs a Pod with a local source' do describe 'Installs a Pod with a local source' do
behaves_like cli_spec 'install_local_source', it_behaves_like cli_spec 'install_local_source',
'install --no-repo-update' 'install --no-repo-update'
end end
description = 'Installs a Pod with an external source' description = 'Installs a Pod with an external source'
if has_mercurial if has_mercurial
describe description do describe description do
behaves_like cli_spec 'install_external_source', it_behaves_like cli_spec 'install_external_source',
'install --no-repo-update' 'install --no-repo-update'
end end
else else
...@@ -200,47 +200,47 @@ describe_cli 'pod' do ...@@ -200,47 +200,47 @@ describe_cli 'pod' do
end end
describe 'Installs a Pod given the podspec' do describe 'Installs a Pod given the podspec' do
behaves_like cli_spec 'install_podspec', it_behaves_like cli_spec 'install_podspec',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Installs a Pod with a custom module map' do describe 'Installs a Pod with a custom module map' do
behaves_like cli_spec 'install_custom_module_map', it_behaves_like cli_spec 'install_custom_module_map',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Installs a Pod with a custom module name' do describe 'Installs a Pod with a custom module name' do
behaves_like cli_spec 'install_custom_module_name', it_behaves_like cli_spec 'install_custom_module_name',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Performs an installation using a custom workspace' do describe 'Performs an installation using a custom workspace' do
behaves_like cli_spec 'install_custom_workspace', it_behaves_like cli_spec 'install_custom_workspace',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Integrates a target with custom build settings' do describe 'Integrates a target with custom build settings' do
behaves_like cli_spec 'install_custom_build_configuration', it_behaves_like cli_spec 'install_custom_build_configuration',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Integrates a Pod with resources' do describe 'Integrates a Pod with resources' do
behaves_like cli_spec 'install_resources', it_behaves_like cli_spec 'install_resources',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Integrates a Pod without source files but with resources' do describe 'Integrates a Pod without source files but with resources' do
behaves_like cli_spec 'install_resources_no_source_files', it_behaves_like cli_spec 'install_resources_no_source_files',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Integrates a Pod using frameworks with resources' do describe 'Integrates a Pod using frameworks with resources' do
behaves_like cli_spec 'install_framework_resources', it_behaves_like cli_spec 'install_framework_resources',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Integrates a Pod using non Objective-C source files' do describe 'Integrates a Pod using non Objective-C source files' do
behaves_like cli_spec 'install_non_objective_c_files', it_behaves_like cli_spec 'install_non_objective_c_files',
'install --no-repo-update' 'install --no-repo-update'
end end
...@@ -254,12 +254,12 @@ describe_cli 'pod' do ...@@ -254,12 +254,12 @@ describe_cli 'pod' do
# @todo add tests for all the hooks API # @todo add tests for all the hooks API
# #
describe 'Runs the Podfile callbacks' do describe 'Runs the Podfile callbacks' do
behaves_like cli_spec 'install_podfile_callbacks', it_behaves_like cli_spec 'install_podfile_callbacks',
'install --no-repo-update' 'install --no-repo-update'
end end
describe 'Uses Lockfile checkout options' do describe 'Uses Lockfile checkout options' do
behaves_like cli_spec 'install_using_checkout_options', it_behaves_like cli_spec 'install_using_checkout_options',
'install --no-repo-update' 'install --no-repo-update'
end end
end end
...@@ -268,12 +268,12 @@ describe_cli 'pod' do ...@@ -268,12 +268,12 @@ describe_cli 'pod' do
describe 'Pod update' do describe 'Pod update' do
describe 'Updates an existing installation' do describe 'Updates an existing installation' do
behaves_like cli_spec 'update_all', it_behaves_like cli_spec 'update_all',
'update --no-repo-update' 'update --no-repo-update'
end end
describe 'Updates a selected Pod in an existing installation' do describe 'Updates a selected Pod in an existing installation' do
behaves_like cli_spec 'update_selected', it_behaves_like cli_spec 'update_selected',
'update Reachability --no-repo-update' 'update Reachability --no-repo-update'
end end
end end
...@@ -284,13 +284,13 @@ describe_cli 'pod' do ...@@ -284,13 +284,13 @@ describe_cli 'pod' do
describe 'Lints a Pod from source with a prepare_command' do describe 'Lints a Pod from source with a prepare_command' do
# We have to disable verbose mode by adding --no-verbose here, # We have to disable verbose mode by adding --no-verbose here,
# otherwise xcodebuild output is included in execution output. # otherwise xcodebuild output is included in execution output.
behaves_like cli_spec 'lib_lint_with_prepare_command', it_behaves_like cli_spec 'lib_lint_with_prepare_command',
'lib lint', 'lib lint',
'--no-verbose' '--no-verbose'
end end
describe 'Lints a Pod' do describe 'Lints a Pod' do
behaves_like cli_spec 'spec_lint', it_behaves_like cli_spec 'spec_lint',
'spec lint --quick' 'spec lint --quick'
end end
end end
...@@ -299,7 +299,7 @@ describe_cli 'pod' do ...@@ -299,7 +299,7 @@ describe_cli 'pod' do
describe 'Pod init' do describe 'Pod init' do
describe 'Initializes a Podfile with a single platform' do describe 'Initializes a Podfile with a single platform' do
behaves_like cli_spec 'init_single_platform', it_behaves_like cli_spec 'init_single_platform',
'init' 'init'
end end
end end
......
...@@ -20,11 +20,6 @@ ...@@ -20,11 +20,6 @@
# Set up # Set up
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
require 'rubygems'
require 'bundler/setup'
require 'bacon'
require 'mocha-on-bacon'
require 'pretty_bacon'
require 'pathname' require 'pathname'
require 'active_support/core_ext/string/strip' require 'active_support/core_ext/string/strip'
...@@ -74,25 +69,94 @@ if ENV['SKIP_XCODEBUILD'].nil? && Pod::Executable.which('xcodebuild').nil? ...@@ -74,25 +69,94 @@ if ENV['SKIP_XCODEBUILD'].nil? && Pod::Executable.which('xcodebuild').nil?
ENV['SKIP_XCODEBUILD'] = 'true' ENV['SKIP_XCODEBUILD'] = 'true'
end end
Bacon.summary_at_exit RSpec.configure do |config|
config.include SpecHelper::Fixture
config.include SpecHelper::Command
config.include Pod::Config::Mixin
def skip_xcodebuild?
ENV['SKIP_XCODEBUILD']
end
module Bacon def temporary_directory
class Context SpecHelper.temporary_directory
include Pod::Config::Mixin end
include SpecHelper::Fixture
include SpecHelper::Command
def skip_xcodebuild? config.mock_with :rspec do |mocks|
ENV['SKIP_XCODEBUILD'] mocks.syntax = :should
::Object.send(:define_method, :stubs) { |*args, &blk| stub(*args, &blk) }
::Object.send(:define_method, :expects) { |*args, &blk| should_receive(*args, &blk) }
::RSpec::Mocks::MessageExpectation.send(:define_method, :returns) { |*args, &blk| and_return(*args, &blk) }
::RSpec::Mocks::AnyInstance::StubChain.send(:define_method, :returns) { |*args, &blk| and_return(*args, &blk) }
::RSpec::Mocks::AnyInstance::PositiveExpectationChain.send(:define_method, :returns) { |*args, &blk| and_return(*args, &blk) }
::RSpec::Matchers::BuiltIn::OperatorMatcher.send(:define_method, :raise) do |*args, &blk|
matcher = ::RSpec::Matchers::BuiltIn::RaiseError.new(*args, &blk)
method = is_a?(::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher) ? :should_not : :should
@actual.send(method, matcher)
matcher.instance_variable_get(:@actual_error)
end
::RSpec::Matchers::BuiltIn::OperatorMatcher.send(:define_method, :not) { ::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher.new(@actual) }
::RSpec::Matchers::BuiltIn::OperatorMatcher.send(:include, ::RSpec::Matchers)
class BeShim
include ::RSpec::Matchers
def initialize(actual, should_method)
@actual = actual
@should_method = should_method
end
def method_missing(m, *args, &blk)
m = m.to_s.chomp('?').to_sym
matcher = case m
when :true
be_truthy
when :false
be_falsey
when :nil
be_nil
when :kind_of
be_a_kind_of(*args)
else
::RSpec::Matchers::BuiltIn::BePredicate.new(:"be_#{m}", *args, &blk)
end
@actual.send(@should_method, matcher)
end
end end
def temporary_directory ::RSpec::Matchers::BuiltIn::OperatorMatcher.send(:define_method, :be) do
SpecHelper.temporary_directory method = is_a?(::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher) ? :should_not : :should
BeShim.new(@actual, method)
end
class ::RSpec::Matchers::BuiltIn::OperatorMatcher
alias_method :cp_method_missing, :method_missing
def method_missing(m, *args, &blk)
wo = m.to_s.chomp('?').to_sym
if wo == m
cp_method_missing(m, *args, &blk)
else
send(wo, *args, &blk)
end
end
end
::RSpec::Core::ExampleGroup.send(:define_method, :stub) { |*args, &blk| double(*args, &blk) }
::RSpec::Core::ExampleGroup.send(:define_method, :mock) { |*args, &blk| double(*args, &blk) }
::RSpec::Core::ExampleGroup.send(:define_method, :should) do |*args, &blk|
d = double()
def d.raise(*args, &blk);
matcher = ::RSpec::Matchers::BuiltIn::RaiseError.new(*args)
method = @not ? :should_not : :should
blk.send(method, matcher)
matcher.instance_variable_get(:@actual_error)
end
def d.not
@not = true
self
end
d
end end
end end
end
Mocha::Configuration.prevent(:stubbing_non_existent_method) config.expect_with(:rspec) { |c| c.syntax = :should }
end
module SpecHelper module SpecHelper
def self.temporary_directory def self.temporary_directory
......
# Restores the config to the default state before each requirement # Restores the config to the default state before each requirement
module Bacon RSpec.configure do |config|
class Context config.before(:each) do
old_run_requirement = instance_method(:run_requirement) ::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
c.verbose = false
c.silent = true
c.repos_dir = fixture('spec-repos')
c.installation_root = SpecHelper.temporary_directory
c.skip_repo_update = true
c.cache_root = SpecHelper.temporary_directory + 'Cache'
end
define_method(:run_requirement) do |description, spec| ::Pod::UI.output = ''
::Pod::Config.instance = nil ::Pod::UI.warnings = ''
::Pod::Config.instance.tap do |c| ::Pod::UI.next_input = ''
c.verbose = false # The following prevents a nasty behaviour where the increments are not
c.silent = true # balanced when testing informative which might lead to sections not
c.repos_dir = fixture('spec-repos') # being printed to the output as they are too nested.
c.installation_root = SpecHelper.temporary_directory ::Pod::UI.indentation_level = 0
c.skip_repo_update = true ::Pod::UI.title_level = 0
c.cache_root = SpecHelper.temporary_directory + 'Cache'
end
::Pod::UI.output = '' SpecHelper.temporary_directory.rmtree if SpecHelper.temporary_directory.exist?
::Pod::UI.warnings = '' SpecHelper.temporary_directory.mkpath
::Pod::UI.next_input = ''
# The following prevents a nasty behaviour where the increments are not
# balanced when testing informative which might lead to sections not
# being printed to the output as they are too nested.
::Pod::UI.indentation_level = 0
::Pod::UI.title_level = 0
SpecHelper.temporary_directory.rmtree if SpecHelper.temporary_directory.exist? SpecHelper.tmp_repos_path.mkpath unless SpecHelper.tmp_repos_path.exist?
SpecHelper.temporary_directory.mkpath
# TODO # TODO
::Pod::SourcesManager.stubs(:search_index_path).returns(temporary_directory + 'search_index.yaml') ::Pod::SourcesManager.stubs(:search_index_path).returns(temporary_directory + 'search_index.yaml')
end
old_run_requirement.bind(self).call(description, spec) require 'webmock'
end config.after(:each) do
WebMock.reset!
end end
end end
...@@ -82,7 +82,8 @@ module SpecHelper ...@@ -82,7 +82,8 @@ module SpecHelper
module_function :tmp_repos_path module_function :tmp_repos_path
def self.extended(base) def self.extended(base)
base.before do base.send(:include, self)
base.before(:each) do
tmp_repos_path.mkpath tmp_repos_path.mkpath
end end
end end
......
...@@ -161,7 +161,7 @@ module Pod ...@@ -161,7 +161,7 @@ module Pod
end end
it 'returns the search index file' do it 'returns the search index file' do
@config.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
end end
......
...@@ -84,7 +84,7 @@ module Pod ...@@ -84,7 +84,7 @@ module Pod
end end
describe 'when the cache is incomplete' do describe 'when the cache is incomplete' do
shared 'it falls back to download the pod' do shared_examples 'it falls back to download the pod' do
describe 'when downloading a released pod' do describe 'when downloading a released pod' do
it 'does download the source' do it 'does download the source' do
Downloader::Git.any_instance.expects(:download).never Downloader::Git.any_instance.expects(:download).never
...@@ -125,7 +125,7 @@ module Pod ...@@ -125,7 +125,7 @@ module Pod
end end
describe 'because the spec is missing' do describe 'because the spec is missing' do
behaves_like 'it falls back to download the pod' it_behaves_like 'it falls back to download the pod'
end end
describe 'because the spec is invalid' do describe 'because the spec is invalid' do
...@@ -137,7 +137,7 @@ module Pod ...@@ -137,7 +137,7 @@ module Pod
end end
end end
behaves_like 'it falls back to download the pod' it_behaves_like 'it falls back to download the pod'
end end
end end
......
...@@ -22,7 +22,7 @@ module Pod ...@@ -22,7 +22,7 @@ module Pod
@subject = ExternalSources.from_dependency(dependency, podfile_path) @subject = ExternalSources.from_dependency(dependency, podfile_path)
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
path = config.sandbox.specifications_root + 'Reachability.podspec.json' path = config.sandbox.specifications_root + 'Reachability.podspec.json'
path.should.exist? path.should.exist
end end
it 'returns the description' do it 'returns the description' do
...@@ -47,22 +47,22 @@ module Pod ...@@ -47,22 +47,22 @@ module Pod
should.raise Informative do should.raise Informative do
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
end.message.should.match /No podspec found for `Reachability` in `#{temporary_directory}`/ end.message.should.match /No podspec found for `Reachability` in `#{temporary_directory}`/
end
it 'marks a pod as relative' do it 'marks a pod as relative' do
@subject.stubs(:params).returns(:path => './Reachability') @subject.stubs(:params).returns(:path => './Reachability')
Pathname.any_instance.stubs(:exist?).returns(true) Pathname.any_instance.stubs(:exist?).returns(true)
config.sandbox.stubs(:store_podspec) config.sandbox.stubs(:store_podspec)
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
config.sandbox.local_path_was_absolute?('Reachability').should.be.false config.sandbox.local_path_was_absolute?('Reachability').should.be.false
end end
it 'marks a pod as absolute' do it 'marks a pod as absolute' do
@subject.stubs(:params).returns(:path => fixture('integration/Reachability')) @subject.stubs(:params).returns(:path => fixture('integration/Reachability'))
Pathname.any_instance.stubs(:exist?).returns(true) Pathname.any_instance.stubs(:exist?).returns(true)
config.sandbox.stubs(:store_podspec) config.sandbox.stubs(:store_podspec)
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
config.sandbox.local_path_was_absolute?('Reachability').should.be.true config.sandbox.local_path_was_absolute?('Reachability').should.be.true
end
end end
describe '#podspec_path' do describe '#podspec_path' do
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
headers = %w(/some/dir/foo.h /some/dir/bar.h /some/other/dir/baz.h).map { |h| Pathname.new(h) } headers = %w(/some/dir/foo.h /some/dir/bar.h /some/other/dir/baz.h).map { |h| Pathname.new(h) }
generator = Generator::BridgeSupport.new(headers) generator = Generator::BridgeSupport.new(headers)
expected = ['-c', "-I '/some/dir' -I '/some/other/dir'", '-o', '/path/to/Pods.bridgesupport', *headers] expected = ['-c', "-I '/some/dir' -I '/some/other/dir'", '-o', '/path/to/Pods.bridgesupport', *headers]
generator.expects(:gen_bridge_metadata).with { |*command| command.map(&:to_s) == expected.map(&:to_s) } generator.expects(:gen_bridge_metadata) { |*command| command.map(&:to_s).should == expected.map(&:to_s) }
generator.save_as(Pathname.new('/path/to/Pods.bridgesupport')) generator.save_as(Pathname.new('/path/to/Pods.bridgesupport'))
end end
end end
......
...@@ -23,19 +23,16 @@ module Pod ...@@ -23,19 +23,16 @@ module Pod
@target.target_definition.whitelist_pod_for_configuration(@spec.name, 'Release') @target.target_definition.whitelist_pod_for_configuration(@spec.name, 'Release')
@podfile = @target.target_definition.podfile @podfile = @target.target_definition.podfile
@generator = AggregateXCConfig.new(@target, 'Release') @generator = AggregateXCConfig.new(@target, 'Release')
@xcconfig = @generator.generate
end end
shared 'AggregateXCConfig' do shared_examples 'AggregateXCConfig' do
it 'returns the path of the pods root relative to the user project' do it 'returns the path of the pods root relative to the user project' do
@generator.target.relative_pods_root.should == '${SRCROOT}/Pods' @generator.target.relative_pods_root.should == '${SRCROOT}/Pods'
end end
#--------------------------------------------------------------------# #--------------------------------------------------------------------#
before do
@xcconfig = @generator.generate
end
it 'generates the xcconfig' do it 'generates the xcconfig' do
@xcconfig.class.should == Xcodeproj::Config @xcconfig.class.should == Xcodeproj::Config
end end
...@@ -98,7 +95,7 @@ module Pod ...@@ -98,7 +95,7 @@ module Pod
fixture_spec('banana-lib/BananaLib.podspec') fixture_spec('banana-lib/BananaLib.podspec')
end end
behaves_like 'AggregateXCConfig' it_behaves_like 'AggregateXCConfig'
it 'configures the project to load all members that implement Objective-c classes or categories' do it 'configures the project to load all members that implement Objective-c classes or categories' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC' @xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
...@@ -146,7 +143,7 @@ module Pod ...@@ -146,7 +143,7 @@ module Pod
Target.any_instance.stubs(:requires_frameworks?).returns(true) Target.any_instance.stubs(:requires_frameworks?).returns(true)
end end
behaves_like 'AggregateXCConfig' it_behaves_like 'AggregateXCConfig'
it "doesn't configure the project to load all members that implement Objective-c classes or categories" do it "doesn't configure the project to load all members that implement Objective-c classes or categories" do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-ObjC' @xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-ObjC'
......
...@@ -571,7 +571,7 @@ module Pod ...@@ -571,7 +571,7 @@ module Pod
it 'returns that an update is required when there is no sandbox manifest' do it 'returns that an update is required when there is no sandbox manifest' do
@analyzer.sandbox.stubs(:manifest).returns(nil) @analyzer.sandbox.stubs(:manifest).returns(nil)
@analyzer.should.send(:checkout_requires_update?, @dependency) @analyzer.send(:checkout_requires_update?, @dependency).should.be.true
end end
before do before do
......
...@@ -135,7 +135,7 @@ module Pod ...@@ -135,7 +135,7 @@ module Pod
@installer.install! @installer.install!
support_files_dir = config.sandbox.target_support_files_dir('Pods') support_files_dir = config.sandbox.target_support_files_dir('Pods')
script = support_files_dir + 'Pods-resources.sh' script = support_files_dir + 'Pods-resources.sh'
script.read.should.not.include?('logo-sidebar.png') script.read.should.not.include('logo-sidebar.png')
end end
xit 'adds the resources bundles to the copy resources script' do xit 'adds the resources bundles to the copy resources script' do
......
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
end end
describe '#warn_about_xcconfig_overrides' do describe '#warn_about_xcconfig_overrides' do
shared 'warn_about_xcconfig_overrides' do def warn_about_xcconfig_overrides
target_config = stub(:name => 'Release', :build_settings => @user_target_build_settings) target_config = stub(:name => 'Release', :build_settings => @user_target_build_settings)
user_target = stub(:name => 'SampleProject', :build_configurations => [target_config]) user_target = stub(:name => 'SampleProject', :build_configurations => [target_config])
@target.stubs(:user_targets).returns([user_target]) @target.stubs(:user_targets).returns([user_target])
...@@ -61,32 +61,31 @@ module Pod ...@@ -61,32 +61,31 @@ module Pod
@target.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' } @target.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' }
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@target]) @integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@target])
@integrator.unstub(:warn_about_xcconfig_overrides)
@integrator.send(:warn_about_xcconfig_overrides) @integrator.send(:warn_about_xcconfig_overrides)
end end
it 'check that the integrated target does not override the CocoaPods build settings' do it 'check that the integrated target does not override the CocoaPods build settings' do
@user_target_build_settings = { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1'] } @user_target_build_settings = { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1'] }
behaves_like 'warn_about_xcconfig_overrides' warn_about_xcconfig_overrides
UI.warnings.should.include 'The `SampleProject [Release]` target ' \ UI.warnings.should.include 'The `SampleProject [Release]` target ' \
'overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting' 'overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting'
end end
it 'allows the use of the alternate form of the inherited flag' do it 'allows the use of the alternate form of the inherited flag' do
@user_target_build_settings = { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1', '${inherited}'] } @user_target_build_settings = { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1', '${inherited}'] }
behaves_like 'warn_about_xcconfig_overrides' warn_about_xcconfig_overrides
UI.warnings.should.not.include 'GCC_PREPROCESSOR_DEFINITIONS' UI.warnings.should.not.include 'GCC_PREPROCESSOR_DEFINITIONS'
end end
it 'allows build settings which inherit the settings form the CocoaPods xcconfig' do it 'allows build settings which inherit the settings form the CocoaPods xcconfig' do
@user_target_build_settings = { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1', '$(inherited)'] } @user_target_build_settings = { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1', '$(inherited)'] }
behaves_like 'warn_about_xcconfig_overrides' warn_about_xcconfig_overrides
UI.warnings.should.not.include 'GCC_PREPROCESSOR_DEFINITIONS' UI.warnings.should.not.include 'GCC_PREPROCESSOR_DEFINITIONS'
end end
it "ignores certain build settings which don't inherit the settings form the CocoaPods xcconfig" do it "ignores certain build settings which don't inherit the settings form the CocoaPods xcconfig" do
@user_target_build_settings = { 'CODE_SIGN_IDENTITY' => 'Mac Developer' } @user_target_build_settings = { 'CODE_SIGN_IDENTITY' => 'Mac Developer' }
behaves_like 'warn_about_xcconfig_overrides' warn_about_xcconfig_overrides
UI.warnings.should.not.include 'CODE_SIGN_IDENTITY' UI.warnings.should.not.include 'CODE_SIGN_IDENTITY'
end end
end end
......
...@@ -43,7 +43,7 @@ module Pod ...@@ -43,7 +43,7 @@ module Pod
'subspec does not exist in all versions' do 'subspec does not exist in all versions' do
@resolver.instance_variable_set(:@cached_sets, {}) @resolver.instance_variable_set(:@cached_sets, {})
possibilities = @resolver.search_for(Dependency.new('SDWebImage/Core')) possibilities = @resolver.search_for(Dependency.new('SDWebImage/Core'))
possibilities.should.not.include? nil possibilities.should.not.include nil
end end
end end
...@@ -566,7 +566,7 @@ module Pod ...@@ -566,7 +566,7 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all) resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ['AFNetworking (1.0RC3)'] specs.should.not == ['AFNetworking (1.0RC3)']
specs.should == ['AFNetworking (1.3.4)'] specs.should == ['AFNetworking (1.3.4)']
end end
...@@ -578,7 +578,7 @@ module Pod ...@@ -578,7 +578,7 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all) resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ['AFNetworking (1.0RC3)'] specs.should.not == ['AFNetworking (1.0RC3)']
specs.should == ['AFNetworking (1.0)'] specs.should == ['AFNetworking (1.0)']
end end
...@@ -590,7 +590,7 @@ module Pod ...@@ -590,7 +590,7 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all) resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ['AFNetworking (1.0RC3)'] specs.should.not == ['AFNetworking (1.0RC3)']
specs.should == ['AFNetworking (0.10.1)'] specs.should == ['AFNetworking (0.10.1)']
end end
...@@ -602,7 +602,7 @@ module Pod ...@@ -602,7 +602,7 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all) resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ['AFNetworking (1.0RC3)'] specs.should.not == ['AFNetworking (1.0RC3)']
specs.should == ['AFNetworking (1.0)'] specs.should == ['AFNetworking (1.0)']
end end
...@@ -614,7 +614,7 @@ module Pod ...@@ -614,7 +614,7 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all) resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ['AFNetworking (1.0RC3)'] specs.should.not == ['AFNetworking (1.0RC3)']
specs.should == ['AFNetworking (1.2.1)'] specs.should == ['AFNetworking (1.2.1)']
end end
...@@ -626,7 +626,7 @@ module Pod ...@@ -626,7 +626,7 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all) resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ['AFNetworking (1.0RC3)'] specs.should.not == ['AFNetworking (1.0RC3)']
specs.should == ['AFNetworking (1.2.1)'] specs.should == ['AFNetworking (1.2.1)']
end end
...@@ -638,7 +638,7 @@ module Pod ...@@ -638,7 +638,7 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all) resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ['AFNetworking (1.0RC3)'] specs.should.not == ['AFNetworking (1.0RC3)']
specs.should == ['AFNetworking (1.2.1)'] specs.should == ['AFNetworking (1.2.1)']
end end
......
...@@ -115,7 +115,7 @@ module Pod ...@@ -115,7 +115,7 @@ module Pod
end end
it 'includes folders in the resources' do it 'includes folders in the resources' do
@accessor.resources.should.include?(@root + 'Resources/sub_dir') @accessor.resources.should.include(@root + 'Resources/sub_dir')
end end
it 'returns the preserve paths' do it 'returns the preserve paths' do
...@@ -126,11 +126,11 @@ module Pod ...@@ -126,11 +126,11 @@ module Pod
it 'includes folders in the preserve paths' do it 'includes folders in the preserve paths' do
@spec_consumer.stubs(:preserve_paths).returns(['Resources']) @spec_consumer.stubs(:preserve_paths).returns(['Resources'])
@accessor.preserve_paths.should.include?(@root + 'Resources') @accessor.preserve_paths.should.include(@root + 'Resources')
end end
it 'returns the paths of the framework bundles' do it 'returns the paths of the framework bundles' do
@accessor.vendored_frameworks.should.include?(@root + 'Bananalib.framework') @accessor.vendored_frameworks.should.include(@root + 'Bananalib.framework')
end end
it 'returns the paths of the framework headers' do it 'returns the paths of the framework headers' do
...@@ -146,7 +146,7 @@ module Pod ...@@ -146,7 +146,7 @@ module Pod
end end
it 'returns the paths of the library files' do it 'returns the paths of the library files' do
@accessor.vendored_libraries.should.include?(@root + 'libBananalib.a') @accessor.vendored_libraries.should.include(@root + 'libBananalib.a')
end end
it 'returns the resource bundles of the pod' do it 'returns the resource bundles of the pod' do
...@@ -207,13 +207,14 @@ module Pod ...@@ -207,13 +207,14 @@ module Pod
it 'when false returns all source files as non-arc' do it 'when false returns all source files as non-arc' do
@spec_consumer.stubs(:requires_arc).returns(false) @spec_consumer.stubs(:requires_arc).returns(false)
@accessor.non_arc_source_files.should == @accessor.source_files @accessor.non_arc_source_files.should == @accessor.source_files
@accessor.arc_source_files.should.be.empty? @accessor.arc_source_files.should.be.kind_of(Array)
@accessor.arc_source_files.should.be.empty
end end
it 'when true returns all source files as arc' do it 'when true returns all source files as arc' do
@spec_consumer.stubs(:requires_arc).returns(true) @spec_consumer.stubs(:requires_arc).returns(true)
@accessor.arc_source_files.should == @accessor.source_files @accessor.arc_source_files.should == @accessor.source_files
@accessor.non_arc_source_files.should.be.empty? @accessor.non_arc_source_files.should.be.empty
end end
it 'when a file pattern returns all source files as arc that match' do it 'when a file pattern returns all source files as arc that match' do
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
require 'webmock'
module Bacon
class Context
alias_method :after_webmock, :after
def after(&block)
after_webmock do
block.call
WebMock.reset!
end
end
end
end
module Pod module Pod
describe Validator do describe Validator do
......
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