Commit d59409f6 authored by Fabio Pelosin's avatar Fabio Pelosin

[Specs] Cleaning up temporary repos helper.

parent 139d0099
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::List" do describe "Pod::Command::List" do
extend SpecHelper::Git extend SpecHelper::TemporaryRepos
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
......
...@@ -2,8 +2,12 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,8 +2,12 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Command::Push do describe Pod::Command::Push do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
def master_repo
fixture('spec-repos/master')
end
it "complains for wrong parameters" do it "complains for wrong parameters" do
lambda { run_command('push') }.should.raise Pod::Command::Help lambda { run_command('push') }.should.raise Pod::Command::Help
...@@ -12,19 +16,19 @@ describe Pod::Command::Push do ...@@ -12,19 +16,19 @@ describe Pod::Command::Push do
end end
it "complains if it can't find the repo" do it "complains if it can't find the repo" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) repo1 = add_repo('repo1', master_repo)
Dir.chdir(fixture('banana-lib')) do Dir.chdir(fixture('banana-lib')) do
lambda { run_command('push', 'repo2') }.should.raise Pod::Informative lambda { run_command('push', 'repo2') }.should.raise Pod::Informative
end end
end end
it "complains if it can't find a spec" do it "complains if it can't find a spec" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) repo1 = add_repo('repo1', master_repo)
lambda { run_command('push', 'repo1') }.should.raise Pod::Informative lambda { run_command('push', 'repo1') }.should.raise Pod::Informative
end end
it "it raises if the pod is not validated" do it "it raises if the pod is not validated" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) repo1 = add_repo('repo1', master_repo)
git('repo1', 'checkout master') # checkout master, because the fixture is a submodule git('repo1', 'checkout master') # checkout master, because the fixture is a submodule
repo2 = add_repo('repo2', repo1.dir) repo2 = add_repo('repo2', repo1.dir)
git_config('repo2', 'remote.origin.url').should == (tmp_repos_path + 'repo1').to_s git_config('repo2', 'remote.origin.url').should == (tmp_repos_path + 'repo1').to_s
...@@ -36,7 +40,7 @@ describe Pod::Command::Push do ...@@ -36,7 +40,7 @@ describe Pod::Command::Push do
before do before do
# prepare the repos # prepare the repos
@upstream = add_repo('upstream', fixture('spec-repos/master')) @upstream = add_repo('upstream', master_repo)
git('upstream', 'checkout -b master') # checkout master, because the fixture is a submodule git('upstream', 'checkout -b master') # checkout master, because the fixture is a submodule
@local_repo = add_repo('local_repo', @upstream.dir) @local_repo = add_repo('local_repo', @upstream.dir)
git_config('local_repo', 'remote.origin.url').should == (tmp_repos_path + 'upstream').to_s git_config('local_repo', 'remote.origin.url').should == (tmp_repos_path + 'upstream').to_s
......
...@@ -2,8 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,8 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Repo" do describe "Pod::Command::Repo" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "runs with correct parameters" do it "runs with correct parameters" do
lambda { run_command('repo', 'add', 'NAME', 'URL') }.should.not.raise lambda { run_command('repo', 'add', 'NAME', 'URL') }.should.not.raise
......
...@@ -2,8 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,8 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Search" do describe "Pod::Command::Search" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
......
...@@ -3,8 +3,8 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,8 +3,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Setup" do describe "Pod::Command::Setup" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "runs with correct parameters" do it "runs with correct parameters" do
lambda { run_command('setup') }.should.not.raise lambda { run_command('setup') }.should.not.raise
......
...@@ -18,7 +18,7 @@ describe "Pod::Command::Spec#create" do ...@@ -18,7 +18,7 @@ describe "Pod::Command::Spec#create" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Github extend SpecHelper::Github
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::Git extend SpecHelper::TemporaryRepos
it "creates a new podspec stub file" do it "creates a new podspec stub file" do
run_command('spec', 'create', 'Bananas') run_command('spec', 'create', 'Bananas')
...@@ -94,7 +94,7 @@ end ...@@ -94,7 +94,7 @@ end
describe "Pod::Command::Spec#lint" do describe "Pod::Command::Spec#lint" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::Git extend SpecHelper::TemporaryRepos
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
......
...@@ -2,8 +2,8 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,8 +2,8 @@ require File.expand_path('../../spec_helper', __FILE__)
# describe "Pod::Command" do # describe "Pod::Command" do
# extend SpecHelper::Command # extend SpecHelper::Command
# extend SpecHelper::Git
# extend SpecHelper::TemporaryDirectory # extend SpecHelper::TemporaryDirectory
# extend SpecHelper::TemporaryRepos
# #
# TODO: # TODO:
# it "raises help informative if an unknown parameter is passed" # it "raises help informative if an unknown parameter is passed"
......
...@@ -15,9 +15,9 @@ $:.unshift((ROOT + 'spec').to_s) ...@@ -15,9 +15,9 @@ $:.unshift((ROOT + 'spec').to_s)
require 'spec_helper/color_output' require 'spec_helper/color_output'
require 'spec_helper/command' require 'spec_helper/command'
require 'spec_helper/fixture' require 'spec_helper/fixture'
require 'spec_helper/git'
require 'spec_helper/github' require 'spec_helper/github'
require 'spec_helper/temporary_directory' require 'spec_helper/temporary_directory'
require 'spec_helper/temporary_repos'
module Bacon module Bacon
extend ColorOutput extend ColorOutput
......
...@@ -2,22 +2,18 @@ require 'spec_helper/temporary_directory' ...@@ -2,22 +2,18 @@ require 'spec_helper/temporary_directory'
module SpecHelper module SpecHelper
def self.tmp_repos_path def self.tmp_repos_path
Git.tmp_repos_path TemporaryRepos.tmp_repos_path
end end
module Git module TemporaryRepos
extend Pod::Executable
executable :git
def tmp_repos_path def tmp_repos_path
SpecHelper.temporary_directory + 'cocoapods' SpecHelper.temporary_directory + 'cocoapods'
end end
module_function :tmp_repos_path module_function :tmp_repos_path
def tmp_master_repo_path
tmp_repos_path + 'master'
end
extend Pod::Executable
executable :git
alias_method :git_super, :git alias_method :git_super, :git
def git(repo, command) def git(repo, command)
Dir.chdir(tmp_repos_path + repo) do Dir.chdir(tmp_repos_path + repo) do
...@@ -42,5 +38,12 @@ module SpecHelper ...@@ -42,5 +38,12 @@ module SpecHelper
git(name, 'add README') git(name, 'add README')
git(name, 'commit -m "changed"') git(name, 'commit -m "changed"')
end end
def self.extended(base)
base.before do
tmp_repos_path.mkpath
end
end
end end
end end
...@@ -2,10 +2,8 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,10 +2,8 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Resolver" do describe "Pod::Resolver" do
before do before do
@config_before = config
Pod::Config.instance = nil
config.silent = true
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
platform :ios platform :ios
dependency 'BlocksKit' dependency 'BlocksKit'
...@@ -15,7 +13,7 @@ describe "Pod::Resolver" do ...@@ -15,7 +13,7 @@ describe "Pod::Resolver" do
end end
after do after do
Pod::Config.instance = @config_before config.repos_dir = SpecHelper.tmp_repos_path
end end
xit "holds the context state, such as cached specification sets" do xit "holds the context state, such as cached specification sets" do
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Source" do describe "Pod::Source" do
extend SpecHelper::Git
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do before do
add_repo('repo1', fixture('spec-repos/master')) add_repo('repo1', fixture('spec-repos/master'))
......
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