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