diff --git a/.travis.yml b/.travis.yml index d608004..7f33973 100644 --- a/.travis.yml +++ b/.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 + diff --git a/Rakefile b/Rakefile index 68cc78d..e793293 100644 --- a/Rakefile +++ b/Rakefile @@ -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' diff --git a/lib/cocoapods-packager/builder.rb b/lib/cocoapods-packager/builder.rb index be54325..009d94c 100755 --- a/lib/cocoapods-packager/builder.rb +++ b/lib/cocoapods-packager/builder.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 46d25ff..af30eb8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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__) @@ -67,5 +71,9 @@ def fixture(name) module Bacon class Context include SpecHelper::Fixture + + def temporary_directory + SpecHelper.temporary_directory + end end end diff --git a/spec/pod/utils_spec.rb b/spec/unit/pod/utils_spec.rb similarity index 97% rename from spec/pod/utils_spec.rb rename to spec/unit/pod/utils_spec.rb index da1bdfd..1a4057b 100644 --- a/spec/pod/utils_spec.rb +++ b/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 diff --git a/spec/specification/builder_spec.rb b/spec/unit/specification/builder_spec.rb similarity index 67% rename from spec/specification/builder_spec.rb rename to spec/unit/specification/builder_spec.rb index b4002cb..6f91b84 100644 --- a/spec/specification/builder_spec.rb +++ b/spec/unit/specification/builder_spec.rb @@ -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 diff --git a/spec/specification/spec_builder_spec.rb b/spec/unit/specification/spec_builder_spec.rb similarity index 97% rename from spec/specification/spec_builder_spec.rb rename to spec/unit/specification/spec_builder_spec.rb index bd4d8fb..b61b59f 100644 --- a/spec/specification/spec_builder_spec.rb +++ b/spec/unit/specification/spec_builder_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../spec_helper', __FILE__) +require File.expand_path('../../../spec_helper', __FILE__) module Pod describe SpecBuilder do diff --git a/spec/user_interface/build_failed_report_spec.rb b/spec/unit/user_interface/build_failed_report_spec.rb similarity index 80% rename from spec/user_interface/build_failed_report_spec.rb rename to spec/unit/user_interface/build_failed_report_spec.rb index 22f852b..cd38fc0 100644 --- a/spec/user_interface/build_failed_report_spec.rb +++ b/spec/unit/user_interface/build_failed_report_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../spec_helper', __FILE__) +require File.expand_path('../../../spec_helper', __FILE__) module Pod module UserInterface