Commit 572ac974 authored by Fabio Pelosin's avatar Fabio Pelosin

[Specs] Patch bacon to reset Pod::Config::Instance.

One of the tests wasn't restoring the changes it made to the config.
As the test was difficult to track down and the problem would have
become only worse in the future, the issues was solved starting with
a new config before each run.

The performance impact seems negligible and the testing environment is
more predictable.
parent 59104c81
...@@ -7,10 +7,6 @@ describe "Pod::Command::List" do ...@@ -7,10 +7,6 @@ describe "Pod::Command::List" do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
end end
after do
config.repos_dir = tmp_repos_path
end
def command(arguments = argv) def command(arguments = argv)
command = Pod::Command::List.new(arguments) command = Pod::Command::List.new(arguments)
end end
......
...@@ -9,11 +9,6 @@ describe "Pod::Command::Search" do ...@@ -9,11 +9,6 @@ describe "Pod::Command::Search" do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
end end
after do
config.repos_dir = tmp_repos_path
end
it "runs with correct parameters" do it "runs with correct parameters" do
lambda { run_command('search', 'table') }.should.not.raise lambda { run_command('search', 'table') }.should.not.raise
lambda { run_command('search', 'table', '--full') }.should.not.raise lambda { run_command('search', 'table', '--full') }.should.not.raise
......
...@@ -100,10 +100,6 @@ describe "Pod::Command::Spec#lint" do ...@@ -100,10 +100,6 @@ describe "Pod::Command::Spec#lint" do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
end end
after do
config.repos_dir = tmp_repos_path
end
it "lints a repo" do it "lints a repo" do
# The fixture has an error due to a name mismatch # The fixture has an error due to a name mismatch
cmd = command('spec', 'lint', 'master') cmd = command('spec', 'lint', 'master')
......
...@@ -29,10 +29,6 @@ describe Pod::Installer::UserProjectIntegrator do ...@@ -29,10 +29,6 @@ describe Pod::Installer::UserProjectIntegrator do
@sample_project = Xcodeproj::Project.new(@sample_project_path) @sample_project = Xcodeproj::Project.new(@sample_project_path)
end end
after do
config.project_root = nil
end
it 'creates a workspace with a name matching the project' do it 'creates a workspace with a name matching the project' do
workspace_path = @sample_project_path.dirname + "SampleProject.xcworkspace" workspace_path = @sample_project_path.dirname + "SampleProject.xcworkspace"
workspace_path.should.exist workspace_path.should.exist
...@@ -42,12 +38,12 @@ describe Pod::Installer::UserProjectIntegrator do ...@@ -42,12 +38,12 @@ describe Pod::Installer::UserProjectIntegrator do
workspace = Xcodeproj::Workspace.new_from_xcworkspace(@sample_project_path.dirname + "SampleProject.xcworkspace") workspace = Xcodeproj::Workspace.new_from_xcworkspace(@sample_project_path.dirname + "SampleProject.xcworkspace")
workspace.projpaths.sort.should == %w{ Pods/Pods.xcodeproj SampleProject.xcodeproj } workspace.projpaths.sort.should == %w{ Pods/Pods.xcodeproj SampleProject.xcodeproj }
end end
it 'adds the Pods project to the workspace' do it 'adds the Pods project to the workspace' do
workspace = Xcodeproj::Workspace.new_from_xcworkspace(@sample_project_path.dirname + "SampleProject.xcworkspace") workspace = Xcodeproj::Workspace.new_from_xcworkspace(@sample_project_path.dirname + "SampleProject.xcworkspace")
workspace.projpaths.find { |path| path =~ /Pods.xcodeproj/ }.should.not.be.nil workspace.projpaths.find { |path| path =~ /Pods.xcodeproj/ }.should.not.be.nil
end end
it 'sets the Pods xcconfig as the base config for each build configuration' do it 'sets the Pods xcconfig as the base config for each build configuration' do
@podfile.target_definitions.each do |_, definition| @podfile.target_definitions.each do |_, definition|
target = @sample_project.targets.where(:name => definition.link_with.first) target = @sample_project.targets.where(:name => definition.link_with.first)
...@@ -70,7 +66,7 @@ describe Pod::Installer::UserProjectIntegrator do ...@@ -70,7 +66,7 @@ describe Pod::Installer::UserProjectIntegrator do
framework_build_phase.files.where(:name => definition.lib_name).should.not == nil framework_build_phase.files.where(:name => definition.lib_name).should.not == nil
end end
end end
it 'adds a Copy Pods Resources build phase to each target' do it 'adds a Copy Pods Resources build phase to each target' do
@podfile.target_definitions.each do |_, definition| @podfile.target_definitions.each do |_, definition|
target = @sample_project.targets.where(:name => definition.link_with.first) target = @sample_project.targets.where(:name => definition.link_with.first)
......
...@@ -25,30 +25,15 @@ else ...@@ -25,30 +25,15 @@ else
describe "A full (integration spec) installation for platform `#{platform}'" do describe "A full (integration spec) installation for platform `#{platform}'" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
def create_config! def create_config!
Pod::Config.instance = nil
if ENV['VERBOSE_SPECS']
config.verbose = true
else
config.silent = true
end
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
config.project_root = temporary_directory config.project_root = temporary_directory
config.doc_install = false
config.integrate_targets = false config.integrate_targets = false
end end
before do before do
fixture('spec-repos/master') # ensure the archive is unpacked fixture('spec-repos/master') # ensure the archive is unpacked
@config_before = config
create_config! create_config!
config.generate_docs = false
end
after do
Pod::Config.instance = @config_before
end end
def should_successfully_perform(command) def should_successfully_perform(command)
...@@ -193,7 +178,16 @@ else ...@@ -193,7 +178,16 @@ else
unless `which appledoc`.strip.empty? unless `which appledoc`.strip.empty?
it "generates documentation of all pods by default" do it "generates documentation of all pods by default" do
create_config! ::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
ENV['VERBOSE_SPECS'] ? c.verbose = true : c.silent = true
c.doc_install = false
c.repos_dir = fixture('spec-repos')
c.project_root = temporary_directory
c.integrate_targets = false
end
Pod::Generator::Documentation.any_instance.stubs(:already_installed?).returns(false)
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
...@@ -201,9 +195,6 @@ else ...@@ -201,9 +195,6 @@ else
dependency 'JSONKit', '1.4' dependency 'JSONKit', '1.4'
dependency 'SSToolkit' dependency 'SSToolkit'
end end
Pod::Generator::Documentation.any_instance.stubs(:already_installed?).returns(false)
installer = SpecHelper::Installer.new(podfile) installer = SpecHelper::Installer.new(podfile)
installer.install! installer.install!
...@@ -213,7 +204,7 @@ else ...@@ -213,7 +204,7 @@ else
doc.should.include?('<title>SSToolkit 0.1.2 Reference</title>') doc.should.include?('<title>SSToolkit 0.1.2 Reference</title>')
end end
else else
puts "[!] Skipping documentation generation specs, because appledoc can't be found." puts " ! ".red << "Skipping documentation generation specs, because appledoc can't be found."
end end
end end
......
...@@ -18,6 +18,7 @@ require 'spec_helper/fixture' ...@@ -18,6 +18,7 @@ require 'spec_helper/fixture'
require 'spec_helper/github' require 'spec_helper/github'
require 'spec_helper/temporary_directory' require 'spec_helper/temporary_directory'
require 'spec_helper/temporary_repos' require 'spec_helper/temporary_repos'
require 'spec_helper/config'
module Bacon module Bacon
class Context class Context
...@@ -31,8 +32,9 @@ module Bacon ...@@ -31,8 +32,9 @@ module Bacon
end end
config = Pod::Config.instance config = Pod::Config.instance
config.silent = true config.silent = true
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
config.project_root = SpecHelper.temporary_directory
Pod::Specification::Statistics.instance.cache_file = nil Pod::Specification::Statistics.instance.cache_file = nil
require 'tmpdir' require 'tmpdir'
......
# Restores the config to the default state before each requirement
module Bacon
class Context
old_run_requirement = instance_method(:run_requirement)
define_method(:run_requirement) do |description, spec|
::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
ENV['VERBOSE_SPECS'] ? c.verbose = true : c.silent = true
c.repos_dir = SpecHelper.tmp_repos_path
c.project_root = SpecHelper.temporary_directory
c.doc_install = false
c.generate_docs = false
end
old_run_requirement.bind(self).call(description, spec)
end
end
end
...@@ -2,14 +2,9 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,14 +2,9 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Config" do describe "Pod::Config" do
before do before do
@original_config = config
Pod::Config.instance = nil Pod::Config.instance = nil
end end
after do
Pod::Config.instance = @original_config
end
it "returns the singleton config instance" do it "returns the singleton config instance" do
config.should.be.instance_of Pod::Config config.should.be.instance_of Pod::Config
end end
...@@ -22,7 +17,9 @@ describe "Pod::Config" do ...@@ -22,7 +17,9 @@ describe "Pod::Config" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
it "returns the path to the project root" do it "returns the path to the project root" do
config.project_root = nil
config.project_root.should == Pathname.pwd config.project_root.should == Pathname.pwd
config.project_root = temporary_directory
end end
it "returns the path to the project Podfile if it exists" do it "returns the path to the project Podfile if it exists" do
......
...@@ -6,7 +6,7 @@ describe Pod::Generator::DummySource do ...@@ -6,7 +6,7 @@ describe Pod::Generator::DummySource do
before do before do
setup_temporary_directory setup_temporary_directory
end end
after do after do
teardown_temporary_directory teardown_temporary_directory
end end
...@@ -21,5 +21,5 @@ describe Pod::Generator::DummySource do ...@@ -21,5 +21,5 @@ describe Pod::Generator::DummySource do
@implementation PodsDummy @implementation PodsDummy
@end @end
EOS EOS
end end
end end
...@@ -21,10 +21,6 @@ describe Pod::Installer::UserProjectIntegrator do ...@@ -21,10 +21,6 @@ describe Pod::Installer::UserProjectIntegrator do
@integrator = Pod::Installer::UserProjectIntegrator.new(@podfile) @integrator = Pod::Installer::UserProjectIntegrator.new(@podfile)
end end
after do
config.project_root = nil
end
it "returns the path to the workspace from the Podfile" do it "returns the path to the workspace from the Podfile" do
@integrator.workspace_path.should == config.project_root + 'SampleProject.xcworkspace' @integrator.workspace_path.should == config.project_root + 'SampleProject.xcworkspace'
end end
......
...@@ -6,10 +6,6 @@ describe "Pod::Installer" do ...@@ -6,10 +6,6 @@ describe "Pod::Installer" do
config.project_pods_root = fixture('integration') config.project_pods_root = fixture('integration')
end end
after do
config.repos_dir = SpecHelper.tmp_repos_path
end
describe "by default" do describe "by default" do
before do before do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
......
...@@ -89,10 +89,6 @@ describe Pod::LocalPod do ...@@ -89,10 +89,6 @@ describe Pod::LocalPod do
#@destroot = fixture('integration/SSZipArchive') #@destroot = fixture('integration/SSZipArchive')
#end #end
#after do
#config.project_pods_root = nil
#end
xit "returns the list of files that the source_files pattern expand to" do xit "returns the list of files that the source_files pattern expand to" do
files = @destroot.glob('**/*.{h,c,m}') files = @destroot.glob('**/*.{h,c,m}')
files = files.map { |file| file.relative_path_from(config.project_pods_root) } files = files.map { |file| file.relative_path_from(config.project_pods_root) }
......
...@@ -12,10 +12,6 @@ describe "Pod::Resolver" do ...@@ -12,10 +12,6 @@ describe "Pod::Resolver" do
@resolver = Pod::Resolver.new(@podfile, stub('sandbox')) @resolver = Pod::Resolver.new(@podfile, stub('sandbox'))
end end
after do
config.repos_dir = SpecHelper.tmp_repos_path
end
xit "holds the context state, such as cached specification sets" do xit "holds the context state, such as cached specification sets" do
@resolver.resolve @resolver.resolve
@resolver.cached_sets.values.sort_by(&:name).should == [ @resolver.cached_sets.values.sort_by(&:name).should == [
......
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