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