Commit 71983133 authored by Fabio Pelosin's avatar Fabio Pelosin

[Specs] Clean up specs helpers.

parent a6029d66
......@@ -2,7 +2,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Command::Install do
extend SpecHelper::TemporaryDirectory
it "tells the user that no Podfile or podspec was found in the current working dir" do
exception = lambda { run_command('install', '--no-update') }.should.raise Informative
......
......@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe "Command::List" do
extend SpecHelper::TemporaryRepos
extend SpecHelper::TemporaryDirectory
before do
set_up_test_repo
......
......@@ -2,7 +2,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Command::Outdated do
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "tells the user that no Podfile was found in the current working dir" do
......
......@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Command::Push do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do
......
......@@ -4,7 +4,6 @@ module Pod
describe Command::Repo do
describe "In general" do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do
......
......@@ -2,7 +2,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Command::Search do
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do
......
......@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Command::Setup do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do
......
......@@ -4,7 +4,6 @@ module Pod
describe Command::Spec do
describe "In general" do
extend SpecHelper::TemporaryDirectory
it "complains for wrong parameters" do
lambda { run_command('spec') }.should.raise CLAide::Help
......@@ -20,7 +19,6 @@ module Pod
describe "create subcommand" do
extend SpecHelper::Github
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "creates a new podspec stub file" do
......@@ -98,7 +96,6 @@ module Pod
#-------------------------------------------------------------------------#
describe "lint subcommand" do
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "complains if it can't find any spec to lint" do
......@@ -149,8 +146,6 @@ module Pod
#-------------------------------------------------------------------------#
describe "cat subcommand" do
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "complains it cant't find a spec to read" do
......
......@@ -2,7 +2,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Command::Update do
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "tells the user that no Podfile was found in the current working dir" do
......
......@@ -45,7 +45,6 @@ module Pod
#-------------------------------------------------------------------------#
describe "Single platform" do
extend SpecHelper::TemporaryDirectory
# it "includes automatically inherited subspecs" do
# end
......@@ -199,7 +198,6 @@ module Pod
[:ios, :osx].each do |test_platform|
describe "Multi-platform (#{test_platform})" do
extend SpecHelper::TemporaryDirectory
before do
FileUtils.cp_r(fixture('integration/.'), config.project_pods_root)
......
require 'rubygems'
require 'bundler/setup'
require 'bacon'
require 'mocha-on-bacon'
Bacon.summary_at_exit
require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
require "active_support/core_ext/string/strip"
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
$:.unshift((ROOT + 'lib').to_s)
$:.unshift((ROOT + 'spec').to_s)
require 'cocoapods'
require 'claide'
$:.unshift((ROOT + 'spec').to_s)
require 'spec_helper/bacon'
require 'spec_helper/command'
require 'spec_helper/fixture'
require 'spec_helper/github'
require 'spec_helper/temporary_directory'
require 'spec_helper/temporary_repos'
require 'spec_helper/user_interface'
require 'spec_helper/pre_flight'
require 'spec_helper/bacon' # Prettifies the bacon output and adds support for `xit`.
require 'spec_helper/command' # Allows to run Pod commands and returns their output.
require 'spec_helper/fixture' # Provides access to the fixtures and unpacks them if needed.
require 'spec_helper/temporary_repos' # Allows to create and modify temporary spec repositories.
require 'spec_helper/user_interface' # Redirects UI to UI.output & UI.warnings.
require 'spec_helper/pre_flight' # Cleans the temporary directory, the config & the UI.output before every test.
require 'spec_helper/github' # Stubs Github API to return always the values (watchers).
#-----------------------------------------------------------------------------#
# README!
#
# Override {Specification#source} to return sources from fixtures and limit
# network connections.
#
module Pod
class Specification
alias :original_source :source
def source
fixture = SpecHelper.fixture("integration/#{name}")
result = super
if fixture.exist?
# puts "Using fixture [#{name}]"
result[:git] = fixture.to_s
else
# puts "MISSING fixture [#{name}]"
end
result
end
end
end
#-----------------------------------------------------------------------------#
ENV['SKIP_SETUP'] = 'true'
if ENV['SKIP_XCODEBUILD'].nil? && `which xcodebuild`.strip.empty?
ENV['SKIP_XCODEBUILD'] = 'true'
end
require 'claide'
Bacon.summary_at_exit
module Bacon
class Context
include Pod::Config::Mixin
include SpecHelper::Fixture
include SpecHelper::Command
def skip_xcodebuild?
ENV['SKIP_XCODEBUILD']
end
def temporary_directory
SpecHelper.temporary_directory
end
end
end
config = Pod::Config.instance
config.silent = true
config.repos_dir = SpecHelper.tmp_repos_path
config.project_root = SpecHelper.temporary_directory
Pod::Specification::Set::Statistics.instance.cache_file = nil
require 'tmpdir'
module SpecHelper
def self.temporary_directory
ROOT + 'tmp'
end
end
# TODO why is this no longer using SpecHelper::TemporaryDirectory ?
def temporary_sandbox
Pod::Sandbox.new(Pathname.new(Dir.mktmpdir + "/Pods"))
#Pod::Sandbox.new(temporary_directory + "Pods")
Pod::Sandbox.new(temporary_directory + "Pods")
end
def fixture_spec(name)
......@@ -65,26 +91,5 @@ end
#-----------------------------------------------------------------------------#
# Override {Specification#source} to return sources from fixtures and limit
# network connections.
#
module Pod
class Specification
alias :original_source :source
def source
fixture = SpecHelper.fixture("integration/#{name}")
result = super
if fixture.exist?
# puts "Using fixture [#{name}]"
result[:git] = fixture.to_s
else
# puts "MISSING fixture [#{name}]"
end
result
end
end
end
SpecHelper::Fixture.fixture('banana-lib') # ensure it exists
require "active_support/core_ext/string/strip"
require 'spec_helper/temporary_directory'
module SpecHelper
module Command
def argv(*argv)
......
require 'octokit'
module SpecHelper
module Github
def expect_github_repo_request(data = nil)
......
require 'fileutils'
module SpecHelper
def self.temporary_directory
TemporaryDirectory.temporary_directory
end
module TemporaryDirectory
def temporary_directory
ROOT + 'tmp'
end
module_function :temporary_directory
def setup_temporary_directory
temporary_directory.mkpath
end
def teardown_temporary_directory
temporary_directory.rmtree if temporary_directory.exist?
end
def self.extended(base)
base.before do
teardown_temporary_directory
setup_temporary_directory
end
end
end
end
require 'spec_helper/temporary_directory'
# Important
# Include with temporary directory
module SpecHelper
def self.tmp_repos_path
TemporaryRepos.tmp_repos_path
......
module Pod
# @note as some outputs wraps strings
#
module UI
@output = ''
@warnings = ''
......
......@@ -18,7 +18,6 @@ module Pod
end
describe "Concerning a user's project, which is expected in the current working directory" do
extend SpecHelper::TemporaryDirectory
before do
config.project_root = temporary_directory
......
require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::DummySource do
extend SpecHelper::TemporaryDirectory
before do
setup_temporary_directory
end
after do
teardown_temporary_directory
end
it "generates a dummy sourcefile with the appropriate class for the class name identifier" do
generator = Pod::Generator::DummySource.new('SomeIdentification')
......
......@@ -57,7 +57,7 @@ describe PrefixHeader = Pod::Generator::PrefixHeader do
@gen.generate.should.include?('#import <Cocoa/Cocoa.h>')
end
extend SpecHelper::TemporaryDirectory
it "writes the prefix header file to the disk" do
path = temporary_directory + 'Test.pch'
......
......@@ -88,7 +88,7 @@ module Pod
#-----------------------------------------------------------------------#
extend SpecHelper::TemporaryDirectory
it "saves the xcconfig" do
path = temporary_directory + 'sample.xcconfig'
......
......@@ -4,7 +4,6 @@ module Pod
describe TargetInstaller = Installer::TargetInstaller do
describe "In General" do
extend SpecHelper::TemporaryDirectory
before do
@podfile = Podfile.new do
......
......@@ -4,7 +4,7 @@ module Pod
describe Installer::UserProjectIntegrator do
describe "In general" do
extend SpecHelper::TemporaryDirectory
before do
@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
sample_project_path = @sample_project_path
......
......@@ -20,12 +20,6 @@ def generate_podfile(pods = ['JSONKit'])
pods.each { |name| pod name }
end
end
# it 'tells each pod to link its headers' do
# @pods[0].expects(:link_headers)
# do_install!
# end
module Pod
describe Installer do
......@@ -35,18 +29,22 @@ module Pod
# config.project_pods_root = @sandbox.root
# FileUtils.cp_r(fixture('integration/JSONKit'), @sandbox.root + 'JSONKit')
# end
#
describe "Concerning pre-installation computations" do
# @sandbox = temporary_sandbox
# config.project_pods_root = temporary_sandbox.root
# FileUtils.cp_r(fixture('integration/JSONKit'), @sandbox.root + 'JSONKit')
# resolver = Resolver.new(podfile, nil, @sandbox)
# @installer = Installer.new(resolver)
# target_installer = @installer.target_installers.first
# target_installer.install
# it 'tells each pod to link its headers' do
# @pods[0].expects(:link_headers)
# do_install!
# end
describe "Concerning pre-installation computations" do
# @sandbox = temporary_sandbox
# config.project_pods_root = temporary_sandbox.root
# FileUtils.cp_r(fixture('integration/JSONKit'), @sandbox.root + 'JSONKit')
# resolver = Resolver.new(podfile, nil, @sandbox)
# @installer = Installer.new(resolver)
# target_installer = @installer.target_installers.first
# target_installer.install
before do
podfile = generate_podfile
......@@ -56,23 +54,21 @@ module Pod
@installer.install!
end
# describe "#analyze" do
# it "doesn't affects creates changes in the file system" do
# end
# end
# <<<<<<< HEAD
it "marks all pods as added if there is no lockfile" do
true.should.be.true
# @installer.pods_added_from_the_lockfile.should == ['JSONKit']
# =======
# it "adds the files of the pod to the Pods project only once" do
# @installer.install!
# group = @installer.project.pods.groups.find { |g| g.name == 'Reachability' }
# group.files.map(&:name).sort.should == ["Reachability.h", "Reachability.m"]
# >>>>>>> core-extraction
end
# it "adds the files of the pod to the Pods project only once" do
# @installer.install!
# group = @installer.project.pods.groups.find { |g| g.name == 'Reachability' }
# group.files.map(&:name).sort.should == ["Reachability.h", "Reachability.m"]
# end
# it 'clears out its headers root when preparing for install' do
# @sandbox.prepare_for_install
# @sandbox.build_headers.root.should.not.exist
# end
end
# describe "by default" do
......@@ -91,22 +87,7 @@ module Pod
# target_installer.generate_xcconfig([], @sandbox)
# @xcconfig = target_installer.xcconfig.to_hash
# end
# it "generates a BridgeSupport metadata file from all the pod headers" do
# podfile = Podfile.new do
# platform :osx
# pod 'ASIHTTPRequest'
# end
# FileUtils.cp_r(fixture('integration/ASIHTTPRequest'), @sandbox.root + 'ASIHTTPRequest')
# installer = Installer.new(@sandbox, podfile)
# pods = installer.specifications.map do |spec|
# LocalPod.new(spec, installer.sandbox, podfile.target_definitions[:default].platform)
# end
# expected = pods.map { |pod| pod.header_files }.flatten.map { |header| config.project_pods_root + header }
# expected.size.should > 0
# installer.target_installers.first.bridge_support_generator_for(pods, installer.sandbox).headers.should == expected
# end
#
# it "omits empty target definitions" do
# podfile = Podfile.new do
# platform :ios
......@@ -118,16 +99,6 @@ module Pod
# installer.target_installers.map(&:target_definition).map(&:name).should == [:not_empty]
# end
# it "adds the user's build configurations" do
# path = fixture('SampleProject/SampleProject.xcodeproj')
# podfile = Podfile.new do
# platform :ios
# xcodeproj path, 'App Store' => :release
# end
# installer = Installer.new(@sandbox, podfile)
# installer.project.build_configurations.map(&:name).sort.should == ['App Store', 'Debug', 'Release', 'Test']
# end
# it "forces downloading of the `bleeding edge' version of a pod" do
# podfile = Podfile.new do
# platform :ios
......@@ -142,8 +113,6 @@ module Pod
# end
# end
# describe "concerning multiple pods originating form the same spec" do
# extend SpecHelper::Fixture
......@@ -223,8 +192,3 @@ module Pod
end
end
# it 'clears out its headers root when preparing for install' do
# @sandbox.prepare_for_install
# @sandbox.build_headers.root.should.not.exist
# end
......@@ -334,7 +334,7 @@ describe Pod::LocalPod do
end
describe "concerning a Pod with a local source" do
extend SpecHelper::TemporaryDirectory
before do
@local_path = temporary_directory + 'localBanana'
......
......@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Sandbox do
extend SpecHelper::TemporaryDirectory
before do
@sandbox = Pod::Sandbox.new(temporary_directory + 'Sandbox')
......@@ -79,7 +79,7 @@ module Pod
#---------------------------------------------------------------------------#
describe Sandbox::HeadersStore do
extend SpecHelper::TemporaryDirectory
before do
@sandbox = Pod::Sandbox.new(temporary_directory + 'Sandbox')
......
......@@ -34,7 +34,6 @@ module Pod
#-------------------------------------------------------------------------#
describe "Updating Sources" do
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "update source backed by a git repository" do
......@@ -101,7 +100,6 @@ module Pod
#-------------------------------------------------------------------------#
describe "Master repo" do
extend SpecHelper::TemporaryDirectory
it "returns the master repo dir" do
SourcesManager.master_repo_dir.to_s.should.match /fixtures\/spec-repos\/master/
......
......@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Validator do
extend SpecHelper::TemporaryDirectory
# @return [void]
#
......
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