Skip to content

Commit

Permalink
Merge pull request #241 from CocoaPods/amorde/tests
Browse files Browse the repository at this point in the history
Test Improvements
  • Loading branch information
amorde committed Jul 10, 2019
2 parents 12d6dcb + 199b6ab commit f95c6c2
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 12 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
@@ -1,9 +1,17 @@
osx_image: xcode10.1
language: objective-c
cache: bundler

before_install:
- bundle install
- bundle exec pod repo update --silent

env:
- TASK=rubocop
- TASK="rake spec:unit"
- TASK="rake spec:integration"
- TASK="rake spec:command"

script:
- bundle exec rake spec
- bundle exec rubocop
- bundle exec $TASK

25 changes: 21 additions & 4 deletions Rakefile
Expand Up @@ -4,9 +4,26 @@ def specs(dir)
FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
end

desc 'Runs all the specs'
task :spec do
sh "bundle exec bacon #{specs('**')}"
namespace :spec do
desc 'Runs the unit specs'
task :unit do
sh "bundle exec bacon #{specs('unit/**')}"
end

desc 'Runs the integration specs'
task :integration do
sh "bundle exec bacon #{specs('integration/**')}"
end

desc 'Runs the command specs'
task :command do
sh "bundle exec bacon #{specs('command/**')}"
end

desc 'Runs all the specs'
task :all do
sh "bundle exec bacon #{specs('**')}"
end
end

task :default => :spec
task :default => 'spec:all'
4 changes: 2 additions & 2 deletions lib/cocoapods-packager/builder.rb
Expand Up @@ -223,8 +223,8 @@ module * { export * }

def copy_license
license_file = @spec.license[:file] || 'LICENSE'
license_file = "#{@static_sandbox_root}/#{@spec.name}/#{license_file}"
`cp "#{license_file}" .` if Pathname(license_file).exist?
license_file = Pathname.new("#{@static_sandbox_root}/#{@spec.name}/#{license_file}")
FileUtils.cp(license_file, '.') if license_file.exist?
end

def copy_resources
Expand Down
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -54,6 +54,10 @@ def self.fixture(name)
Fixture.fixture(name)
end

def self.temporary_directory
ROOT + 'tmp'
end

module Fixture
ROOT = Pathname('fixtures').expand_path(__dir__)

Expand All @@ -67,5 +71,9 @@ def fixture(name)
module Bacon
class Context
include SpecHelper::Fixture

def temporary_directory
SpecHelper.temporary_directory
end
end
end
2 changes: 1 addition & 1 deletion spec/pod/utils_spec.rb → spec/unit/pod/utils_spec.rb
@@ -1,4 +1,4 @@
require File.expand_path('../../spec_helper', __FILE__)
require File.expand_path('../../../spec_helper', __FILE__)

module Pod
describe Command::Package do
Expand Down
@@ -1,7 +1,26 @@
require File.expand_path('../../spec_helper', __FILE__)
require File.expand_path('../../../spec_helper', __FILE__)

module Pod
describe Builder do
describe 'In general' do
before do
@spec = Specification.from_file('spec/fixtures/Builder.podspec')
@static_sandbox_dir = temporary_directory + 'Pods'
@installer = stub('Installer', :pod_targets => [])
@builder = Builder.new(Platform.new(:ios), @installer, nil, @static_sandbox_dir, nil, nil, @spec, nil, nil, nil, nil, nil, nil)
end

it 'copies the license file if it exists' do
path = @static_sandbox_dir + 'Builder/LICENSE.md'
path.dirname.mkpath
File.open(path, 'w') { |f| f.puts 'Permission is granted...' }
@spec.stubs(:license).returns({ :file => 'LICENSE.md'})
FileUtils.expects(:cp).with(path, '.')
@builder.send(:copy_license)
FileUtils.rm_rf(path.dirname)
end
end

describe 'Xcodebuild command' do
describe 'compiler flags' do
before do
Expand Down
@@ -1,4 +1,4 @@
require File.expand_path('../../spec_helper', __FILE__)
require File.expand_path('../../../spec_helper', __FILE__)

module Pod
describe SpecBuilder do
Expand Down
@@ -1,4 +1,4 @@
require File.expand_path('../../spec_helper', __FILE__)
require File.expand_path('../../../spec_helper', __FILE__)

module Pod
module UserInterface
Expand Down

0 comments on commit f95c6c2

Please sign in to comment.