diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..04ed2aa37 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--require spec_helper +--order random diff --git a/Gemfile b/Gemfile index 12311d4e9..943ba1d95 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gemspec group :development do - gem 'mocha', '< 1.5' + gem 'mocha', '~> 3.1.0' gem 'rake', '~> 12.0' gem 'rexml', '~> 3.2.5' gem 'rspec', '~> 3.13' diff --git a/Gemfile.lock b/Gemfile.lock index d07ba857d..6baa3d142 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,11 +64,10 @@ GEM rb-inotify (>= 0.9) rb-kqueue (>= 0.2) logger (1.7.0) - metaclass (0.0.4) method_source (1.0.0) minitest (5.27.0) - mocha (1.4.0) - metaclass (~> 0.0.1) + mocha (3.1.0) + ruby2_keywords (>= 0.0.5) mutex_m (0.3.0) netrc (0.11.0) notify (0.5.2) @@ -122,6 +121,7 @@ GEM rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) securerandom (0.4.1) strscan (3.1.8) typhoeus (1.6.0) @@ -143,7 +143,7 @@ DEPENDENCIES awesome_print cocoapods-core! kicker - mocha (< 1.5) + mocha (~> 3.1.0) pry rake (~> 12.0) rb-fsevent diff --git a/spec/build_type_spec.rb b/spec/build_type_spec.rb index ad43f9150..aebdb7de3 100644 --- a/spec/build_type_spec.rb +++ b/spec/build_type_spec.rb @@ -4,55 +4,54 @@ module Pod describe BuildType do describe '#initialize' do it 'returns static library by default' do - BuildType.new.should == BuildType.static_library + expect(BuildType.new).to eq(BuildType.static_library) end it 'allows specifying linkage' do - BuildType.new(:linkage => :dynamic).should == BuildType.dynamic_library + expect(BuildType.new(:linkage => :dynamic)).to eq(BuildType.dynamic_library) end it 'allows specifying packaging' do - BuildType.new(:packaging => :framework).should == BuildType.static_framework + expect(BuildType.new(:packaging => :framework)).to eq(BuildType.static_framework) end it 'raises when given an unknown linkage' do - -> { BuildType.new(:linkage => :foo) }.should.raise(ArgumentError). - message.should.include? 'Invalid linkage option :foo, valid options are [:static, :dynamic]' + expect { BuildType.new(:linkage => :foo) }.to raise_error(ArgumentError, a_string_including('Invalid linkage option :foo, valid options are [:static, :dynamic]')) end end describe 'convenience factory methods' do it '#dynamic_library' do - BuildType.dynamic_library.should == BuildType.new(:linkage => :dynamic, :packaging => :library) + expect(BuildType.dynamic_library).to eq(BuildType.new(:linkage => :dynamic, :packaging => :library)) end it '#static_library' do - BuildType.static_library.should == BuildType.new(:linkage => :static, :packaging => :library) + expect(BuildType.static_library).to eq(BuildType.new(:linkage => :static, :packaging => :library)) end it '#dynamic_framework' do - BuildType.dynamic_framework.should == BuildType.new(:linkage => :dynamic, :packaging => :framework) + expect(BuildType.dynamic_framework).to eq(BuildType.new(:linkage => :dynamic, :packaging => :framework)) end it '#static_framework' do - BuildType.static_framework.should == BuildType.new(:linkage => :static, :packaging => :framework) + expect(BuildType.static_framework).to eq(BuildType.new(:linkage => :static, :packaging => :framework)) end end describe '#==' do it 'compares equal build types as equal' do - BuildType.new(:linkage => :dynamic, :packaging => :library).should == BuildType.new(:linkage => :dynamic, :packaging => :library) + expect(BuildType.new(:linkage => :dynamic, :packaging => :library)).to eq(BuildType.new(:linkage => :dynamic, :packaging => :library)) end it 'compares unequal build types as unequal' do - BuildType.new(:linkage => :dynamic, :packaging => :framework).should != BuildType.new(:linkage => :dynamic, :packaging => :library) - BuildType.new(:linkage => :static, :packaging => :library).should != BuildType.new(:linkage => :dynamic, :packaging => :library) + expect(BuildType.new(:linkage => :dynamic, :packaging => :framework)).not_to eq(BuildType.new(:linkage => :dynamic, :packaging => :library)) + expect(BuildType.new(:linkage => :static, :packaging => :library)).not_to eq(BuildType.new(:linkage => :dynamic, :packaging => :library)) end end describe '#to_s' do it 'returns a readable representation' do - BuildType.static_framework.to_s.should == 'static framework' + expect(BuildType.static_framework.to_s).to eq('static framework') end end end diff --git a/spec/cdn_source_spec.rb b/spec/cdn_source_spec.rb index de6a58f93..6f08373bb 100644 --- a/spec/cdn_source_spec.rb +++ b/spec/cdn_source_spec.rb @@ -89,35 +89,35 @@ def typhoeus_non_http_response_future(code) describe 'In general' do it 'return its name' do - @source.name.should == 'test_cdn_repo_local' + expect(@source.name).to eq('test_cdn_repo_local') end it 'return its type' do - @source.type.should == 'CDN' + expect(@source.type).to eq('CDN') end it 'works when the root URL has a trailing slash' do save_url('http://localhost:4321/') @source = CDNSource.new(@path) - @source.url.should == 'http://localhost:4321/' + expect(@source.url).to eq('http://localhost:4321/') end it 'works when the root URL has a trailing path' do save_url('http://localhost:4321/trail/ing/path/') @source = CDNSource.new(@path) - @source.url.should == 'http://localhost:4321/trail/ing/path/' + expect(@source.url).to eq('http://localhost:4321/trail/ing/path/') end it 'works when the root URL has no trailing slash' do save_url('http://localhost:4321') @source = CDNSource.new(@path) - @source.url.should == 'http://localhost:4321/' + expect(@source.url).to eq('http://localhost:4321/') end it 'works when the root URL file has a newline' do save_url("http://localhost:4321/\n") @source = CDNSource.new(@path) - @source.url.should == 'http://localhost:4321/' + expect(@source.url).to eq('http://localhost:4321/') end end @@ -125,13 +125,13 @@ def typhoeus_non_http_response_future(code) describe '#pods' do it 'returns the available Pods' do - @source.pods.should == %w(BeaconKit SDWebImage) + expect(@source.pods).to eq(%w(BeaconKit SDWebImage)) end it "raises if the repo doesn't exist" do path = fixture('spec-repos/non_existing') @source = CDNSource.new(path) - @source.metadata.should.be.nil? + expect(@source.metadata).to be_nil end end @@ -141,16 +141,16 @@ def typhoeus_non_http_response_future(code) extend SpecHelper::TemporaryDirectory it 'returns the available versions of a Pod' do - @source.versions('BeaconKit').map(&:to_s).should == %w(1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 1.0.0) + expect(@source.versions('BeaconKit').map(&:to_s)).to eq(%w(1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 1.0.0)) end it 'returns nil if the Pod could not be found' do - @source.versions('Unknown_Pod').should.be.nil + expect(@source.versions('Unknown_Pod')).to be_nil end it 'does not error when a Pod name need URI escaping' do - @source.versions('СерафимиМногоꙮчитїи').map(&:to_s).should == %w(1.0.0) - @source.specification('СерафимиМногоꙮчитїи', '1.0.0').name.should == 'СерафимиМногоꙮчитїи' + expect(@source.versions('СерафимиМногоꙮчитїи').map(&:to_s)).to eq(%w(1.0.0)) + expect(@source.specification('СерафимиМногоꙮчитїи', '1.0.0').name).to eq('СерафимиМногоꙮчитїи') end it 'uses netrc when provided' do @@ -166,8 +166,8 @@ def typhoeus_non_http_response_future(code) auth = req['Authorization'] res.body = '' end - @source.versions('Unknown_Pod').should.be.nil - auth.should == 'Basic dXNlcjE6eHh4' + expect(@source.versions('Unknown_Pod')).to be_nil + expect(auth).to eq('Basic dXNlcjE6eHh4') end it 'handles redirects' do @@ -187,7 +187,7 @@ def typhoeus_non_http_response_future(code) @source.expects(:debug).with { |cmd| cmd.include? "CDN: #{@source.name} Relative path downloaded: all_pods_versions_2_0_9.txt, save ETag:" } @source.expects(:debug).with("CDN: #{@source.name} Redirecting from #{original_url} to #{redirect_url}") @source.expects(:debug).with { |cmd| cmd.include? "CDN: #{@source.name} Relative path downloaded: Specs/2/0/9/BeaconKit/1.0.0/BeaconKit.podspec.json, save ETag:" } - @source.versions('BeaconKit').map(&:to_s).should == %w(1.0.0) + expect(@source.versions('BeaconKit').map(&:to_s)).to eq(%w(1.0.0)) end it 'handles responses with no headers' do @@ -197,9 +197,9 @@ def typhoeus_non_http_response_future(code) @source.expects(:download_typhoeus_impl_async). with_url('http://localhost:4321/Specs/2/0/9/BeaconKit/1.0.0/BeaconKit.podspec.json'). returns(typhoeus_http_response_future(200, nil, '{}')) - should.not.raise do + expect do @source.versions('BeaconKit') - end + end.not_to raise_error end it 'forces UTF-8 encoding for the body' do @@ -211,18 +211,17 @@ def typhoeus_non_http_response_future(code) @source.expects(:download_typhoeus_impl_async). with_url('http://localhost:4321/Specs/2/0/9/BeaconKit/1.0.0/BeaconKit.podspec.json'). returns(typhoeus_http_response_future(200, {}, mock_json_body)) - should.not.raise do + expect do @source.versions('BeaconKit') - end + end.not_to raise_error end it 'raises if unexpected HTTP error' do @source.expects(:download_typhoeus_impl_async). returns(typhoeus_http_response_future(500)) - should.raise Informative do + expect do @source.versions('BeaconKit') - end.message. - should.include "CDN: #{@source.name} URL couldn\'t be downloaded: #{@url}all_pods_versions_2_0_9.txt Response: 500" + end.to raise_error(Informative, a_string_including("CDN: #{@source.name} URL couldn\'t be downloaded: #{@url}all_pods_versions_2_0_9.txt Response: 500")) end it 'raises if unexpected non-HTTP error' do @@ -232,10 +231,12 @@ def typhoeus_non_http_response_future(code) @source.expects(:sleep_async).at_least_once.with(anything).returns(resolved_event) - should.raise Informative do + expect do @source.versions('BeaconKit') - end.message. - should.include "CDN: #{@source.name} URL couldn\'t be downloaded: #{@url}all_pods_versions_2_0_9.txt Response: Couldn't connect to server" + end.to raise_error( + Informative, + a_string_including("CDN: #{@source.name} URL couldn\'t be downloaded: #{@url}all_pods_versions_2_0_9.txt Response: Couldn't connect to server"), + ) end it 'retries after unexpected HTTP error' do @@ -256,7 +257,7 @@ def typhoeus_non_http_response_future(code) @source.expects(:sleep_async).with(seconds).returns(resolved_event) end - @source.versions('BeaconKit').map(&:to_s).should == %w(1.0.0) + expect(@source.versions('BeaconKit').map(&:to_s)).to eq(%w(1.0.0)) end it 'fails after unexpected HTTP error retries are exhausted' do @@ -273,9 +274,9 @@ def typhoeus_non_http_response_future(code) @source.expects(:sleep_async).with(seconds).returns(resolved_event) end - should.raise Informative do + expect do @source.versions('BeaconKit') - end.message.should.include "CDN: #{@source.name} URL couldn't be downloaded: http://localhost:4321/all_pods_versions_2_0_9.txt Response: 503" + end.to raise_error(Informative, a_string_including("CDN: #{@source.name} URL couldn't be downloaded: http://localhost:4321/all_pods_versions_2_0_9.txt Response: 503")) end it 'retries after unexpected non-HTTP error' do @@ -296,7 +297,7 @@ def typhoeus_non_http_response_future(code) @source.expects(:sleep_async).with(seconds).returns(resolved_event) end - @source.versions('BeaconKit').map(&:to_s).should == %w(1.0.0) + expect(@source.versions('BeaconKit').map(&:to_s)).to eq(%w(1.0.0)) end it 'fails after unexpected non-HTTP error retries are exhausted' do @@ -313,9 +314,12 @@ def typhoeus_non_http_response_future(code) @source.expects(:sleep_async).with(seconds).returns(resolved_event) end - should.raise Informative do + expect do @source.versions('BeaconKit') - end.message.should.include "CDN: #{@source.name} URL couldn't be downloaded: http://localhost:4321/all_pods_versions_2_0_9.txt Response: Couldn't connect to server" + end.to raise_error( + Informative, + a_string_including("CDN: #{@source.name} URL couldn't be downloaded: http://localhost:4321/all_pods_versions_2_0_9.txt Response: Couldn't connect to server"), + ) end it 'raises cumulative error when more than one Future rejects' do @@ -331,18 +335,18 @@ def typhoeus_non_http_response_future(code) "CDN: #{@source.name} URL couldn't be downloaded: #{@url}Specs/2/0/9/BeaconKit/1.0.#{index}/BeaconKit.podspec.json Response: 500 Some error" end - should.raise Informative do + expect do @source.versions('BeaconKit') - end.message.should.include "CDN: #{@source.name} Repo update failed - 6 error(s):\n" + messages.join("\n") + end.to raise_error(Informative, a_string_including("CDN: #{@source.name} Repo update failed - 6 error(s):\n" + messages.join("\n"))) end it 'returns cached versions for a Pod' do pod_path_children = %w(1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 1.0.0) - @source.versions('BeaconKit').map(&:to_s).should == pod_path_children + expect(@source.versions('BeaconKit').map(&:to_s)).to eq(pod_path_children) @source.expects(:download_file).never - @source.versions('BeaconKit').map(&:to_s).should == pod_path_children + expect(@source.versions('BeaconKit').map(&:to_s)).to eq(pod_path_children) pod_versions = pod_path_children.map { |v| Version.new(v) } - @source.instance_variable_get(:@versions_by_name).should == { 'BeaconKit' => pod_versions } + expect(@source.instance_variable_get(:@versions_by_name)).to eq({ 'BeaconKit' => pod_versions }) end end @@ -351,8 +355,8 @@ def typhoeus_non_http_response_future(code) describe '#specification' do it 'returns the specification for the given name and version' do spec = @source.specification('BeaconKit', Version.new('1.0.5')) - spec.name.should == 'BeaconKit' - spec.version.to_s.should == '1.0.5' + expect(spec.name).to eq('BeaconKit') + expect(spec.version.to_s).to eq('1.0.5') end it 'downloads specification again if file is not valid' do @@ -360,8 +364,8 @@ def typhoeus_non_http_response_future(code) FileUtils.mkdir_p(@path + 'Specs/2/0/9/BeaconKit/1.0.5') FileUtils.touch(@path + 'Specs/2/0/9/BeaconKit/1.0.5/BeaconKit.podspec.json') spec = @source.specification('BeaconKit', Version.new('1.0.5')) - spec.name.should == 'BeaconKit' - spec.version.to_s.should == '1.0.5' + expect(spec.name).to eq('BeaconKit') + expect(spec.version.to_s).to eq('1.0.5') end it 'does not attempt to access a version not in the version index' do @@ -370,9 +374,9 @@ def typhoeus_non_http_response_future(code) @source.expects(:download_file).never @source.expects(:local_file).never - should.raise StandardError do + expect do @source.specification('BeaconKit', Version.new('9.9.9')) - end.message.should.include 'Unable to find the specification BeaconKit (9.9.9) in the test_cdn_repo_local source.' + end.to raise_error(StandardError, a_string_including('Unable to find the specification BeaconKit (9.9.9) in the test_cdn_repo_local source.')) end end @@ -380,9 +384,9 @@ def typhoeus_non_http_response_future(code) describe '#all_specs' do it 'raises an error' do - should.raise Informative do + expect do @source.all_specs - end.message.should.match /Can't retrieve all the specs for a CDN-backed source, it will take forever/ + end.to raise_error(Informative, /Can't retrieve all the specs for a CDN-backed source, it will take forever/) end end @@ -391,8 +395,8 @@ def typhoeus_non_http_response_future(code) describe '#set' do it 'returns the set of a given Pod' do set = @source.set('BeaconKit') - set.name.should == 'BeaconKit' - set.sources.should == [@source] + expect(set.name).to eq('BeaconKit') + expect(set.sources).to eq([@source]) end end @@ -400,9 +404,9 @@ def typhoeus_non_http_response_future(code) describe '#pod_sets' do it 'raises an error' do - should.raise Informative do + expect do @source.pod_sets - end.message.should.match /Can't retrieve all the pod sets for a CDN-backed source, it will take forever/ + end.to raise_error(Informative, /Can't retrieve all the pod sets for a CDN-backed source, it will take forever/) end end @@ -410,37 +414,37 @@ def typhoeus_non_http_response_future(code) describe '#search' do it 'searches for the Pod with the given name' do - @source.search('BeaconKit').name.should == 'BeaconKit' + expect(@source.search('BeaconKit').name).to eq('BeaconKit') end it 'searches for the pod with the given dependency' do dep = Dependency.new('BeaconKit') - @source.search(dep).name.should == 'BeaconKit' + expect(@source.search(dep).name).to eq('BeaconKit') end it 'supports dependencies on subspecs' do dep = Dependency.new('SDWebImage/MapKit') - @source.search(dep).name.should == 'SDWebImage' + expect(@source.search(dep).name).to eq('SDWebImage') end it 'matches case' do @source.expects(:debug).with { |cmd| cmd =~ /CDN: #{@source.name} Relative path: all_pods_versions_9_5_b\.txt not available in this source set/ } @source.expects(:debug).with { |cmd| cmd =~ /CDN: #{@source.name} Relative path downloaded: all_pods_versions_9_5_b\.txt, save ETag:/ } - @source.search('bEacoNKIT').should.be.nil? + expect(@source.search('bEacoNKIT')).to be_nil end describe '#search_by_name' do it 'properly configures the sources of a set in search by name' do sets = @source.search_by_name('beacon') - sets.count.should == 1 + expect(sets.count).to eq(1) set = sets.first - set.name.should == 'BeaconKit' - set.sources.map(&:name).should == %w(test_cdn_repo_local) + expect(set.name).to eq('BeaconKit') + expect(set.sources.map(&:name)).to eq(%w(test_cdn_repo_local)) end it 'can use regular expressions' do sets = @source.search_by_name('be{0,1}acon') - sets.first.name.should == 'BeaconKit' + expect(sets.first.name).to eq('BeaconKit') end end end @@ -456,7 +460,7 @@ def typhoeus_non_http_response_future(code) @source.search('BeaconKit') Algolia::Index.any_instance.stubs(:search).with('beacon', :attributesToRetrieve => 'name').returns('hits' => [{ 'name' => 'BeaconKit' }]) sets = @source.search_by_name('beacon', true) - sets.first.name.should == 'BeaconKit' + expect(sets.first.name).to eq('BeaconKit') end it 'configures full-text search with Algolia from CDN file' do @@ -464,14 +468,14 @@ def typhoeus_non_http_response_future(code) @source.expects(:download_file).with('AlgoliaSearch.yml').returns('AlgoliaSearch.yml') Algolia::Index.any_instance.stubs(:search).with('beacon', :attributesToRetrieve => 'name').returns('hits' => [{ 'name' => 'BeaconKit' }]) sets = @source.search_by_name('beacon', true) - sets.first.name.should == 'BeaconKit' + expect(sets.first.name).to eq('BeaconKit') end it 'does not perform any heavy CDN operations if nothing was found' do + @source.expects(:download_file).never @source.expects(:download_file).with('AlgoliaSearch.yml').returns('AlgoliaSearch.yml') Algolia::Index.any_instance.stubs(:search).with('beacon', :attributesToRetrieve => 'name').returns('hits' => []) - @source.expects(:download_file).never - @source.search_by_name('beacon', true).should == [] + expect(@source.search_by_name('beacon', true)).to eq([]) end end @@ -479,23 +483,23 @@ def typhoeus_non_http_response_future(code) describe '#fuzzy_search' do it 'is case insensitive' do - @source.fuzzy_search('beaconkit').name.should == 'BeaconKit' + expect(@source.fuzzy_search('beaconkit').name).to eq('BeaconKit') end it 'matches misspells' do - @source.fuzzy_search('baconkit').name.should == 'BeaconKit' + expect(@source.fuzzy_search('baconkit').name).to eq('BeaconKit') end it 'matches suffixes' do - @source.fuzzy_search('Kit').name.should == 'BeaconKit' + expect(@source.fuzzy_search('Kit').name).to eq('BeaconKit') end it 'returns nil if there is no match' do - @source.fuzzy_search('12345').should.be.nil + expect(@source.fuzzy_search('12345')).to be_nil end it 'matches abbreviations' do - @source.fuzzy_search('BKit').name.should == 'BeaconKit' + expect(@source.fuzzy_search('BKit').name).to eq('BeaconKit') end end @@ -506,7 +510,7 @@ def typhoeus_non_http_response_future(code) File.open(@path.join('deprecated_podspecs.txt'), 'w') { |f| } CDNSource.any_instance.expects(:download_file).with('deprecated_podspecs.txt').returns('deprecated_podspecs.txt') CDNSource.any_instance.expects(:download_file_async).with('CocoaPods-version.yml').returns(fulfilled_future('CocoaPods-version.yml')) - @source.update(true).should == [] + expect(@source.update(true)).to eq([]) end end @@ -514,15 +518,15 @@ def typhoeus_non_http_response_future(code) describe 'Representations' do it 'does not support hash representation' do - should.raise Informative do + expect do @source.to_hash - end.message.should.match /Can't retrieve all the specs for a CDN-backed source, it will take forever/ + end.to raise_error(Informative, /Can't retrieve all the specs for a CDN-backed source, it will take forever/) end it 'does not support yaml representation' do - should.raise Informative do + expect do @source.to_yaml - end.message.should.match /Can't retrieve all the specs for a CDN-backed source, it will take forever/ + end.to raise_error(Informative, /Can't retrieve all the specs for a CDN-backed source, it will take forever/) end end @@ -530,7 +534,7 @@ def typhoeus_non_http_response_future(code) describe '#specification_path' do it 'returns the path of a specification' do path = @source.specification_path('BeaconKit', '1.0.5') - path.to_s.should.end_with?('Specs/2/0/9/BeaconKit/1.0.5/BeaconKit.podspec.json') + expect(path.to_s).to end_with('Specs/2/0/9/BeaconKit/1.0.5/BeaconKit.podspec.json') end end end diff --git a/spec/dependency_spec.rb b/spec/dependency_spec.rb index 4e17b9ac5..40fc6453b 100644 --- a/spec/dependency_spec.rb +++ b/spec/dependency_spec.rb @@ -5,147 +5,147 @@ module Pod describe 'In general' do it 'can be initialized with no requirements' do dependency = Dependency.new('bananas') - dependency.name.should == 'bananas' + expect(dependency.name).to eq('bananas') end it 'can be initialized with multiple requirements' do dependency = Dependency.new('bananas', '> 1.0', '< 2.0') - dependency.requirement.to_s.should == '< 2.0, > 1.0' + expect(dependency.requirement.to_s).to eq('< 2.0, > 1.0') end it 'can be initialized with a requirement on a pre-release version' do dependency = Dependency.new('bananas', '> 1.0-pre') - dependency.requirement.to_s.should == '> 1.0-pre' + expect(dependency.requirement.to_s).to eq('> 1.0-pre') end it 'can be initialized with multiple requirements and a podspec source' do dependency = Dependency.new('bananas', '> 1.0', '< 2.0', :source => 'https://github.com/CocoaPods/CocoaPods.git') - dependency.requirement.to_s.should == '< 2.0, > 1.0' - dependency.podspec_repo.should == 'https://github.com/CocoaPods/CocoaPods.git' + expect(dependency.requirement.to_s).to eq('< 2.0, > 1.0') + expect(dependency.podspec_repo).to eq('https://github.com/CocoaPods/CocoaPods.git') end it 'can be initialized with a requirement on a pre-release version and a podspec source' do dependency = Dependency.new('bananas', '> 1.0-pre', :source => 'https://github.com/CocoaPods/CocoaPods.git') - dependency.requirement.to_s.should == '> 1.0-pre' - dependency.podspec_repo.should == 'https://github.com/CocoaPods/CocoaPods.git' + expect(dependency.requirement.to_s).to eq('> 1.0-pre') + expect(dependency.podspec_repo).to eq('https://github.com/CocoaPods/CocoaPods.git') end it 'can be initialized with an external source' do dep = Dependency.new('cocoapods', :git => 'git://github.com/cocoapods/cocoapods') - dep.should.be.external + expect(dep).to be_external end it 'can be initialized with an empty external source and not be considered external' do dep = Dependency.new('cocoapods', :git => nil) - dep.should.not.be.external + expect(dep).not_to be_external end it 'knows if it is local' do dep = Dependency.new('cocoapods', :path => '/tmp/cocoapods') - dep.should.be.local + expect(dep).to be_local end it "says it isn't local if nothing was passed in" do dep = Dependency.new('cocoapods') - dep.should.not.be.local + expect(dep).not_to be_local end it 'raises if initialized with an external source and requirements are provided' do - should.raise Informative do + expect do Dependency.new('cocoapods', '1.0', :git => 'git://github.com/cocoapods/cocoapods') - end + end.to raise_error(Informative) end describe '#from_string' do it 'creates a dependency from a string' do d = Dependency.from_string('BananaLib (1.0)') - d.name.should == 'BananaLib' - d.requirement.should =~ Version.new('1.0') - d.external_source.should.be.nil + expect(d.name).to eq('BananaLib') + expect(d.requirement).to be_satisfied_by(Version.new('1.0')) + expect(d.external_source).to be_nil end it 'creates a dependency from a string with multiple version requirements' do d = Dependency.from_string('FontAwesomeIconFactory (< 2.0, >= 1.0.1)') - d.name.should == 'FontAwesomeIconFactory' - d.requirement.should == Requirement.new('< 2.0', '>= 1.0.1') + expect(d.name).to eq('FontAwesomeIconFactory') + expect(d.requirement).to eq(Requirement.new('< 2.0', '>= 1.0.1')) end it "doesn't include external source when initialized from a string as incomplete and thus it should be provided by the client" do d = Dependency.from_string("BananaLib (from `www.example.com', tag `1.0')") - d.name.should == 'BananaLib' - d.requirement.should.be.none? - d.external?.should.be.false + expect(d.name).to eq('BananaLib') + expect(d.requirement).to be_none + expect(d.external?).to be(false) end it 'handles strings with no requirements' do d = Dependency.from_string('AFNetworking') - d.name.should == 'AFNetworking' - d.requirement.should.be.none? + expect(d.name).to eq('AFNetworking') + expect(d.requirement).to be_none end it 'handles names with a space' do d = Dependency.from_string('RestKit/Subspec JSON (= 1.0)') - d.name.should == 'RestKit/Subspec JSON' - d.requirement.should == Requirement.new('= 1.0') + expect(d.name).to eq('RestKit/Subspec JSON') + expect(d.requirement).to eq(Requirement.new('= 1.0')) end it 'handles names with a space and external source' do d = Dependency.from_string("RestKit/Subspec JSON (from `www.example.com', tag `1.0')") - d.requirement.should.be.none? - d.external?.should.be.false + expect(d.requirement).to be_none + expect(d.external?).to be(false) end it 'handles names with a space and no requirements' do d = Dependency.from_string('RestKit/Subspec JSON') - d.name.should == 'RestKit/Subspec JSON' - d.requirement.should.be.none? + expect(d.name).to eq('RestKit/Subspec JSON') + expect(d.requirement).to be_none end end it 'includes the external sources in the string representation' do dependency = Dependency.new('cocoapods', :hg => 'example.com') - dependency.to_s.should == 'cocoapods (from `example.com`)' + expect(dependency.to_s).to eq('cocoapods (from `example.com`)') end it 'raises if version requirements are specified for an external source' do - should.raise Pod::Informative do + expect do Dependency.new('cocoapods', '1.2.3', :git => 'example.com') - end + end.to raise_error(Pod::Informative) end it 'raises if an invalid initialization flag is given' do - should.raise ArgumentError do + expect do Dependency.new('cocoapods', :foot) - end + end.to raise_error(ArgumentError) end it 'can store a specific version which is used in place of the requirements' do dependency = Dependency.new('cocoapods', '> 1.0') dependency.specific_version = Version.new('1.23') - dependency.requirement.as_list.should == ['= 1.23'] + expect(dependency.requirement.as_list).to eq(['= 1.23']) end #--------------------------------------# it 'preserves the external source on duplication' do dep = Dependency.new('bananas', :podspec => 'bananas') - dep.dup.external_source.should == { :podspec => 'bananas' } + expect(dep.dup.external_source).to eq({ :podspec => 'bananas' }) end #--------------------------------------# it 'returns the name of the dependency, or the name of the pod of which this is a subspec' do dep = Dependency.new('RestKit') - dep.root_name.should == 'RestKit' + expect(dep.root_name).to eq('RestKit') dep = Dependency.new('RestKit/Networking') - dep.root_name.should == 'RestKit' + expect(dep.root_name).to eq('RestKit') end it 'returns a copy of the dependency but for the top level spec, if it is a subspec' do dep = Dependency.new('RestKit', '>= 1.2.3') - dep.to_root_dependency.should == Dependency.new('RestKit', '>= 1.2.3') + expect(dep.to_root_dependency).to eq(Dependency.new('RestKit', '>= 1.2.3')) dep = Dependency.new('RestKit/Networking', '>= 1.2.3') - dep.to_root_dependency.should == Dependency.new('RestKit', '>= 1.2.3') + expect(dep.to_root_dependency).to eq(Dependency.new('RestKit', '>= 1.2.3')) end #--------------------------------------# @@ -153,19 +153,19 @@ module Pod it 'returns whether it is compatible with another dependency' do dep1 = Dependency.new('bananas', '>= 1.8') dep2 = Dependency.new('bananas', '1.9') - dep1.compatible?(dep2).should.be.true + expect(dep1.compatible?(dep2)).to be(true) end it 'is not compatible with another dependency with non satisfied version requirements' do dep1 = Dependency.new('bananas', '> 1.9') dep2 = Dependency.new('bananas', '1.9') - dep1.compatible?(dep2).should.be.false + expect(dep1.compatible?(dep2)).to be(false) end it 'is not compatible with another if the external sources differ' do dep1 = Dependency.new('bananas', :podspec => 'bananas') dep2 = Dependency.new('bananas', '1.9') - dep1.compatible?(dep2).should.be.false + expect(dep1.compatible?(dep2)).to be(false) end #--------------------------------------# @@ -173,32 +173,32 @@ module Pod it 'is equal to another dependency if `external_source` is the same' do dep1 = Dependency.new('bananas', :git => 'GIT-URL') dep2 = Dependency.new('bananas') - dep1.should.not == dep2 + expect(dep1).not_to eq(dep2) dep3 = Dependency.new('bananas', :git => 'GIT-URL') - dep1.should == dep3 + expect(dep1).to eq(dep3) end it 'is equal to another dependency if `podspec_repo` is the same' do dep1 = Dependency.new('bananas', :source => 'GIT-URL') dep2 = Dependency.new('bananas') - dep1.should.not == dep2 + expect(dep1).not_to eq(dep2) dep3 = Dependency.new('bananas', :source => 'GIT-URL') - dep1.should == dep3 + expect(dep1).to eq(dep3) end it 'supports Array#uniq' do d_1 = Dependency.new('bananas') d_2 = Dependency.new('bananas') - [d_1, d_2].uniq.should == [d_1] + expect([d_1, d_2].uniq).to eq([d_1]) end #--------------------------------------# it 'is able to match against proper SemVer pre-release versions' do dep = Dependency.new('bananas', '< 2.0.0') - should.not.raise do + expect do dep.match?('bananas', '2.0.0-rc1') - end + end.not_to raise_error end #--------------------------------------# @@ -206,7 +206,7 @@ module Pod it 'merges with another dependency' do dep1 = Dependency.new('bananas', '>= 1.8') dep2 = Dependency.new('bananas', '1.9') - dep1.merge(dep2).should == Dependency.new('bananas', '>= 1.8', '1.9') + expect(dep1.merge(dep2)).to eq(Dependency.new('bananas', '>= 1.8', '1.9')) end it 'it preserves the external source while merging with another dependency' do @@ -214,20 +214,20 @@ module Pod dep2 = Dependency.new('bananas', :podspec => 'bananas') result = dep1.merge(dep2) - result.should.be.external - result.requirement.as_list.should == ['= 1.9'] + expect(result).to be_external + expect(result.requirement.as_list).to eq(['= 1.9']) result = dep2.merge(dep1) - result.should.be.external - result.requirement.as_list.should == ['= 1.9'] + expect(result).to be_external + expect(result.requirement.as_list).to eq(['= 1.9']) end it 'raises if there is an attempt to merge with a dependency with a different name' do - should.raise ArgumentError do + expect do dep1 = Dependency.new('bananas', '>= 1.8') dep2 = Dependency.new('orange', '1.9') dep1.merge(dep2) - end + end.to raise_error(ArgumentError) end it 'preserves the podspec repo while merging' do @@ -235,17 +235,17 @@ module Pod dep2 = Dependency.new('bananas', :source => 'https://source.git') expected = Dependency.new('bananas', '~> 1.9', :source => 'https://source.git') - dep1.merge(dep2).should == expected - dep2.merge(dep1).should == expected + expect(dep1.merge(dep2)).to eq(expected) + expect(dep2.merge(dep1)).to eq(expected) end it 'raises if there is an attempt to merge with two different podspec repos' do - should.raise ArgumentError do + expect do dep1 = Dependency.new('bananas', :source => 'https://other.git') dep2 = Dependency.new('bananas', :source => 'https://source.git') dep1.merge(dep2) - end + end.to raise_error(ArgumentError) end it 'allows merging if both dependencies have the same podspec repo' do @@ -253,76 +253,76 @@ module Pod dep2 = Dependency.new('bananas', :source => 'https://source.git') expected = Dependency.new('bananas', '~> 1.9', :source => 'https://source.git') - dep1.merge(dep2).should == expected - dep2.merge(dep1).should == expected + expect(dep1.merge(dep2)).to eq(expected) + expect(dep2.merge(dep1)).to eq(expected) end it 'raises when attempting to merge with a podspec repo and external source' do - should.raise Informative do + expect do dep1 = Dependency.new('bananas', :git => 'https://other.git') dep2 = Dependency.new('bananas', :source => 'https://source.git') dep1.merge(dep2) - end + end.to raise_error(Informative) end it 'prefers the right hand side when external source keys overlap' do dep1 = Dependency.new('bananas', :git => 'https://other.git') dep2 = Dependency.new('bananas', :git => 'https://other/1.git') - dep1.merge(dep2).should == Dependency.new('bananas', :git => 'https://other/1.git') - dep2.merge(dep1).should == Dependency.new('bananas', :git => 'https://other.git') + expect(dep1.merge(dep2)).to eq(Dependency.new('bananas', :git => 'https://other/1.git')) + expect(dep2.merge(dep1)).to eq(Dependency.new('bananas', :git => 'https://other.git')) end #--------------------------------------# it 'returns whether a dependency has pre-release requirements' do - Dependency.new('A').should.not.be.prerelease - Dependency.new('A', '1.0').should.not.be.prerelease - Dependency.new('A', '1.0', '< 3').should.not.be.prerelease + expect(Dependency.new('A')).not_to be_prerelease + expect(Dependency.new('A', '1.0')).not_to be_prerelease + expect(Dependency.new('A', '1.0', '< 3')).not_to be_prerelease - Dependency.new('A', '1.beta').should.be.prerelease - Dependency.new('A', '~> 1.0.0.beta').should.be.prerelease - Dependency.new('A', '~> 2', '< 1.0.0.beta').should.be.prerelease + expect(Dependency.new('A', '1.beta')).to be_prerelease + expect(Dependency.new('A', '~> 1.0.0.beta')).to be_prerelease + expect(Dependency.new('A', '~> 2', '< 1.0.0.beta')).to be_prerelease end #--------------------------------------# it 'matches a specification with the correct name' do dep = Dependency.new('bananas', '1.0') - dep.should.match?('bananas', '1.0') - dep.should.match?('bananas', '1') - dep.should.match?('bananas', '1.0.0') - dep.should.not.match?('orange', '1.0') + expect(dep.match?('bananas', '1.0')).to be_truthy + expect(dep.match?('bananas', '1')).to be_truthy + expect(dep.match?('bananas', '1.0.0')).to be_truthy + expect(dep.match?('orange', '1.0')).to be_falsey end it 'matches any version if no requirements are provided' do dep = Dependency.new('bananas') - dep.should.match?('bananas', '1.0') + expect(dep.match?('bananas', '1.0')).to be_truthy end it 'matches a specification with the correct version if requirements are provided' do dep = Dependency.new('bananas', '> 0.5') - dep.should.match?('bananas', '1.0') - dep.should.match?('bananas', '1.0.0') - dep.should.not.match?('bananas', '0.1') + expect(dep.match?('bananas', '1.0')).to be_truthy + expect(dep.match?('bananas', '1.0.0')).to be_truthy + expect(dep.match?('bananas', '0.1')).to be_falsey end it 'matches a specification regardless of version specificity' do dep = Dependency.new('bananas', '~> 1.0.0') - dep.should.match?('bananas', '1.0') - dep.should.match?('bananas', '1') - dep.should.match?('bananas', '1.0.0.0') + expect(dep.match?('bananas', '1.0')).to be_truthy + expect(dep.match?('bananas', '1')).to be_truthy + expect(dep.match?('bananas', '1.0.0.0')).to be_truthy dep = Dependency.new('bananas', '~> 1.0.0-a') - dep.should.match?('bananas', '1.0.0.0-a') - dep.should.match?('bananas', '1.0.0-a') - dep.should.match?('bananas', '1.0-a') + expect(dep.match?('bananas', '1.0.0.0-a')).to be_truthy + expect(dep.match?('bananas', '1.0.0-a')).to be_truthy + expect(dep.match?('bananas', '1.0-a')).to be_truthy end it 'matching supports the comparison with pre-release version' do dep = Dependency.new('bananas', '> 0.5') - dep.match?('bananas', '1.0-rc1').should.be.true + expect(dep.match?('bananas', '1.0-rc1')).to be(true) end end @@ -342,15 +342,15 @@ module Pod :tag => '1.0.0', } description = @dep.send(:external_source_description, source) - description.should == 'from `example.com/repo.git`, commit `SHA`, branch `master`, tag `1.0.0`' + expect(description).to eq('from `example.com/repo.git`, commit `SHA`, branch `master`, tag `1.0.0`') end it 'returns the description of other sources' do - @dep.send(:external_source_description, :hg => 'example.com').should == 'from `example.com`' - @dep.send(:external_source_description, :svn => 'example.com').should == 'from `example.com`' - @dep.send(:external_source_description, :podspec => 'example.com').should == 'from `example.com`' - @dep.send(:external_source_description, :path => 'example.com').should == 'from `example.com`' - @dep.send(:external_source_description, :other => 'example.com').should.match /from.*example.com/ + expect(@dep.send(:external_source_description, :hg => 'example.com')).to eq('from `example.com`') + expect(@dep.send(:external_source_description, :svn => 'example.com')).to eq('from `example.com`') + expect(@dep.send(:external_source_description, :podspec => 'example.com')).to eq('from `example.com`') + expect(@dep.send(:external_source_description, :path => 'example.com')).to eq('from `example.com`') + expect(@dep.send(:external_source_description, :other => 'example.com')).to match(/from.*example.com/) end end end diff --git a/spec/github_spec.rb b/spec/github_spec.rb index 5387bad00..52f7983d8 100644 --- a/spec/github_spec.rb +++ b/spec/github_spec.rb @@ -6,66 +6,66 @@ module Pod it 'returns the information of a user' do VCR.use_cassette('GitHub', :record => :new_episodes) do user = GitHub.user('CocoaPods') - user['login'].should == 'CocoaPods' + expect(user['login']).to eq('CocoaPods') end end it 'returns the information of a repo' do VCR.use_cassette('GitHub', :record => :new_episodes) do repo = GitHub.repo('https://github.com/CocoaPods/CocoaPods') - repo['name'].should == 'CocoaPods' + expect(repo['name']).to eq('CocoaPods') end end it 'handles SSH as well as HTTP' do VCR.use_cassette('GitHub', :record => :new_episodes) do repo = GitHub.repo('git@github.com:CocoaPods/CocoaPods') - repo['name'].should == 'CocoaPods' + expect(repo['name']).to eq('CocoaPods') end end it 'strips any trailing .git suffix' do VCR.use_cassette('GitHub', :record => :new_episodes) do repo = GitHub.repo('git@github.com:CocoaPods/CocoaPods.git') - repo['name'].should == 'CocoaPods' + expect(repo['name']).to eq('CocoaPods') end end it 'returns the information of a repo with dots in the name' do VCR.use_cassette('GitHub', :record => :new_episodes) do repo = GitHub.repo('https://github.com/contentful/contentful.objc') - repo['name'].should == 'contentful.objc' + expect(repo['name']).to eq('contentful.objc') end end it 'returns the tags of a repo' do VCR.use_cassette('GitHub', :record => :new_episodes) do tags = GitHub.tags('https://github.com/CocoaPods/CocoaPods') - tags.find { |t| t['name'] == '0.20.2' }.should.not.be.nil + expect(tags.find { |t| t['name'] == '0.20.2' }).not_to be_nil end end it 'returns the branches of a repo' do VCR.use_cassette('GitHub', :record => :new_episodes) do branches = GitHub.branches('https://github.com/CocoaPods/CocoaPods') - branches.find { |t| t['name'] == 'master' }.should.not.be.nil + expect(branches.find { |t| t['name'] == 'master' }).not_to be_nil end end it 'returns the contents of a repo' do VCR.use_cassette('GitHub', :record => :new_episodes) do contents = GitHub.contents('https://github.com/CocoaPods/CocoaPods') - contents.find { |t| t['name'] == 'README.md' }.should.not.be.nil + expect(contents.find { |t| t['name'] == 'README.md' }).not_to be_nil end end it 'returns the modified state of a repo' do VCR.use_cassette('GitHub', :record => :new_episodes) do old_commit_updated = GitHub.modified_since_commit('https://github.com/CocoaPods/CocoaPods', '6a0ba68e4f0c0229b46f311687cfc81209efd5b9') - old_commit_updated.should.be.true + expect(old_commit_updated).to be(true) latest_commit_updated = GitHub.modified_since_commit('https://github.com/CocoaPods/CocoaPods', '436c0e2f71bd2c129ef607a40d57068e6f31ceb7') - latest_commit_updated.should.be.false + expect(latest_commit_updated).to be(false) end end end @@ -86,29 +86,29 @@ module Pod it 'supports URLs with the `http` protocol' do VCR.use_cassette('GitHub', :record => :new_episodes) do repo = GitHub.repo('http://github.com/CocoaPods/CocoaPods') - repo['name'].should == 'CocoaPods' + expect(repo['name']).to eq('CocoaPods') end end it 'supports the GitHub identifier instead of the URL' do VCR.use_cassette('GitHub', :record => :new_episodes) do repo = GitHub.repo('CocoaPods/CocoaPods') - repo['name'].should == 'CocoaPods' + expect(repo['name']).to eq('CocoaPods') end end it 'returns nil if a requests fails' do VCR.use_cassette('GitHub', :record => :new_episodes) do repo = GitHub.repo('https://github.com/CocoaPods/Missing_Repo') - repo.should.be.nil + expect(repo).to be_nil end end it 'prints a warning for failed requests' do VCR.use_cassette('GitHub', :record => :new_episodes) do GitHub.repo('https://github.com/CocoaPods/Missing_Repo') - CoreUI.warnings.should.match /Request to https:.*Missing_Repo failed - 404/ - CoreUI.warnings.should.match /Not Found/ + expect(CoreUI.warnings).to match(/Request to https:.*Missing_Repo failed - 404/) + expect(CoreUI.warnings).to match(/Not Found/) end end diff --git a/spec/http_spec.rb b/spec/http_spec.rb index 1bace1572..d0eb80633 100644 --- a/spec/http_spec.rb +++ b/spec/http_spec.rb @@ -13,7 +13,7 @@ module Pod WebMock::API.stub_request(:head, /new-url/).to_return(:status => 200) resolved_url = HTTP.get_actual_url('http://SOME-URL/redirect/') - resolved_url.should == 'http://NEW-URL/' + expect(resolved_url).to eq('http://NEW-URL/') end it 'can resolve relative redirects' do @@ -22,14 +22,14 @@ module Pod WebMock::API.stub_request(:head, /foo/).to_return(:status => 200) resolved_url = HTTP.get_actual_url('http://SOME-URL/redirect') - resolved_url.should == 'http://SOME-URL/foo' + expect(resolved_url).to eq('http://SOME-URL/foo') end it 'can successfully validate URLs' do WebMock::API.stub_request(:head, /foo/).to_return(:status => 200) response = HTTP.validate_url('http://SOME-URL/foo') - response.success?.should.be.true + expect(response.success?).to be(true) end it 'is resilient to HEAD errors' do @@ -37,7 +37,7 @@ module Pod WebMock::API.stub_request(:get, /foo/).to_return(:status => 200) response = HTTP.validate_url('http://SOME-URL/foo') - response.success?.should.be.true + expect(response.success?).to be(true) end it 'reports failures when validating URLs' do @@ -45,12 +45,12 @@ module Pod WebMock::API.stub_request(:get, /foo/).to_return(:status => 404) response = HTTP.validate_url('http://SOME-URL/foo') - response.success?.should.be.false + expect(response.success?).to be(false) end it 'is resilient against exceptions during validation of URLs' do response = HTTP.validate_url('%&/(foo)') - response.should.be.nil + expect(response).to be_nil end it 'uses a browser user-agent to validate URLs' do @@ -60,7 +60,7 @@ module Pod to_return(:status => 200, :body => '') response = HTTP.validate_url('http://SOME-URL/foo') - response.success?.should.be.true + expect(response.success?).to be(true) end it 'uses GET with Range of 1 byte' do @@ -70,7 +70,7 @@ module Pod to_return(:status => 200, :body => ' ') response = HTTP.validate_url('http://SOME-URL/foo') - response.success?.should.be.true + expect(response.success?).to be(true) end it 'uses GET without Range if server rejects Range' do @@ -83,18 +83,18 @@ module Pod to_return(:status => 200, :body => '') response = HTTP.validate_url('http://SOME-URL/foo') - response.success?.should.be.true + expect(response.success?).to be(true) end it 'returns nil for URLs that are not HTTP URLs' do - HTTP.validate_url('ftp://example.com/foo').should.be.nil - HTTP.validate_url('mailto:pods@example.com').should.be.nil + expect(HTTP.validate_url('ftp://example.com/foo')).to be_nil + expect(HTTP.validate_url('mailto:pods@example.com')).to be_nil end it 'returns nil when a network error occurs during validation' do WebMock::API.stub_request(:head, /foo/).to_raise(OpenSSL::SSL::SSLError) - HTTP.validate_url('https://SOME-URL/foo').should.be.nil + expect(HTTP.validate_url('https://SOME-URL/foo')).to be_nil end end @@ -126,10 +126,9 @@ module Pod WebMock.disable! begin url = "https://127.0.0.1:#{tcp_server.addr[1]}/" - exception = should.raise(OpenSSL::SSL::SSLError) do + expect do HTTP.perform(:get, url) - end - exception.message.should.include 'certificate verify failed' + end.to raise_error(OpenSSL::SSL::SSLError, a_string_including('certificate verify failed')) ensure WebMock.enable! thread.kill @@ -146,9 +145,9 @@ module Pod raises(SocketError) begin - should.raise(SocketError) do + expect do HTTP.perform(:get, 'https://example.com/') - end + end.to raise_error(SocketError) ensure proxy_env.each { |k, v| v ? ENV[k] = v : ENV.delete(k) } end diff --git a/spec/lockfile_spec.rb b/spec/lockfile_spec.rb index 00036fe9b..bfd851324 100644 --- a/spec/lockfile_spec.rb +++ b/spec/lockfile_spec.rb @@ -128,31 +128,31 @@ def self.specs_by_source it 'stores the initialization hash' do lockfile = Lockfile.new(YAMLHelper.load_string(Sample.yaml)) - lockfile.internal_data.should == YAMLHelper.load_string(Sample.yaml) + expect(lockfile.internal_data).to eq(YAMLHelper.load_string(Sample.yaml)) end it 'loads from a file' do File.open(@tmp_path, 'w') { |f| f.write(Sample.yaml) } lockfile = Lockfile.from_file(@tmp_path) - lockfile.internal_data.should == YAMLHelper.load_string(Sample.yaml) + expect(lockfile.internal_data).to eq(YAMLHelper.load_string(Sample.yaml)) end it "returns nil if it can't find the initialization file" do lockfile = Lockfile.from_file(temporary_directory + 'Podfile.lock_not_existing') - lockfile.should.nil? + expect(lockfile).to be_nil end it 'returns the file in which is defined' do File.open(@tmp_path, 'w') { |f| f.write(Sample.yaml) } lockfile = Lockfile.from_file(@tmp_path) - lockfile.defined_in_file.should == @tmp_path + expect(lockfile.defined_in_file).to eq(@tmp_path) end it "raises if the provided YAML doesn't returns a hash" do File.open(@tmp_path, 'w') { |f| f.write('value') } - should.raise Informative do + expect do Lockfile.from_file(@tmp_path) - end.message.should.match /Invalid Lockfile/ + end.to raise_error(Informative, /Invalid Lockfile/) end #--------------------------------------# @@ -166,54 +166,54 @@ def self.specs_by_source platform :ios pod 'BananaLib', '~>1.0' end - @lockfile.should == @lockfile - @lockfile.should.not == Lockfile.generate(podfile, Sample.specs, Sample.checkout_options, Sample.specs_by_source) + expect(@lockfile).to eq(@lockfile) + expect(@lockfile).not_to eq(Lockfile.generate(podfile, Sample.specs, Sample.checkout_options, Sample.specs_by_source)) end it 'returns the list of the names of the installed pods' do - @lockfile.pod_names.should == %w(BananaLib JSONKit monkey) + expect(@lockfile.pod_names).to eq(%w(BananaLib JSONKit monkey)) end it 'returns the versions of a given pod' do - @lockfile.version('BananaLib').should == Version.new('1.0') - @lockfile.version('JSONKit').should == Version.new('1.4') - @lockfile.version('monkey').should == Version.new('1.0.8') + expect(@lockfile.version('BananaLib')).to eq(Version.new('1.0')) + expect(@lockfile.version('JSONKit')).to eq(Version.new('1.4')) + expect(@lockfile.version('monkey')).to eq(Version.new('1.0.8')) end it 'returns the versions of a given pod handling the case in which the root spec was not stored' do @lockfile.stubs(:pod_versions).returns('BananaLib/Subspec' => Version.new(1.0)) - @lockfile.version('BananaLib').should == Version.new('1.0') + expect(@lockfile.version('BananaLib')).to eq(Version.new('1.0')) end it 'returns the spec repo of a given pod' do - @lockfile.spec_repo('BananaLib').should == 'trunk' - @lockfile.spec_repo('JSONKit').should.be.nil - @lockfile.spec_repo('monkey').should == 'trunk' + expect(@lockfile.spec_repo('BananaLib')).to eq('trunk') + expect(@lockfile.spec_repo('JSONKit')).to be_nil + expect(@lockfile.spec_repo('monkey')).to eq('trunk') end it 'returns the checksum for the given Pod' do - @lockfile.checksum('BananaLib').should == 'd46ca864666e216300a0653de197668b12e732a1' + expect(@lockfile.checksum('BananaLib')).to eq('d46ca864666e216300a0653de197668b12e732a1') end it 'returns the dependencies used for the last installation' do json_dep = Dependency.new('JSONKit') json_dep.external_source = { :podspec => 'path/JSONKit.podspec' } - @lockfile.dependencies.should == [ + expect(@lockfile.dependencies).to eq([ Dependency.new('BananaLib', '~>1.0'), json_dep, - ] + ]) end it 'returns the spec repo sources' do - @lockfile.pods_by_spec_repo.should == Hash[Sample.specs_by_source.map do |source, specs| + expect(@lockfile.pods_by_spec_repo).to eq(Hash[Sample.specs_by_source.map do |source, specs| next unless source.name == 'trunk' ['trunk', specs.map(&:name)] - end.compact] + end.compact]) end it 'returns the spec repo sources when that section is missing' do @lockfile = Lockfile.new({}) - @lockfile.pods_by_spec_repo.should == {} + expect(@lockfile.pods_by_spec_repo).to eq({}) end it 'only includes root names in spec repo sources' do @@ -223,31 +223,31 @@ def self.specs_by_source s.subspec 'Core' s.subspec 'NotCore' end.recursive_subspecs) - @lockfile.pods_by_spec_repo.should == { + expect(@lockfile.pods_by_spec_repo).to eq({ 'trunk' => %w(foo), - } + }) end it 'includes the external source information in the generated dependencies' do dep = @lockfile.dependencies.find { |d| d.name == 'JSONKit' } - dep.external_source.should == { :podspec => 'path/JSONKit.podspec' } + expect(dep.external_source).to eq({ :podspec => 'path/JSONKit.podspec' }) end it 'returns the dependency that locks the pod with the given name to the installed version' do json_dep = Dependency.new('JSONKit', '1.4') json_dep.external_source = { :podspec => 'path/JSONKit.podspec' } result = @lockfile.dependencies_to_lock_pod_named('JSONKit') - result.should == [json_dep] + expect(result).to eq([json_dep]) end it 'raises if there is a request for a locking dependency for a not stored Pod' do - should.raise StandardError do + expect do @lockfile.dependencies_to_lock_pod_named('Missing') - end.message.should.match /without a known dependency/ + end.to raise_error(StandardError, /without a known dependency/) end it 'returns the version of CocoaPods which generated the lockfile' do - @lockfile.cocoapods_version.should == Version.new(CORE_VERSION) + expect(@lockfile.cocoapods_version).to eq(Version.new(CORE_VERSION)) end end @@ -281,12 +281,12 @@ def self.specs_by_source pod 'JSONKit' pod 'TTTAttributedLabel' end - @lockfile.detect_changes_with_podfile(podfile).should == { + expect(@lockfile.detect_changes_with_podfile(podfile)).to eq({ :changed => [], :removed => [], :unchanged => %w(BlocksKit JSONKit), :added => ['TTTAttributedLabel'], - } + }) end it 'detects a removed Pod' do @@ -294,12 +294,12 @@ def self.specs_by_source platform :ios pod 'BlocksKit' end - @lockfile.detect_changes_with_podfile(podfile).should == { + expect(@lockfile.detect_changes_with_podfile(podfile)).to eq({ :changed => [], :removed => ['JSONKit'], :unchanged => ['BlocksKit'], :added => [], - } + }) end it 'detects Pods whose version changed' do @@ -308,12 +308,12 @@ def self.specs_by_source pod 'BlocksKit' pod 'JSONKit', '> 1.4' end - @lockfile.detect_changes_with_podfile(podfile).should == { + expect(@lockfile.detect_changes_with_podfile(podfile)).to eq({ :changed => ['JSONKit'], :removed => [], :unchanged => ['BlocksKit'], :added => [], - } + }) end it "it doesn't mark as changed Pods whose version changed but is still compatible with the Podfile" do @@ -322,12 +322,12 @@ def self.specs_by_source pod 'BlocksKit' pod 'JSONKit', '> 1.0' end - @lockfile.detect_changes_with_podfile(podfile).should == { + expect(@lockfile.detect_changes_with_podfile(podfile)).to eq({ :changed => [], :removed => [], :unchanged => %w(BlocksKit JSONKit), :added => [], - } + }) end it 'detects Pods whose external source changed' do @@ -336,30 +336,32 @@ def self.specs_by_source pod 'BlocksKit' pod 'JSONKit', :git => 'example1.com' end - @lockfile.detect_changes_with_podfile(podfile).should == { + expect(@lockfile.detect_changes_with_podfile(podfile)).to eq({ :changed => ['JSONKit'], :removed => [], :unchanged => ['BlocksKit'], :added => [], - } + }) @lockfile = Lockfile.generate(podfile, @specs, @checkout_options, @specs_by_source) podfile = Podfile.new do platform :ios pod 'BlocksKit' pod 'JSONKit', :git => 'example2.com' end - @lockfile.detect_changes_with_podfile(podfile).should == { + expect(@lockfile.detect_changes_with_podfile(podfile)).to eq({ :changed => ['JSONKit'], :removed => [], :unchanged => ['BlocksKit'], :added => [], - } + }) end end #-------------------------------------------------------------------------# describe 'Serialization' do + extend SpecHelper::TemporaryDirectory + before do @lockfile = Lockfile.generate(Sample.podfile, Sample.specs, Sample.checkout_options, Sample.specs_by_source) end @@ -368,7 +370,7 @@ def self.specs_by_source path = SpecHelper.temporary_directory + 'Podfile.lock' @lockfile.write_to_disk(path) loaded = Lockfile.from_file(path) - loaded.should == @lockfile + expect(loaded).to eq(@lockfile) end it "won't write to disk if the equivalent lockfile is already there" do @@ -379,7 +381,7 @@ def self.specs_by_source @lockfile.stubs(:to_yaml).returns("---\nhi: ./hi\n") path.expects(:open).with('w').never @lockfile.write_to_disk(path) - path.read.should == old_yaml + expect(path.read).to eq(old_yaml) end it 'overwrites a different lockfile' do @@ -390,19 +392,19 @@ def self.specs_by_source @lockfile = Lockfile.new('COCOAPODS' => '0.0.0') @lockfile.write_to_disk(path) - @lockfile.should == Lockfile.from_file(path) + expect(@lockfile).to eq(Lockfile.from_file(path)) end it 'fix strange quotation marks in lockfile' do yaml_string = Sample.quotation_marks_yaml yaml_string = yaml_string.tr("'", '') yaml_string = yaml_string.tr('"', '') - yaml_string.should == Sample.yaml + expect(yaml_string).to eq(Sample.yaml) end it 'generates a hash representation' do hash = @lockfile.to_hash - hash.should == { + expect(hash).to eq({ 'PODS' => [ { 'BananaLib (1.0)' => ['monkey (< 1.0.9, ~> 1.0.1)'] }, 'JSONKit (1.4)', 'monkey (1.0.8)'], @@ -413,23 +415,22 @@ def self.specs_by_source 'SPEC CHECKSUMS' => { 'BananaLib' => 'd46ca864666e216300a0653de197668b12e732a1', 'JSONKit' => '92ae5f71b77c8dec0cd8d0744adab79d38560949' }, 'PODFILE CHECKSUM' => 'podfile_checksum', 'COCOAPODS' => CORE_VERSION, - } + }) end it 'handles when the podfile has no checksum' do podfile = Sample.podfile podfile.stubs(:checksum).returns(nil) @lockfile = Lockfile.generate(podfile, Sample.specs, Sample.checkout_options, Sample.specs_by_source) - @lockfile.to_hash.should.not.key?('PODFILE CHECKSUM') + expect(@lockfile.to_hash).not_to have_key('PODFILE CHECKSUM') end it 'generates an ordered YAML representation' do - @lockfile.to_yaml.should == Sample.yaml + expect(@lockfile.to_yaml).to eq(Sample.yaml) end it 'generates a valid YAML representation' do - YAMLHelper.load_string(@lockfile.to_yaml).should == - YAMLHelper.load_string(Sample.yaml) + expect(YAMLHelper.load_string(@lockfile.to_yaml)).to eq(YAMLHelper.load_string(Sample.yaml)) end it 'serializes correctly external dependencies' do @@ -452,8 +453,8 @@ def self.specs_by_source } specs_by_source = { TrunkSource.new(fixture('spec-repos/trunk')) => specs.select { |s| s.name == 'monkey' } } lockfile = Lockfile.generate(podfile, specs, checkout_options, specs_by_source) - lockfile.internal_data['DEPENDENCIES'][0].should == 'BananaLib (from `www.example.com`, tag `1.0`)' - lockfile.internal_data['EXTERNAL SOURCES']['BananaLib'].should == { :git => 'www.example.com', :tag => '1.0' } + expect(lockfile.internal_data['DEPENDENCIES'][0]).to eq('BananaLib (from `www.example.com`, tag `1.0`)') + expect(lockfile.internal_data['EXTERNAL SOURCES']['BananaLib']).to eq({ :git => 'www.example.com', :tag => '1.0' }) end describe 'when the Podfile is empty' do @@ -462,7 +463,7 @@ def self.specs_by_source end it 'generates a lockfile with only the version' do - @lockfile.to_yaml.should == "COCOAPODS: #{CORE_VERSION}\n" + expect(@lockfile.to_yaml).to eq("COCOAPODS: #{CORE_VERSION}\n") end end end @@ -475,38 +476,38 @@ def self.specs_by_source end it 'stores the information of the installed pods and of their dependencies' do - @lockfile.internal_data['PODS'].should == [ + expect(@lockfile.internal_data['PODS']).to eq([ { 'BananaLib (1.0)' => ['monkey (< 1.0.9, ~> 1.0.1)'] }, 'JSONKit (1.4)', 'monkey (1.0.8)', - ] + ]) end it 'stores the information of the dependencies of the Podfile' do - @lockfile.internal_data['DEPENDENCIES'].should == [ + expect(@lockfile.internal_data['DEPENDENCIES']).to eq([ 'BananaLib (~> 1.0)', 'JSONKit (from `path/JSONKit.podspec`)' - ] + ]) end it 'stores the information of the external sources' do - @lockfile.internal_data['EXTERNAL SOURCES'].should == { + expect(@lockfile.internal_data['EXTERNAL SOURCES']).to eq({ 'JSONKit' => { :podspec => 'path/JSONKit.podspec' }, - } + }) end it 'stores the checksum of the specifications' do - @lockfile.internal_data['SPEC CHECKSUMS'].should == { + expect(@lockfile.internal_data['SPEC CHECKSUMS']).to eq({ 'BananaLib' => 'd46ca864666e216300a0653de197668b12e732a1', 'JSONKit' => '92ae5f71b77c8dec0cd8d0744adab79d38560949', - } + }) end it 'store the version of the CocoaPods Core gem' do - @lockfile.internal_data['COCOAPODS'].should == CORE_VERSION + expect(@lockfile.internal_data['COCOAPODS']).to eq(CORE_VERSION) end it 'it includes all the information that it is expected to store' do - @lockfile.internal_data.should == YAMLHelper.load_string(Sample.yaml) + expect(@lockfile.internal_data).to eq(YAMLHelper.load_string(Sample.yaml)) end end @@ -528,9 +529,9 @@ def self.specs_by_source end, ] pods_data = Lockfile.send(:generate_pods_data, specs) - pods_data.should == [ + expect(pods_data).to eq([ { 'BananaLib (1.0)' => ['monkey (< 1.0.9)', 'tree (~> 1.0.1)'] }, - ] + ]) end it 'sort pods by lowercase' do @@ -551,11 +552,11 @@ def self.specs_by_source end, ] pods_data = Lockfile.send(:generate_pods_data, specs) - pods_data.should == [ + expect(pods_data).to eq([ { 'a (1.0)' => ['monkey (< 1.0.9)'] }, 'b (1.0)', { 'C (1.0)' => ['tree (~> 1.0.1)'] }, - ] + ]) end it 'sorts dependencies for the pod by lowercase' do @@ -577,9 +578,9 @@ def self.specs_by_source end, ] pods_data = Lockfile.send(:generate_pods_data, specs) - pods_data.should == [ + expect(pods_data).to eq([ { 'BananaLib (1.0)' => ['a (< 1.0.9)', 'b (< 1.0.8)', 'C (~> 1.0.1)'] }, - ] + ]) end end @@ -591,7 +592,7 @@ def self.specs_by_source pod 'C' end dependencies_data = Lockfile.send(:generate_dependencies_data, podfile) - dependencies_data.should == %w(a b C) + expect(dependencies_data).to eq(%w(a b C)) end end @@ -614,7 +615,7 @@ def self.specs_by_source ], } spec_repos_data = Lockfile.send(:generate_spec_repos, spec_repos) - spec_repos_data.should == { 'trunk' => %w(a b C) } + expect(spec_repos_data).to eq({ 'trunk' => %w(a b C) }) end end @@ -647,7 +648,7 @@ def self.specs_by_source ], } spec_repos_data = Lockfile.send(:generate_spec_repos, spec_repos) - spec_repos_data.should == { 'trunk' => %w(a b C d E) } + expect(spec_repos_data).to eq({ 'trunk' => %w(a b C d E) }) end end end diff --git a/spec/platform_spec.rb b/spec/platform_spec.rb index 3f8fb088a..0c22a028a 100644 --- a/spec/platform_spec.rb +++ b/spec/platform_spec.rb @@ -4,22 +4,22 @@ module Pod describe Platform do describe 'In general' do it 'returns a new Platform instance' do - Platform.ios.should == Platform.new(:ios) - Platform.osx.should == Platform.new(:osx) - Platform.tvos.should == Platform.new(:tvos) - Platform.visionos.should == Platform.new(:visionos) - Platform.watchos.should == Platform.new(:watchos) - Platform.all.should.include? Platform.new(:ios) - Platform.all.should.include? Platform.new(:osx) - Platform.all.should.include? Platform.new(:tvos) - Platform.all.should.include? Platform.new(:visionos) - Platform.all.should.include? Platform.new(:watchos) + expect(Platform.ios).to eq(Platform.new(:ios)) + expect(Platform.osx).to eq(Platform.new(:osx)) + expect(Platform.tvos).to eq(Platform.new(:tvos)) + expect(Platform.visionos).to eq(Platform.new(:visionos)) + expect(Platform.watchos).to eq(Platform.new(:watchos)) + expect(Platform.all).to include(Platform.new(:ios)) + expect(Platform.all).to include(Platform.new(:osx)) + expect(Platform.all).to include(Platform.new(:tvos)) + expect(Platform.all).to include(Platform.new(:visionos)) + expect(Platform.all).to include(Platform.new(:watchos)) end it 'can be initialized from another platform' do platform = Platform.new(:ios) new = Platform.new(platform) - new.should == platform + expect(new).to eq(platform) end before do @@ -27,113 +27,113 @@ module Pod end it 'exposes its symbolic name' do - @platform.name.should == :ios + expect(@platform.name).to eq(:ios) end it 'can be initialized with a string' do - Platform.new('MACOS').should == Platform.macos - Platform.new('macOS').should == Platform.macos - Platform.new('macos').should == Platform.macos + expect(Platform.new('MACOS')).to eq(Platform.macos) + expect(Platform.new('macOS')).to eq(Platform.macos) + expect(Platform.new('macos')).to eq(Platform.macos) - Platform.new('iOS').should == Platform.ios - Platform.new('IOS').should == Platform.ios - Platform.new('ios').should == Platform.ios + expect(Platform.new('iOS')).to eq(Platform.ios) + expect(Platform.new('IOS')).to eq(Platform.ios) + expect(Platform.new('ios')).to eq(Platform.ios) - Platform.new('tvos').should == Platform.tvos - Platform.new('tvOS').should == Platform.tvos - Platform.new('TVOS').should == Platform.tvos + expect(Platform.new('tvos')).to eq(Platform.tvos) + expect(Platform.new('tvOS')).to eq(Platform.tvos) + expect(Platform.new('TVOS')).to eq(Platform.tvos) - Platform.new('watchOS').should == Platform.watchos - Platform.new('WATCHOS').should == Platform.watchos - Platform.new('watchos').should == Platform.watchos + expect(Platform.new('watchOS')).to eq(Platform.watchos) + expect(Platform.new('WATCHOS')).to eq(Platform.watchos) + expect(Platform.new('watchos')).to eq(Platform.watchos) - Platform.new('visionos').should == Platform.visionos - Platform.new('VISIONOS').should == Platform.visionos - Platform.new('visionOS').should == Platform.visionos + expect(Platform.new('visionos')).to eq(Platform.visionos) + expect(Platform.new('VISIONOS')).to eq(Platform.visionos) + expect(Platform.new('visionOS')).to eq(Platform.visionos) # Recognizes xrOS - Platform.new('xros').should == Platform.visionos - Platform.new('XROS').should == Platform.visionos - Platform.new('xrOS').should == Platform.visionos + expect(Platform.new('xros')).to eq(Platform.visionos) + expect(Platform.new('XROS')).to eq(Platform.visionos) + expect(Platform.new('xrOS')).to eq(Platform.visionos) end it 'exposes its name as string' do - Platform.ios.string_name.should == 'iOS' - Platform.osx.string_name.should == 'macOS' - Platform.tvos.string_name.should == 'tvOS' - Platform.visionos.string_name.should == 'visionOS' - Platform.watchos.string_name.should == 'watchOS' + expect(Platform.ios.string_name).to eq('iOS') + expect(Platform.osx.string_name).to eq('macOS') + expect(Platform.tvos.string_name).to eq('tvOS') + expect(Platform.visionos.string_name).to eq('visionOS') + expect(Platform.watchos.string_name).to eq('watchOS') end it 'exposes a safe variant of its name as string' do - Platform.ios.safe_string_name.should == 'iOS' - Platform.osx.safe_string_name.should == 'macOS' - Platform.tvos.safe_string_name.should == 'tvOS' - Platform.visionos.safe_string_name.should == 'visionOS' - Platform.watchos.safe_string_name.should == 'watchOS' + expect(Platform.ios.safe_string_name).to eq('iOS') + expect(Platform.osx.safe_string_name).to eq('macOS') + expect(Platform.tvos.safe_string_name).to eq('tvOS') + expect(Platform.visionos.safe_string_name).to eq('visionOS') + expect(Platform.watchos.safe_string_name).to eq('watchOS') end it 'can be compared for equality with another platform with the same symbolic name' do - @platform.should == Platform.new(:ios) + expect(@platform).to eq(Platform.new(:ios)) end it 'can be compared for equality with another platform with the same symbolic name and the same deployment target' do - @platform.should.not == Platform.new(:ios, '4.0') - Platform.new(:ios, '4.0').should == Platform.new(:ios, '4.0') + expect(@platform).not_to eq(Platform.new(:ios, '4.0')) + expect(Platform.new(:ios, '4.0')).to eq(Platform.new(:ios, '4.0')) end it 'can be compared for equality with a matching symbolic name (backwards compatibility reasons)' do - @platform.should == :ios + expect(@platform).to eq(:ios) end it 'presents an accurate string representation' do - @platform.to_s.should == 'iOS' - Platform.new(:osx).to_s.should == 'macOS' - Platform.new(:visionos).to_s.should == 'visionOS' - Platform.new(:watchos).to_s.should == 'watchOS' - Platform.new(:tvos).to_s.should == 'tvOS' - Platform.new(:ios, '5.0.0').to_s.should == 'iOS 5.0.0' - Platform.new(:osx, '10.7').to_s.should == 'macOS 10.7' - Platform.new(:visionos, '1.0').to_s.should == 'visionOS 1.0' - Platform.new(:watchos, '2.0').to_s.should == 'watchOS 2.0' - Platform.new(:tvos, '9.0').to_s.should == 'tvOS 9.0' + expect(@platform.to_s).to eq('iOS') + expect(Platform.new(:osx).to_s).to eq('macOS') + expect(Platform.new(:visionos).to_s).to eq('visionOS') + expect(Platform.new(:watchos).to_s).to eq('watchOS') + expect(Platform.new(:tvos).to_s).to eq('tvOS') + expect(Platform.new(:ios, '5.0.0').to_s).to eq('iOS 5.0.0') + expect(Platform.new(:osx, '10.7').to_s).to eq('macOS 10.7') + expect(Platform.new(:visionos, '1.0').to_s).to eq('visionOS 1.0') + expect(Platform.new(:watchos, '2.0').to_s).to eq('watchOS 2.0') + expect(Platform.new(:tvos, '9.0').to_s).to eq('tvOS 9.0') end it 'uses its name as its symbol version' do - @platform.to_sym.should == :ios + expect(@platform.to_sym).to eq(:ios) end it 'allows to specify the deployment target on initialization' do p = Platform.new(:ios, '4.0.0') - p.deployment_target.should == Version.new('4.0.0') + expect(p.deployment_target).to eq(Version.new('4.0.0')) end it 'allows to specify the deployment target in a hash on initialization (backwards compatibility from 0.6)' do p = Platform.new(:ios, :deployment_target => '4.0.0') - p.deployment_target.should == Version.new('4.0.0') + expect(p.deployment_target).to eq(Version.new('4.0.0')) end it 'can be sorted by name' do p_1 = Platform.new(:ios, '4.0') p_2 = Platform.new(:osx, '10.6') - (p_1 <=> p_2).should == -1 - (p_1 <=> p_1).should == 0 - (p_2 <=> p_1).should == 1 + expect(p_1 <=> p_2).to eq(-1) + expect(p_1 <=> p_1).to eq(0) + expect(p_2 <=> p_1).to eq(1) end it 'can be sorted by deployment_target' do p_1 = Platform.new(:ios, '4.0') p_2 = Platform.new(:ios, '6.0') - (p_1 <=> p_2).should == -1 - (p_1 <=> p_1).should == 0 - (p_2 <=> p_1).should == 1 + expect(p_1 <=> p_2).to eq(-1) + expect(p_1 <=> p_1).to eq(0) + expect(p_2 <=> p_1).to eq(1) end it 'returns whether it requires legacy iOS architectures' do - Platform.new(:ios, '4.0').requires_legacy_ios_archs?.should.be.true - Platform.new(:ios, '5.0').requires_legacy_ios_archs?.should.be.false - Platform.new(:visionos, '1.0').requires_legacy_ios_archs?.should.be.false - Platform.new(:watchos, '2.0').requires_legacy_ios_archs?.should.be.false - Platform.new(:tvos, '9.0').requires_legacy_ios_archs?.should.be.false + expect(Platform.new(:ios, '4.0').requires_legacy_ios_archs?).to be(true) + expect(Platform.new(:ios, '5.0').requires_legacy_ios_archs?).to be(false) + expect(Platform.new(:visionos, '1.0').requires_legacy_ios_archs?).to be(false) + expect(Platform.new(:watchos, '2.0').requires_legacy_ios_archs?).to be(false) + expect(Platform.new(:tvos, '9.0').requires_legacy_ios_archs?).to be(false) end it 'is usable as hash keys' do @@ -142,39 +142,39 @@ module Pod ios6 = Platform.new(:ios, '6.0') ios61 = Platform.new(:ios, '6.1') hash = { ios => ios, osx => osx, ios6 => ios6, ios61 => ios61 } - hash[Platform.new(:ios)].should.be.eql ios - hash[Platform.new(:osx)].should.be.eql osx - hash[Platform.new(:ios, '6.0')].should.be.eql ios6 - hash[Platform.new(:ios, '6.1')].should.be.eql ios61 + expect(hash[Platform.new(:ios)]).to eql(ios) + expect(hash[Platform.new(:osx)]).to eql(osx) + expect(hash[Platform.new(:ios, '6.0')]).to eql(ios6) + expect(hash[Platform.new(:ios, '6.1')]).to eql(ios61) end describe '#supports_dynamic_frameworks?' do it 'supports dynamic frameworks on OSX' do - Platform.osx.should.supports_dynamic_frameworks - Platform.new(:osx, '10.7').should.supports_dynamic_frameworks - Platform.new(:osx, '10.10').should.supports_dynamic_frameworks + expect(Platform.osx.supports_dynamic_frameworks?).to be_truthy + expect(Platform.new(:osx, '10.7').supports_dynamic_frameworks?).to be_truthy + expect(Platform.new(:osx, '10.10').supports_dynamic_frameworks?).to be_truthy end it 'supports dynamic frameworks on iOS since version 8.0' do - Platform.ios.should.not.supports_dynamic_frameworks - Platform.new(:ios, '7.0').should.not.supports_dynamic_frameworks - Platform.new(:ios, '8.0').should.supports_dynamic_frameworks - Platform.new(:ios, '8.1').should.supports_dynamic_frameworks + expect(Platform.ios.supports_dynamic_frameworks?).to be_falsey + expect(Platform.new(:ios, '7.0').supports_dynamic_frameworks?).to be_falsey + expect(Platform.new(:ios, '8.0').supports_dynamic_frameworks?).to be_truthy + expect(Platform.new(:ios, '8.1').supports_dynamic_frameworks?).to be_truthy end it 'supports dynamic frameworks on visionOS' do - Platform.visionos.should.supports_dynamic_frameworks - Platform.new(:visionos, '1.0').should.supports_dynamic_frameworks + expect(Platform.visionos.supports_dynamic_frameworks?).to be_truthy + expect(Platform.new(:visionos, '1.0').supports_dynamic_frameworks?).to be_truthy end it 'supports dynamic frameworks on watchOS' do - Platform.watchos.should.supports_dynamic_frameworks - Platform.new(:watchos, '2.0').should.supports_dynamic_frameworks + expect(Platform.watchos.supports_dynamic_frameworks?).to be_truthy + expect(Platform.new(:watchos, '2.0').supports_dynamic_frameworks?).to be_truthy end it 'supports dynamic frameworks on tvOS' do - Platform.tvos.should.supports_dynamic_frameworks - Platform.new(:tvos, '9.0').should.supports_dynamic_frameworks + expect(Platform.tvos.supports_dynamic_frameworks?).to be_truthy + expect(Platform.new(:tvos, '9.0').supports_dynamic_frameworks?).to be_truthy end end end @@ -183,31 +183,31 @@ module Pod it 'supports platforms with the same operating system' do p1 = Platform.new(:ios) p2 = Platform.new(:ios) - p1.should.supports?(p2) + expect(p1.supports?(p2)).to be_truthy p1 = Platform.new(:osx) p2 = Platform.new(:osx) - p1.should.supports?(p2) + expect(p1.supports?(p2)).to be_truthy end it 'supports a platform with a lower or equal deployment_target' do p1 = Platform.new(:ios, '5.0') p2 = Platform.new(:ios, '4.0') - p1.should.supports?(p1) - p1.should.supports?(p2) - p2.should.not.supports?(p1) + expect(p1.supports?(p1)).to be_truthy + expect(p1.supports?(p2)).to be_truthy + expect(p2.supports?(p1)).to be_falsey end it "doesn't supports a platform with a different operating system" do p1 = Platform.new(:ios) p2 = Platform.new(:osx) - p1.should.not.supports?(p2) + expect(p1.supports?(p2)).to be_falsey end it 'returns the string name of a given symbolic name' do - Platform.string_name(:ios).should == 'iOS' - Platform.string_name(:osx).should == 'macOS' - Platform.string_name(:win).should == 'win' + expect(Platform.string_name(:ios)).to eq('iOS') + expect(Platform.string_name(:osx)).to eq('macOS') + expect(Platform.string_name(:win)).to eq('win') end end end diff --git a/spec/podfile/dsl_spec.rb b/spec/podfile/dsl_spec.rb index 806aba659..56484f871 100644 --- a/spec/podfile/dsl_spec.rb +++ b/spec/podfile/dsl_spec.rb @@ -8,9 +8,9 @@ module Pod pod 'ASIHTTPRequest' pod 'SSZipArchive', '>= 0.1' end - podfile.dependencies.size.should == 2 - podfile.dependencies.find { |d| d.root_name == 'ASIHTTPRequest' }.should == Dependency.new('ASIHTTPRequest') - podfile.dependencies.find { |d| d.root_name == 'SSZipArchive' }.should == Dependency.new('SSZipArchive', '>= 0.1') + expect(podfile.dependencies.size).to eq(2) + expect(podfile.dependencies.find { |d| d.root_name == 'ASIHTTPRequest' }).to eq(Dependency.new('ASIHTTPRequest')) + expect(podfile.dependencies.find { |d| d.root_name == 'SSZipArchive' }).to eq(Dependency.new('SSZipArchive', '>= 0.1')) end describe 'whitelisting pods per configuration' do @@ -20,8 +20,8 @@ module Pod end target = podfile.target_definitions['Pods'] - target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release').should.be.true - target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug').should.be.true + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release')).to be(true) + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug')).to be(true) end it 'allows to white-list a dependency on multiple build configuration' do @@ -30,9 +30,9 @@ module Pod end target = podfile.target_definitions['Pods'] - target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release').should.be.true - target.pod_whitelisted_for_configuration?('PonyDebugger', 'App Store').should.be.true - target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug').should.be.false + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release')).to be(true) + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'App Store')).to be(true) + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug')).to be(false) end it 'allows to white-list a dependency on a build configuration' do @@ -41,8 +41,8 @@ module Pod end target = podfile.target_definitions['Pods'] - target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release').should.be.true - target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug').should.be.false + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release')).to be(true) + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug')).to be(false) end it 'allows to white-list a dependency on a build configuration in a target block' do @@ -53,8 +53,8 @@ module Pod end target = podfile.target_definitions['App'] - target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release').should.be.true - target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug').should.be.false + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'Release')).to be(true) + expect(target.pod_whitelisted_for_configuration?('PonyDebugger', 'Debug')).to be(false) end end @@ -65,17 +65,17 @@ module Pod end target = podfile.target_definitions['Pods'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.false + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(false) end it 'raises if :inhibit_warnings value is not a boolean' do - should.raise ArgumentError do + expect do podfile = Podfile.new do pod 'PonyDebugger', :inhibit_warnings => 'true' end target = podfile.target_definitions['Pods'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true - end.message.should.match /should be a boolean/ + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) + end.to raise_error(ArgumentError, /should be a boolean/) end it 'allows inhibiting warnings on a single dependency' do @@ -84,7 +84,7 @@ module Pod end target = podfile.target_definitions['Pods'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) end it 'allows not inhibiting warnings on a single dependency' do @@ -94,7 +94,7 @@ module Pod end target = podfile.target_definitions['Pods'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.false + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(false) end it 'allows inhibiting warnings on a single dependency in a target block' do @@ -105,7 +105,7 @@ module Pod end target = podfile.target_definitions['App'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) end it 'allows not inhibiting warnings on a single dependency in a target block' do @@ -117,7 +117,7 @@ module Pod end target = podfile.target_definitions['App'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.false + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(false) end it 'allows inhibiting warnings on a single dependency in a target block with inheritance' do @@ -131,7 +131,7 @@ module Pod end target = podfile.target_definitions['App'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) end it 'allows inhibiting in parent and not inhibiting in child on a single dependency' do @@ -145,10 +145,10 @@ module Pod end target = podfile.target_definitions['App'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) target = podfile.target_definitions['Inherited'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.false + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(false) end it 'allows not inhibiting in parent and inhibiting in child on a single dependency' do @@ -162,10 +162,10 @@ module Pod end target = podfile.target_definitions['App'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.false + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(false) target = podfile.target_definitions['Inherited'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) end it 'allows not inhibiting a single dependency in parent and inhibiting all dependencies in child' do @@ -180,10 +180,10 @@ module Pod end target = podfile.target_definitions['App'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.false + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(false) target = podfile.target_definitions['Inherited'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) end it 'allows not inhibiting a single dependency in grandparent and inhibiting all dependencies in grandchild' do @@ -200,10 +200,10 @@ module Pod end target = podfile.target_definitions['App'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.false + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(false) target = podfile.target_definitions['InheritedLevelTwo'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) end it 'allows inhibiting all warnings in parent and child scopes' do @@ -219,10 +219,10 @@ module Pod end target = podfile.target_definitions['App'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) target = podfile.target_definitions['Inherited'] - target.inhibits_warnings_for_pod?('PonyDebugger').should.be.true + expect(target.inhibits_warnings_for_pod?('PonyDebugger')).to be(true) end end @@ -233,7 +233,7 @@ module Pod end target = podfile.target_definitions['Pods'] - target.project_name_for_pod('PonyDebugger').should == 'PonyProject' + expect(target.project_name_for_pod('PonyDebugger')).to eq('PonyProject') end end @@ -244,17 +244,17 @@ module Pod end target = podfile.target_definitions['Pods'] - target.build_pod_as_module?('PonyDebugger').should.be.false + expect(target.build_pod_as_module?('PonyDebugger')).to be(false) end it 'raises if :modular_headers value is not a boolean' do - should.raise ArgumentError do + expect do podfile = Podfile.new do pod 'PonyDebugger', :modular_headers => 'true' end target = podfile.target_definitions['Pods'] - target.build_pod_as_module?('PonyDebugger').should.be.true - end.message.should.match /should be a boolean/ + expect(target.build_pod_as_module?('PonyDebugger')).to be(true) + end.to raise_error(ArgumentError, /should be a boolean/) end it 'allows modular headers on a single dependency' do @@ -263,7 +263,7 @@ module Pod end target = podfile.target_definitions['Pods'] - target.build_pod_as_module?('PonyDebugger').should.be.true + expect(target.build_pod_as_module?('PonyDebugger')).to be(true) end it 'allows not modular headers on a single dependency' do @@ -273,7 +273,7 @@ module Pod end target = podfile.target_definitions['Pods'] - target.build_pod_as_module?('PonyDebugger').should.be.false + expect(target.build_pod_as_module?('PonyDebugger')).to be(false) end it 'allows modular headers on a single dependency in a target block' do @@ -284,7 +284,7 @@ module Pod end target = podfile.target_definitions['App'] - target.build_pod_as_module?('PonyDebugger').should.be.true + expect(target.build_pod_as_module?('PonyDebugger')).to be(true) end it 'allows not modular headers on a single dependency in a target block' do @@ -296,7 +296,7 @@ module Pod end target = podfile.target_definitions['App'] - target.build_pod_as_module?('PonyDebugger').should.be.false + expect(target.build_pod_as_module?('PonyDebugger')).to be(false) end it 'allows modular headers on a single dependency in a target block with inheritance' do @@ -310,7 +310,7 @@ module Pod end target = podfile.target_definitions['App'] - target.build_pod_as_module?('PonyDebugger').should.be.true + expect(target.build_pod_as_module?('PonyDebugger')).to be(true) end it 'allows modular headers in parent and not using them in child on a single dependency' do @@ -324,10 +324,10 @@ module Pod end target = podfile.target_definitions['App'] - target.build_pod_as_module?('PonyDebugger').should.be.true + expect(target.build_pod_as_module?('PonyDebugger')).to be(true) target = podfile.target_definitions['Inherited'] - target.build_pod_as_module?('PonyDebugger').should.be.false + expect(target.build_pod_as_module?('PonyDebugger')).to be(false) end it 'allows not using modular headers in parent and using modular headers in child on a single dependency' do @@ -341,10 +341,10 @@ module Pod end target = podfile.target_definitions['App'] - target.build_pod_as_module?('PonyDebugger').should.be.false + expect(target.build_pod_as_module?('PonyDebugger')).to be(false) target = podfile.target_definitions['Inherited'] - target.build_pod_as_module?('PonyDebugger').should.be.true + expect(target.build_pod_as_module?('PonyDebugger')).to be(true) end it 'allows not using modular headers a single dependency in parent and using modular headers all dependencies in child' do @@ -359,10 +359,10 @@ module Pod end target = podfile.target_definitions['App'] - target.build_pod_as_module?('PonyDebugger').should.be.false + expect(target.build_pod_as_module?('PonyDebugger')).to be(false) target = podfile.target_definitions['Inherited'] - target.build_pod_as_module?('PonyDebugger').should.be.true + expect(target.build_pod_as_module?('PonyDebugger')).to be(true) end it 'allows not using modular headers a single dependency in grandparent and using modular headers all dependencies in grandchild' do @@ -379,10 +379,10 @@ module Pod end target = podfile.target_definitions['App'] - target.build_pod_as_module?('PonyDebugger').should.be.false + expect(target.build_pod_as_module?('PonyDebugger')).to be(false) target = podfile.target_definitions['InheritedLevelTwo'] - target.build_pod_as_module?('PonyDebugger').should.be.true + expect(target.build_pod_as_module?('PonyDebugger')).to be(true) end end @@ -396,8 +396,8 @@ module Pod Dependency.new('RestKit/CoreData', '~> 0.24.0'), Dependency.new('RestKit/Networking', '~> 0.24.0'), ] - target.dependencies.sort_by(&:name).should == expected_dependencies - target.pod_whitelisted_for_configuration?('RestKit', 'Release').should.be.true + expect(target.dependencies.sort_by(&:name)).to eq(expected_dependencies) + expect(target.pod_whitelisted_for_configuration?('RestKit', 'Release')).to be(true) podfile = Podfile.new do pod 'RestKit/Subspec', :subspecs => %w(CoreData Networking/Subspec), :git => 'https://github.com/RestKit/RestKit.git' @@ -408,25 +408,25 @@ module Pod Dependency.new('RestKit/Subspec/CoreData', :git => 'https://github.com/RestKit/RestKit.git'), Dependency.new('RestKit/Subspec/Networking/Subspec', :git => 'https://github.com/RestKit/RestKit.git'), ] - target.dependencies.sort_by(&:name).should == expected_dependencies + expect(target.dependencies.sort_by(&:name)).to eq(expected_dependencies) end it 'raises if no name is specified for a Pod' do - lambda do + expect do Podfile.new do pod end - end.should.raise Podfile::StandardError + end.to raise_error(Podfile::StandardError) end it 'raises if an inlide podspec is specified' do - lambda do + expect do Podfile.new do pod do |s| s.name = 'mypod' end end - end.should.raise Podfile::StandardError + end.to raise_error(Podfile::StandardError) end it 'it can use use the dependencies of a podspec' do @@ -435,7 +435,7 @@ module Pod platform :ios podspec :path => banalib_path end - podfile.dependencies.map(&:name).should == %w(monkey AFNetworking SDWebImage) + expect(podfile.dependencies.map(&:name)).to eq(%w(monkey AFNetworking SDWebImage)) end it 'it can use use the dependencies of a podspec\'s subspec' do @@ -444,7 +444,7 @@ module Pod platform :ios podspec :path => banalib_path, :subspec => 'GreenBanana' end - podfile.dependencies.map(&:name).should == %w(monkey AFNetworking) + expect(podfile.dependencies.map(&:name)).to eq(%w(monkey AFNetworking)) end it 'allows specifying a child target definition' do @@ -453,7 +453,7 @@ module Pod pod 'OCMock' end end - podfile.target_definitions[:tests].name.should == :tests + expect(podfile.target_definitions[:tests].name).to eq(:tests) end end @@ -467,17 +467,17 @@ module Pod platform :osx, '10.8' end end - podfile.target_definitions['Pods'].platform.should == Platform.new(:ios, '6.0') - podfile.target_definitions[:osx_target].platform.should == Platform.new(:osx, '10.8') + expect(podfile.target_definitions['Pods'].platform).to eq(Platform.new(:ios, '6.0')) + expect(podfile.target_definitions[:osx_target].platform).to eq(Platform.new(:osx, '10.8')) end it 'does not allow specifying a platform twice' do - should.raise(Podfile::StandardError) do + expect do Podfile.new do platform :ios, '6.0' platform :ios, '9.0' end - end.message.should == 'The target `Pods` already has a platform set.' + end.to raise_error(Podfile::StandardError, 'The target `Pods` already has a platform set.') end it 'allows specifying whether the target is exclusive' do @@ -486,7 +486,7 @@ module Pod inherit!(:none) end end - podfile.target_definitions['Pods'].should.be.exclusive + expect(podfile.target_definitions['Pods']).to be_exclusive end it 'is not exclusive by default' do @@ -494,7 +494,7 @@ module Pod target 'Pods' do end end - podfile.target_definitions['Pods'].should.not.be.exclusive + expect(podfile.target_definitions['Pods']).not_to be_exclusive end it 'allows specifying whether the target is abstract' do @@ -503,7 +503,7 @@ module Pod abstract! end end - podfile.target_definitions['App'].should.be.abstract + expect(podfile.target_definitions['App']).to be_abstract end it 'is not abstract by default' do @@ -511,7 +511,7 @@ module Pod target 'App' do end end - podfile.target_definitions['App'].should.not.be.abstract + expect(podfile.target_definitions['App']).not_to be_abstract end it 'allows specifying an abstract target' do @@ -519,7 +519,7 @@ module Pod abstract_target 'App' do end end - podfile.target_definitions['App'].should.be.abstract + expect(podfile.target_definitions['App']).to be_abstract end describe 'inheritance' do @@ -531,42 +531,42 @@ module Pod inherit! mode end end - podfile.target_definitions['App'].inheritance.should == mode + expect(podfile.target_definitions['App'].inheritance).to eq(mode) end end it 'raises when specifying an unknown mode' do - should.raise(Informative) do + expect do Podfile.new do target 'App' do inherit! 'foo' end end - end.message.should == 'Unrecognized inheritance option `foo` specified for target `App`.' + end.to raise_error(Informative, 'Unrecognized inheritance option `foo` specified for target `App`.') end end it 'raises if unrecognized keys are passed during the initialization of a target' do - should.raise Informative do + expect do Podfile.new do target 'Pods', :unrecognized => true do end end - end + end.to raise_error(Informative) end it 'allows specifying the user Xcode project for a Target definition' do podfile = Podfile.new { project 'App.xcodeproj' } - podfile.target_definitions['Pods'].user_project_path.should == 'App.xcodeproj' + expect(podfile.target_definitions['Pods'].user_project_path).to eq('App.xcodeproj') end it 'allows specifying the build configurations of a user project' do podfile = Podfile.new do project 'App.xcodeproj', 'Mac App Store' => :release, 'Test' => :debug end - podfile.target_definitions['Pods'].build_configurations.should == { + expect(podfile.target_definitions['Pods'].build_configurations).to eq({ 'Mac App Store' => :release, 'Test' => :debug - } + }) end it 'allows to inhibit all the warnings of a Target definition' do @@ -574,12 +574,12 @@ module Pod pod 'ObjectiveRecord' inhibit_all_warnings! end - podfile.target_definitions['Pods'].inhibits_warnings_for_pod?('ObjectiveRecord').should.be.true + expect(podfile.target_definitions['Pods'].inhibits_warnings_for_pod?('ObjectiveRecord')).to be(true) end it 'defaults to not use frameworks for a Target definition' do podfile = Podfile.new { pod 'ObjectiveRecord' } - podfile.target_definitions['Pods'].uses_frameworks?.should.be.false + expect(podfile.target_definitions['Pods'].uses_frameworks?).to be(false) end it 'allows to use frameworks for a Target definition' do @@ -587,7 +587,7 @@ module Pod pod 'ObjectiveRecord' use_frameworks! end - podfile.target_definitions['Pods'].uses_frameworks?.should.be.true + expect(podfile.target_definitions['Pods'].uses_frameworks?).to be(true) end end @@ -595,19 +595,19 @@ module Pod describe 'Workspace' do it 'specifies the Xcode workspace to use' do - Podfile.new do + expect(Podfile.new do workspace 'MyWorkspace.xcworkspace' - end.workspace_path.should == 'MyWorkspace.xcworkspace' + end.workspace_path).to eq('MyWorkspace.xcworkspace') end it 'specifies that BridgeSupport metadata should be generated' do - Podfile.new {}.should.not.generate_bridge_support - Podfile.new { generate_bridge_support! }.should.generate_bridge_support + expect(Podfile.new {}.generate_bridge_support?).to be_falsey + expect(Podfile.new { generate_bridge_support! }.generate_bridge_support?).to be_truthy end it 'specifies that ARC compatibility flag should be generated' do - Podfile.new {}.should.not.set_arc_compatibility_flag - Podfile.new { set_arc_compatibility_flag! }.should.set_arc_compatibility_flag + expect(Podfile.new {}.set_arc_compatibility_flag?).to be_falsey + expect(Podfile.new { set_arc_compatibility_flag! }.set_arc_compatibility_flag?).to be_truthy end end @@ -621,7 +621,7 @@ module Pod yielded = installer end end.pre_install!(:an_installer) - yielded.should == :an_installer + expect(yielded).to eq(:an_installer) end it 'stores a block that will be called with the Installer instance once installation is finished' do @@ -631,11 +631,11 @@ module Pod yielded = installer end end.post_install!(:an_installer) - yielded.should == :an_installer + expect(yielded).to eq(:an_installer) end it 'raises when post_install is called multiple times' do - should.raise(Informative) do + expect do Podfile.new do target 'App' do post_install do |installer| @@ -645,7 +645,7 @@ module Pod end end end - end.message.should == 'Specifying multiple `post_install` hooks is unsupported.' + end.to raise_error(Informative, 'Specifying multiple `post_install` hooks is unsupported.') end end @@ -656,24 +656,24 @@ module Pod podfile = Podfile.new do install! 'method' end - podfile.installation_method.should == ['method', {}] + expect(podfile.installation_method).to eq(['method', {}]) end it 'allows specifying a custom installation method with options' do podfile = Podfile.new do install! 'method', 'option' => 'value' end - podfile.installation_method.should == ['method', { 'option' => 'value' }] + expect(podfile.installation_method).to eq(['method', { 'option' => 'value' }]) end it 'raises when specifying an installation method outside of root' do - should.raise(Informative) do + expect do Podfile.new do target 'App' do install! 'method' end end - end.message.should == 'The installation method can only be set at the root level of the Podfile.' + end.to raise_error(Informative, 'The installation method can only be set at the root level of the Podfile.') end end @@ -697,22 +697,22 @@ def restore_bundler_environment ENV['BUNDLE_BIN_PATH'] = nil ENV['BUNDLE_GEMFILE'] = nil ENV['BUNDLER_VERSION'] = nil - should.raise(Informative) do + expect do Podfile.new do ensure_bundler! end - end.message.should == "CocoaPods was invoked from Global Gemset.\nPlease re-run using: `bundle exec pod #{ARGV.join(' ')}`" + end.to raise_error(Informative, "CocoaPods was invoked from Global Gemset.\nPlease re-run using: `bundle exec pod #{ARGV.join(' ')}`") restore_bundler_environment end it 'prints warning when a bundler env variable not found' do stash_bundler_environment ENV['BUNDLE_GEMFILE'] = nil - should.raise(Informative) do + expect do Podfile.new do ensure_bundler! end - end.message.should == "CocoaPods was invoked from Global Gemset.\nPlease re-run using: `bundle exec pod #{ARGV.join(' ')}`" + end.to raise_error(Informative, "CocoaPods was invoked from Global Gemset.\nPlease re-run using: `bundle exec pod #{ARGV.join(' ')}`") restore_bundler_environment end @@ -725,7 +725,7 @@ def restore_bundler_environment ensure_bundler! end restore_bundler_environment - CoreUI.warnings.should.be.empty + expect(CoreUI.warnings).to be_empty end it 'prints version warning when version argument fails match' do @@ -733,11 +733,11 @@ def restore_bundler_environment ENV['BUNDLE_GEMFILE'] = 'mock argument' ENV['BUNDLE_BIN_PATH'] = 'another mock argument' ENV['BUNDLER_VERSION'] = '1.17.1' - should.raise(Informative) do + expect do Podfile.new do ensure_bundler! '2.0.0' end - end.message.should == 'The installed Bundler version: 1.17.1 does not match the required version: 2.0.0' + end.to raise_error(Informative, 'The installed Bundler version: 1.17.1 does not match the required version: 2.0.0') restore_bundler_environment end @@ -750,7 +750,7 @@ def restore_bundler_environment ensure_bundler! '~> 2.0.0' end restore_bundler_environment - CoreUI.warnings.should.be.empty + expect(CoreUI.warnings).to be_empty end it 'skips version check with missing bundle version (edge case)' do @@ -762,17 +762,17 @@ def restore_bundler_environment ensure_bundler! '2.0.0' end restore_bundler_environment - CoreUI.warnings.should.be.empty + expect(CoreUI.warnings).to be_empty end it 'raises with ensure_bundler! outside of root' do - should.raise(Informative) do + expect do Podfile.new do target 'App' do ensure_bundler! end end - end.message.should == 'The Ensure Bundler check can only be set at the root level of the Podfile.' + end.to raise_error(Informative, 'The Ensure Bundler check can only be set at the root level of the Podfile.') end end @@ -780,38 +780,38 @@ def restore_bundler_environment describe 'Deprecations' do it 'raises when using the #link_with method' do - should.raise(Informative) do + expect do Podfile.new do link_with 'App' end - end.message.should == 'The specification of `link_with` in the Podfile is now unsupported, please use target blocks instead.' + end.to raise_error(Informative, 'The specification of `link_with` in the Podfile is now unsupported, please use target blocks instead.') end it 'warns when using the #xcodeproj method' do podfile = Podfile.new { xcodeproj 'App.xcodeproj', 'Test' => :debug } - podfile.target_definitions['Pods'].user_project_path.should == 'App.xcodeproj' - podfile.target_definitions['Pods'].build_configurations.should == { 'Test' => :debug } - CoreUI.warnings.should == '`xcodeproj` was renamed to `project`. Please update your Podfile accordingly.' + expect(podfile.target_definitions['Pods'].user_project_path).to eq('App.xcodeproj') + expect(podfile.target_definitions['Pods'].build_configurations).to eq({ 'Test' => :debug }) + expect(CoreUI.warnings).to eq('`xcodeproj` was renamed to `project`. Please update your Podfile accordingly.') end end describe 'script phases' do it 'raises when adding a script phase to the root target definition' do - should.raise(Informative) do + expect do Podfile.new do script_phase :name => 'PhaseName', :script => 'echo "Hello World"' end - end.message.should == 'Script phases can only be added within target definitions.' + end.to raise_error(Informative, 'Script phases can only be added within target definitions.') end it 'raises when adding a script phase to an abstract target' do - should.raise(Informative) do + expect do Podfile.new do abstract_target 'AbstractTarget' do script_phase :name => 'PhaseName', :script => 'echo "Hello World"' end end - end.message.should == 'Script phases cannot be added to abstract targets.' + end.to raise_error(Informative, 'Script phases cannot be added to abstract targets.') end end diff --git a/spec/podfile/target_definition_spec.rb b/spec/podfile/target_definition_spec.rb index 0e81b3c58..3d51950b8 100644 --- a/spec/podfile/target_definition_spec.rb +++ b/spec/podfile/target_definition_spec.rb @@ -17,44 +17,44 @@ module Pod describe 'In general' do it 'returns its name' do - @parent.name.should == 'MyApp' + expect(@parent.name).to eq('MyApp') end it 'returns the parent' do - @root.parent.should == @podfile - @parent.parent.should == @root - @child.parent.should == @parent + expect(@root.parent).to eq(@podfile) + expect(@parent.parent).to eq(@root) + expect(@child.parent).to eq(@parent) end #--------------------------------------# it 'returns the children' do - @parent.children.should == [@child] - @child.children.should == [] + expect(@parent.children).to eq([@child]) + expect(@child.children).to eq([]) end it 'returns the recursive children' do @grand_child = Podfile::TargetDefinition.new('MyAppTests', @child) - @parent.recursive_children.should == [@child, @grand_child] - @child.recursive_children.should == [@grand_child] - @grand_child.recursive_children.should == [] + expect(@parent.recursive_children).to eq([@child, @grand_child]) + expect(@child.recursive_children).to eq([@grand_child]) + expect(@grand_child.recursive_children).to eq([]) end it 'returns whether it is root' do - @root.should.be.root - @parent.should.not.be.root - @child.should.not.be.root + expect(@root).to be_root + expect(@parent).not_to be_root + expect(@child).not_to be_root end it 'returns the root target definition' do - @root.root.should == @root - @parent.root.should == @root - @child.root.should == @root + expect(@root.root).to eq(@root) + expect(@parent.root).to eq(@root) + expect(@child.root).to eq(@root) end it 'returns the podfile that specifies it' do - @parent.podfile.class.should == Podfile - @child.podfile.class.should == Podfile + expect(@parent.podfile.class).to eq(Podfile) + expect(@child.podfile.class).to eq(Podfile) end it 'returns dependencies' do @@ -62,61 +62,61 @@ module Pod @parent.store_pod('BlocksKit') @child.store_pod('OCMockito') @child.inheritance = :complete - @parent.dependencies.map(&:name).should == %w(BlocksKit AFNetworking) - @child.dependencies.map(&:name).should == %w(OCMockito BlocksKit AFNetworking) + expect(@parent.dependencies.map(&:name)).to eq(%w(BlocksKit AFNetworking)) + expect(@child.dependencies.map(&:name)).to eq(%w(OCMockito BlocksKit AFNetworking)) end it "doesn't inherit dependencies if it is exclusive" do @parent.store_pod('BlocksKit') @child.store_pod('OCMockito') @child.inheritance = :none - @child.dependencies.map(&:name).should == %w(OCMockito) + expect(@child.dependencies.map(&:name)).to eq(%w(OCMockito)) end it 'returns the targets to inherit search paths from' do @child.inheritance = :search_paths - @child.targets_to_inherit_search_paths.should == [@parent] + expect(@child.targets_to_inherit_search_paths).to eq([@parent]) grandchild = Podfile::TargetDefinition.new('Grandchild', @child) - grandchild.targets_to_inherit_search_paths.should == [@parent] + expect(grandchild.targets_to_inherit_search_paths).to eq([@parent]) grandchild.inheritance = :search_paths - grandchild.targets_to_inherit_search_paths.should == [@parent, @child] + expect(grandchild.targets_to_inherit_search_paths).to eq([@parent, @child]) @child.inheritance = :complete - grandchild.targets_to_inherit_search_paths.should == [@child] + expect(grandchild.targets_to_inherit_search_paths).to eq([@child]) @child.inheritance = :none - grandchild.targets_to_inherit_search_paths.should == [@child] + expect(grandchild.targets_to_inherit_search_paths).to eq([@child]) end it 'returns the non inherited dependencies' do @parent.store_pod('BlocksKit') @child.store_pod('OCMockito') - @parent.non_inherited_dependencies.map(&:name).should == %w(BlocksKit) - @child.non_inherited_dependencies.map(&:name).should == %w(OCMockito) + expect(@parent.non_inherited_dependencies.map(&:name)).to eq(%w(BlocksKit)) + expect(@child.non_inherited_dependencies.map(&:name)).to eq(%w(OCMockito)) end it 'returns whether it is empty' do @parent.store_pod('BlocksKit') - @parent.should.not.be.empty - @child.should.be.empty + expect(@parent).not_to be_empty + expect(@child).to be_empty end it 'returns its label' do - @parent.label.should == 'Pods-MyApp' + expect(@parent.label).to eq('Pods-MyApp') end it 'returns `Pods` as the label if its name is default' do target_def = Podfile::TargetDefinition.new('Pods', @podfile) - target_def.label.should == 'Pods' + expect(target_def.label).to eq('Pods') end it 'includes the name of the parent in the label if any' do @child.inheritance = :complete - @child.label.should == 'Pods-MyApp-MyAppTests' + expect(@child.label).to eq('Pods-MyApp-MyAppTests') end it "doesn't include the name of the parent in the label if it is exclusive" do @child.inheritance = :none - @child.label.should == 'Pods-MyAppTests' + expect(@child.label).to eq('Pods-MyAppTests') end end @@ -124,669 +124,660 @@ module Pod describe 'Attributes accessors' do it 'is not abstract by default' do - @child.should.not.be.abstract + expect(@child).not_to be_abstract end it 'allows to set whether it is abstract' do @child.abstract = true - @child.should.be.abstract + expect(@child).to be_abstract end #--------------------------------------# it 'has complete inheritance by default' do - Podfile::TargetDefinition.new('App', nil).inheritance.should == 'complete' + expect(Podfile::TargetDefinition.new('App', nil).inheritance).to eq('complete') end it 'allows setting the inheritance' do @child.inheritance = :complete - @child.inheritance.should == 'complete' + expect(@child.inheritance).to eq('complete') @child.inheritance = :none - @child.inheritance.should == 'none' + expect(@child.inheritance).to eq('none') @child.inheritance = :search_paths - @child.inheritance.should == 'search_paths' + expect(@child.inheritance).to eq('search_paths') end it 'raises when setting an unknown inheritance mode' do - exception = should.raise(Informative) { @child.inheritance = :unknown } - exception.message.should == 'Unrecognized inheritance option `unknown` specified for target `MyAppTests`.' + expect { @child.inheritance = :unknown }.to raise_error(Informative, 'Unrecognized inheritance option `unknown` specified for target `MyAppTests`.') end it 'raises when setting an inheritance mode on a root target definition' do - exception = should.raise(Informative) { @root.inheritance = :none } - exception.message.should == 'Cannot set inheritance for the root target definition.' + expect { @root.inheritance = :none }.to raise_error(Informative, 'Cannot set inheritance for the root target definition.') end it 'raises when setting an inheritance mode on a abstract target definition' do - exception = should.raise(Informative) { @abstract.inheritance = :none } - exception.message.should == 'Cannot set inheritance for abstract target definition.' + expect { @abstract.inheritance = :none }.to raise_error(Informative, 'Cannot set inheritance for abstract target definition.') end #--------------------------------------# it 'is exclusive by default by the default if the platform of the parent match' do - @child.should.be.exclusive + expect(@child).to be_exclusive end it "is exclusive by the default if the platform of the parent doesn't match" do @parent.set_platform(:osx, '10.6') @child.set_platform(:ios, '6.0') - @child.should.be.exclusive + expect(@child).to be_exclusive end it 'allows to set whether it is exclusive' do @child.inheritance = :complete - @child.should.not.be.exclusive + expect(@child).not_to be_exclusive @child.inheritance = :none - @child.should.be.exclusive + expect(@child).to be_exclusive @child.inheritance = :search_paths - @child.should.be.exclusive + expect(@child).to be_exclusive end #--------------------------------------# it "doesn't specifies any user project by default" do - @parent.user_project_path.should.be.nil + expect(@parent.user_project_path).to be_nil end it 'allows to set the path of the user project' do @parent.user_project_path = 'some/path/project.xcodeproj' - @parent.user_project_path.should == 'some/path/project.xcodeproj' + expect(@parent.user_project_path).to eq('some/path/project.xcodeproj') end it 'appends the extension to a specified user project if needed' do @parent.user_project_path = 'some/path/project' - @parent.user_project_path.should == 'some/path/project.xcodeproj' + expect(@parent.user_project_path).to eq('some/path/project.xcodeproj') end it 'inherits the path of the user project from the parent' do @parent.user_project_path = 'some/path/project.xcodeproj' - @child.user_project_path.should == 'some/path/project.xcodeproj' + expect(@child.user_project_path).to eq('some/path/project.xcodeproj') end #--------------------------------------# it "doesn't specifies any project build configurations default" do - @parent.build_configurations.should.be.nil + expect(@parent.build_configurations).to be_nil end it 'allows to set the project build configurations' do @parent.build_configurations = { 'Debug' => :debug, 'Release' => :release } - @parent.build_configurations.should == { 'Debug' => :debug, 'Release' => :release } + expect(@parent.build_configurations).to eq({ 'Debug' => :debug, 'Release' => :release }) end it 'inherits the project build configurations from the parent' do @parent.build_configurations = { 'Debug' => :debug, 'Release' => :release } - @child.build_configurations.should == { 'Debug' => :debug, 'Release' => :release } + expect(@child.build_configurations).to eq({ 'Debug' => :debug, 'Release' => :release }) end #--------------------------------------# it "doesn't add extra subspec dependencies by default" do @parent.store_pod('RestKit') - @parent.dependencies.map(&:name).should == %w(RestKit) + expect(@parent.dependencies.map(&:name)).to eq(%w(RestKit)) end it 'allows depending on subspecs' do @parent.store_pod('RestKit', :subspecs => %w(Networking)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit/Networking) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit/Networking)) end it 'allows depending on testspecs' do @parent.store_pod('RestKit', :testspecs => %w(Tests)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit RestKit/Tests) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit RestKit/Tests)) end it 'allows depending on appspecs' do @parent.store_pod('RestKit', :appspecs => %w(App)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit RestKit/App) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit RestKit/App)) end it 'allows depending on both subspecs and testspecs' do @parent.store_pod('RestKit', :subspecs => %w(Networking)) @parent.store_pod('RestKit', :testspecs => %w(Tests)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit RestKit/Networking RestKit/Tests) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit RestKit/Networking RestKit/Tests)) end it 'allows depending on both subspecs and appspecs' do @parent.store_pod('RestKit', :subspecs => %w(Networking)) @parent.store_pod('RestKit', :appspecs => %w(App)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit RestKit/App RestKit/Networking) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit RestKit/App RestKit/Networking)) end it 'allows depending on subspecs, testspecs, and appspecs' do @parent.store_pod('RestKit', :subspecs => %w(Networking)) @parent.store_pod('RestKit', :testspecs => %w(Tests)) @parent.store_pod('RestKit', :appspecs => %w(App)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit RestKit RestKit/App RestKit/Networking RestKit/Tests) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit RestKit RestKit/App RestKit/Networking RestKit/Tests)) end it 'allows depending on both subspecs and testspecs in chaining' do @parent.store_pod('RestKit', :subspecs => %w(Networking), :testspecs => %w(Tests)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit/Networking RestKit/Tests) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit/Networking RestKit/Tests)) end it 'allows depending on both subspecs and appspecs in chaining' do @parent.store_pod('RestKit', :subspecs => %w(Networking), :appspecs => %w(App)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit/App RestKit/Networking) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit/App RestKit/Networking)) end it 'allows depending on subspecs, testspecs, and appspecs in chaining' do @parent.store_pod('RestKit', :subspecs => %w(Networking), :testspecs => %w(Tests), :appspecs => %w(App)) - @parent.dependencies.map(&:name).sort.should == %w(RestKit/App RestKit/Networking RestKit/Tests) + expect(@parent.dependencies.map(&:name).sort).to eq(%w(RestKit/App RestKit/Networking RestKit/Tests)) end #--------------------------------------# it "doesn't inhibit warnings per pod by default" do @parent.store_pod('ObjectiveSugar') - @parent.should.not.inhibits_warnings_for_pod?('ObjectiveSugar') + expect(@parent.inhibits_warnings_for_pod?('ObjectiveSugar')).to be_falsey end it 'inhibits warnings per pod if passed to store_pod' do @parent.store_pod('Objective-Record', :head, :inhibit_warnings => true) - @parent.should.inhibits_warnings_for_pod?('Objective-Record') + expect(@parent.inhibits_warnings_for_pod?('Objective-Record')).to be_truthy @parent.store_pod('RestKit/Networking', :head, :inhibit_warnings => true) - @parent.should.inhibits_warnings_for_pod?('RestKit') + expect(@parent.inhibits_warnings_for_pod?('RestKit')).to be_truthy end it 'does not inhibit warnings per pod if the option is false' do @parent.inhibit_all_warnings = true @parent.store_pod('ASIHTTPRequest', :inhibit_warnings => false) - @parent.should.not.inhibits_warnings_for_pod?('ASIHTTPRequest') + expect(@parent.inhibits_warnings_for_pod?('ASIHTTPRequest')).to be_falsey end it 'must delete the hash if it was empty. otherwise breaks Dependency' do reqs = [{ :inhibit_warnings => true }] @parent.send(:parse_inhibit_warnings, 'Objective-Record', reqs) - reqs.should.be.empty + expect(reqs).to be_empty end it 'returns if it should inhibit all warnings' do @parent.inhibit_all_warnings = true - @parent.should.inhibits_warnings_for_pod?('ObjectiveSugar') + expect(@parent.inhibits_warnings_for_pod?('ObjectiveSugar')).to be_truthy end it 'inherits the option to inhibit all warnings' do @parent.inhibit_all_warnings = true @child.store_pod('ASIHTTPRequest') - @child.should.inhibits_warnings_for_pod?('ASIHTTPRequest') + expect(@child.inhibits_warnings_for_pod?('ASIHTTPRequest')).to be_truthy end it 'inherits the option to inhibit warnings per pod' do @parent.store_pod('Objective-Record', :inhibit_warnings => true) - @child.should.inhibits_warnings_for_pod?('Objective-Record') + expect(@child.inhibits_warnings_for_pod?('Objective-Record')).to be_truthy end it 'inherits the false option to inhibit warnings per pod' do @parent.inhibit_all_warnings = true @child.store_pod('ASIHTTPRequest', :inhibit_warnings => false) - @child.should.not.inhibits_warnings_for_pod?('ASIHTTPRequest') + expect(@child.inhibits_warnings_for_pod?('ASIHTTPRequest')).to be_falsey end it 'overriding inhibition per pod in child should not affect parent' do @parent.store_pod('ASIHTTPRequest', :inhibit_warnings => true) @child.store_pod('ASIHTTPRequest', :inhibit_warnings => false) - @child.should.not.inhibits_warnings_for_pod?('ASIHTTPRequest') - @parent.should.inhibits_warnings_for_pod?('ASIHTTPRequest') + expect(@child.inhibits_warnings_for_pod?('ASIHTTPRequest')).to be_falsey + expect(@parent.inhibits_warnings_for_pod?('ASIHTTPRequest')).to be_truthy end #--------------------------------------# it "doesn't use modular headers per pod by default" do @parent.store_pod('ObjectiveSugar') - @parent.should.not.build_pod_as_module?('ObjectiveSugar') + expect(@parent.build_pod_as_module?('ObjectiveSugar')).to be_falsey end it 'uses modular headers per pod if passed to store_pod' do @parent.store_pod('Objective-Record', :head, :modular_headers => true) - @parent.should.build_pod_as_module?('Objective-Record') + expect(@parent.build_pod_as_module?('Objective-Record')).to be_truthy @parent.store_pod('RestKit/Networking', :head, :modular_headers => true) - @parent.should.build_pod_as_module?('RestKit') + expect(@parent.build_pod_as_module?('RestKit')).to be_truthy end it 'does not use modular headers per pod if the option is false' do @parent.use_modular_headers_for_all_pods = true @parent.store_pod('ASIHTTPRequest', :modular_headers => false) - @parent.should.not.build_pod_as_module?('ASIHTTPRequest') + expect(@parent.build_pod_as_module?('ASIHTTPRequest')).to be_falsey end it 'deletes the hash if empty' do reqs = [{ :modular_headers => true }] @parent.send(:parse_modular_headers, 'Objective-Record', reqs) - reqs.should.be.empty + expect(reqs).to be_empty end it 'returns if it should use modular headers for all pods' do @parent.use_modular_headers_for_all_pods = true - @parent.should.build_pod_as_module?('ObjectiveSugar') + expect(@parent.build_pod_as_module?('ObjectiveSugar')).to be_truthy end it 'inherits the option to use modular headers for all pods' do @parent.use_modular_headers_for_all_pods = true @child.store_pod('ASIHTTPRequest') - @child.should.build_pod_as_module?('ASIHTTPRequest') + expect(@child.build_pod_as_module?('ASIHTTPRequest')).to be_truthy end it 'inherits the option to use modular headers per pod' do @parent.store_pod('Objective-Record', :modular_headers => true) - @child.should.build_pod_as_module?('Objective-Record') + expect(@child.build_pod_as_module?('Objective-Record')).to be_truthy end it 'inherits the false option to use modular headers per pod' do @parent.use_modular_headers_for_all_pods = true @child.store_pod('ASIHTTPRequest', :modular_headers => false) - @child.should.not.build_pod_as_module?('ASIHTTPRequest') + expect(@child.build_pod_as_module?('ASIHTTPRequest')).to be_falsey end it 'overriding modular headers per pod in child should not affect parent' do @parent.store_pod('ASIHTTPRequest', :modular_headers => true) @child.store_pod('ASIHTTPRequest', :modular_headers => false) - @child.should.not.build_pod_as_module?('ASIHTTPRequest') - @parent.should.build_pod_as_module?('ASIHTTPRequest') + expect(@child.build_pod_as_module?('ASIHTTPRequest')).to be_falsey + expect(@parent.build_pod_as_module?('ASIHTTPRequest')).to be_truthy end #--------------------------------------# it 'stores the project name for a given pod' do @parent.store_pod('ASIHTTPRequest', :project_name => 'SomeProject') - @parent.project_name_for_pod('ASIHTTPRequest').should == 'SomeProject' - @parent.project_name_for_pod('UnknownPod').should.be.nil + expect(@parent.project_name_for_pod('ASIHTTPRequest')).to eq('SomeProject') + expect(@parent.project_name_for_pod('UnknownPod')).to be_nil end it 'inherits the project name option to use for a pod' do @parent.store_pod('ASIHTTPRequest', :project_name => 'SomeProject') - @child.project_name_for_pod('ASIHTTPRequest').should == 'SomeProject' + expect(@child.project_name_for_pod('ASIHTTPRequest')).to eq('SomeProject') end it 'honors the project name directly set from the target definition before delegating to parent' do @parent.store_pod('ASIHTTPRequest', :project_name => 'SomeProject') @child.store_pod('ASIHTTPRequest', :project_name => 'SomeOtherProject') - @child.project_name_for_pod('ASIHTTPRequest').should == 'SomeOtherProject' + expect(@child.project_name_for_pod('ASIHTTPRequest')).to eq('SomeOtherProject') end #--------------------------------------# it 'returns if it should use frameworks' do @parent.use_frameworks! - @parent.should.uses_frameworks? + expect(@parent.uses_frameworks?).to be_truthy end it 'returns it does not use frameworks if its explicitly specified' do @parent.use_frameworks!(false) - @parent.should.not.uses_frameworks? + expect(@parent.uses_frameworks?).to be_falsey end it 'returns if it should use frameworks by specifying static linkage' do @parent.use_frameworks!(:linkage => :static) - @parent.should.uses_frameworks? + expect(@parent.uses_frameworks?).to be_truthy end it 'returns if it should use frameworks by specifying dynamic linkage' do @parent.use_frameworks!(:linkage => :dynamic) - @parent.should.uses_frameworks? + expect(@parent.uses_frameworks?).to be_truthy end it 'raises when an invalid type is used' do - e = lambda { @parent.use_frameworks!(1) }.should.raise ArgumentError - e.message.should == 'Got `1`, should be a boolean or hash.' + expect { @parent.use_frameworks!(1) }.to raise_error(ArgumentError, 'Got `1`, should be a boolean or hash.') end it 'inherits the option to use frameworks' do @parent.use_frameworks! - @child.should.uses_frameworks? + expect(@child.uses_frameworks?).to be_truthy end it 'allows children to opt-out of using frameworks' do @parent.use_frameworks! @child.use_frameworks!(false) - @child.should.not.uses_frameworks? + expect(@child.uses_frameworks?).to be_falsey # make sure that the value is not accidentally overwritten on access - @child.should.not.uses_frameworks? + expect(@child.uses_frameworks?).to be_falsey end it 'returns the default build type' do - @parent.build_type.should == BuildType.static_library + expect(@parent.build_type).to eq(BuildType.static_library) end it 'returns the default frameworks build type' do @parent.use_frameworks! - @parent.build_type.should == BuildType.dynamic_framework + expect(@parent.build_type).to eq(BuildType.dynamic_framework) end it 'returns the configured dynamic framework build type' do @parent.use_frameworks!(:linkage => :dynamic) - @parent.build_type.should == BuildType.dynamic_framework + expect(@parent.build_type).to eq(BuildType.dynamic_framework) end it 'returns the configured static framework build type' do @parent.use_frameworks!(:linkage => :static) - @parent.build_type.should == BuildType.static_framework + expect(@parent.build_type).to eq(BuildType.static_framework) end it 'inherits the build type' do @parent.use_frameworks! - @child.build_type.should == BuildType.dynamic_framework + expect(@child.build_type).to eq(BuildType.dynamic_framework) end #--------------------------------------# it 'raises if script phase is missing required key' do - e = lambda { @parent.store_script_phase(:name => 'PhaseName') }.should.raise Podfile::StandardError - e.message.should == 'Missing required shell script phase options `script`' + expect { @parent.store_script_phase(:name => 'PhaseName') }.to raise_error(Podfile::StandardError, 'Missing required shell script phase options `script`') end it 'raises if script phase includes an unrecognized key' do - e = lambda { @parent.store_script_phase(:name => 'PhaseName', :unknown => 'Unknown') }.should.raise Podfile::StandardError - e.message.should == 'Unrecognized options `[:unknown]` in shell script `PhaseName` within `MyApp` target. ' \ + expect do + @parent.store_script_phase(:name => 'PhaseName', :unknown => 'Unknown') + end.to raise_error(Podfile::StandardError, 'Unrecognized options `[:unknown]` in shell script `PhaseName` within `MyApp` target. ' \ 'Available options are `[:name, :script, :shell_path, :input_files, :output_files, :input_file_lists, ' \ - ':output_file_lists, :show_env_vars_in_log, :execution_position, :dependency_file, :always_out_of_date]`.' + ':output_file_lists, :show_env_vars_in_log, :execution_position, :dependency_file, :always_out_of_date]`.') end it 'raises if script phase includes an invalid execution position key' do - e = lambda { @parent.store_script_phase(:name => 'PhaseName', :script => 'echo "Hello World"', :execution_position => :unknown) }.should.raise Podfile::StandardError - e.message.should == 'Invalid execution position value `unknown` in shell script `PhaseName` within `MyApp` target. ' \ - 'Available options are `[:before_compile, :after_compile, :before_headers, :after_headers, :any]`.' + expect do + @parent.store_script_phase(:name => 'PhaseName', :script => 'echo "Hello World"', :execution_position => :unknown) + end.to raise_error(Podfile::StandardError, 'Invalid execution position value `unknown` in shell script `PhaseName` within `MyApp` target. ' \ + 'Available options are `[:before_compile, :after_compile, :before_headers, :after_headers, :any]`.') end it 'raises if the same script phase name already exists' do - e = lambda do + expect do @parent.store_script_phase(:name => 'PhaseName', :script => 'echo "Hello World"') @parent.store_script_phase(:name => 'PhaseName', :script => 'echo "Hello World"') - end.should.raise Podfile::StandardError - e.message.should == 'Script phase with name `PhaseName` name already present for target `MyApp`.' + end.to raise_error(Podfile::StandardError, 'Script phase with name `PhaseName` name already present for target `MyApp`.') end it 'stores a script phase if requirements are provided' do @parent.store_script_phase(:name => 'PhaseName', :script => 'echo "Hello World"') - @parent.script_phases.should == [ + expect(@parent.script_phases).to eq([ { :name => 'PhaseName', :script => 'echo "Hello World"', :execution_position => :any }, - ] + ]) end it 'stores a script phase with requirements and optional keys' do @parent.store_script_phase(:name => 'PhaseName', :script => 'echo "Hello World"', :shell_path => '/usr/bin/ruby') - @parent.script_phases.should == [ + expect(@parent.script_phases).to eq([ { :name => 'PhaseName', :script => 'echo "Hello World"', :shell_path => '/usr/bin/ruby', :execution_position => :any }, - ] + ]) end it 'stores a script phase with a specified execution position value' do @parent.store_script_phase(:name => 'PhaseName', :script => 'echo "Hello World"', :shell_path => '/usr/bin/ruby', :execution_position => :before_compile) - @parent.script_phases.should == [ + expect(@parent.script_phases).to eq([ { :name => 'PhaseName', :script => 'echo "Hello World"', :shell_path => '/usr/bin/ruby', :execution_position => :before_compile }, - ] + ]) end #--------------------------------------# it 'whitelists pods by default' do @parent.store_pod('ObjectiveSugar') - @parent.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') - @child.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release')).to be_truthy + expect(@child.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release')).to be_truthy end it 'does not enable pods for un-whitelisted configurations if it is whitelisted for another' do @parent.store_pod('ObjectiveSugar') @parent.whitelist_pod_for_configuration('ObjectiveSugar', 'Release') - @parent.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') - @child.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug')).to be_falsey + expect(@child.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug')).to be_falsey end it 'enables pods for configurations they are whitelisted for' do @parent.store_pod('ObjectiveSugar', :configuration => 'Release') - @parent.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') - @parent.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') - @child.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') - @child.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug')).to be_falsey + expect(@child.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release')).to be_truthy + expect(@child.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug')).to be_falsey @parent.store_pod('AFNetworking', :configurations => ['Debug']) - @parent.should.pod_whitelisted_for_configuration?('AFNetworking', 'Debug') - @parent.should.not.pod_whitelisted_for_configuration?('AFNetworking', 'Release') - @child.should.pod_whitelisted_for_configuration?('AFNetworking', 'Debug') - @child.should.not.pod_whitelisted_for_configuration?('AFNetworking', 'Release') + expect(@parent.pod_whitelisted_for_configuration?('AFNetworking', 'Debug')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('AFNetworking', 'Release')).to be_falsey + expect(@child.pod_whitelisted_for_configuration?('AFNetworking', 'Debug')).to be_truthy + expect(@child.pod_whitelisted_for_configuration?('AFNetworking', 'Release')).to be_falsey end it 'child pods for configurations can merge from parent' do @parent.store_pod('ObjectiveSugar', :configuration => 'Release') @child.store_pod('AFNetworking', :configuration => 'Release') - @parent.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') - @parent.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') - @child.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') - @child.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') - @child.should.pod_whitelisted_for_configuration?('AFNetworking', 'Release') - @child.should.not.pod_whitelisted_for_configuration?('AFNetworking', 'Debug') + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug')).to be_falsey + expect(@child.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release')).to be_truthy + expect(@child.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug')).to be_falsey + expect(@child.pod_whitelisted_for_configuration?('AFNetworking', 'Release')).to be_truthy + expect(@child.pod_whitelisted_for_configuration?('AFNetworking', 'Debug')).to be_falsey end it 'coerces configuration names to strings' do @parent.store_pod('ObjectiveSugar', :configuration => :Release) - @parent.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') - @parent.should.not.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug') + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Debug')).to be_falsey end it 'compares build configurations case-insensitively' do @parent.store_pod('ObjectiveSugar', :configuration => :Release) - @parent.should.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release') - @parent.should.pod_whitelisted_for_configuration?('objectivesugar', 'Release') + expect(@parent.pod_whitelisted_for_configuration?('ObjectiveSugar', 'Release')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('objectivesugar', 'Release')).to be_truthy end it 'returns a unique list of all whitelisted configurations' do - @root.all_whitelisted_configurations.should == [] + expect(@root.all_whitelisted_configurations).to eq([]) @root.whitelist_pod_for_configuration('ObjectiveSugar', 'Release') @root.whitelist_pod_for_configuration('AFNetworking', 'Release') - @root.all_whitelisted_configurations.should == ['Release'] - @child.all_whitelisted_configurations.should == ['Release'] + expect(@root.all_whitelisted_configurations).to eq(['Release']) + expect(@child.all_whitelisted_configurations).to eq(['Release']) @root.whitelist_pod_for_configuration('Objective-Record', 'Debug') - @root.all_whitelisted_configurations.sort.should == %w(Debug Release) - @child.all_whitelisted_configurations.sort.should == %w(Debug Release) + expect(@root.all_whitelisted_configurations.sort).to eq(%w(Debug Release)) + expect(@child.all_whitelisted_configurations.sort).to eq(%w(Debug Release)) end it 'whitelists pod configurations with testspecs' do @parent.build_configurations = { 'Debug' => :debug, 'Release' => :release } @parent.store_pod('RestKit', :testspecs => %w(Tests), :configuration => 'Debug') - @parent.should.pod_whitelisted_for_configuration?('RestKit', 'Debug') - @parent.should.pod_whitelisted_for_configuration?('RestKit/Tests', 'Debug') - @parent.should.not.pod_whitelisted_for_configuration?('RestKit', 'Release') - @parent.should.not.pod_whitelisted_for_configuration?('RestKit/Tests', 'Release') + expect(@parent.pod_whitelisted_for_configuration?('RestKit', 'Debug')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('RestKit/Tests', 'Debug')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('RestKit', 'Release')).to be_falsey + expect(@parent.pod_whitelisted_for_configuration?('RestKit/Tests', 'Release')).to be_falsey end it 'whitelists pod configurations with appspecs' do @parent.build_configurations = { 'Debug' => :debug, 'Release' => :release } @parent.store_pod('RestKit', :appspecs => %w(App), :configuration => 'Debug') - @parent.should.pod_whitelisted_for_configuration?('RestKit', 'Debug') - @parent.should.pod_whitelisted_for_configuration?('RestKit/App', 'Debug') - @parent.should.not.pod_whitelisted_for_configuration?('RestKit', 'Release') - @parent.should.not.pod_whitelisted_for_configuration?('RestKit/App', 'Release') + expect(@parent.pod_whitelisted_for_configuration?('RestKit', 'Debug')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('RestKit/App', 'Debug')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('RestKit', 'Release')).to be_falsey + expect(@parent.pod_whitelisted_for_configuration?('RestKit/App', 'Release')).to be_falsey end it 'whitelists pod configurations with appspecs and testspecs' do @parent.build_configurations = { 'Debug' => :debug, 'Release' => :release } @parent.store_pod('RestKit', :testspecs => %w(Tests), :configuration => 'Debug') @parent.store_pod('RestKit', :appspecs => %w(App), :configuration => 'Debug') - @parent.should.pod_whitelisted_for_configuration?('RestKit', 'Debug') - @parent.should.pod_whitelisted_for_configuration?('RestKit/App', 'Debug') - @parent.should.pod_whitelisted_for_configuration?('RestKit/Tests', 'Debug') - @parent.should.not.pod_whitelisted_for_configuration?('RestKit', 'Release') - @parent.should.not.pod_whitelisted_for_configuration?('RestKit/App', 'Release') - @parent.should.not.pod_whitelisted_for_configuration?('RestKit/Tests', 'Release') + expect(@parent.pod_whitelisted_for_configuration?('RestKit', 'Debug')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('RestKit/App', 'Debug')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('RestKit/Tests', 'Debug')).to be_truthy + expect(@parent.pod_whitelisted_for_configuration?('RestKit', 'Release')).to be_falsey + expect(@parent.pod_whitelisted_for_configuration?('RestKit/App', 'Release')).to be_falsey + expect(@parent.pod_whitelisted_for_configuration?('RestKit/Tests', 'Release')).to be_falsey end #--------------------------------------# it 'returns its platform' do - @parent.platform.should == Pod::Platform.new(:ios, '6.0') + expect(@parent.platform).to eq(Pod::Platform.new(:ios, '6.0')) end it 'inherits the platform form the parent' do - @parent.platform.should == Pod::Platform.new(:ios, '6.0') + expect(@parent.platform).to eq(Pod::Platform.new(:ios, '6.0')) end it 'provides a default deployment target if not specified' do @parent.set_platform(:ios) - @parent.platform.should == Pod::Platform.new(:ios, '4.3') + expect(@parent.platform).to eq(Pod::Platform.new(:ios, '4.3')) @parent.set_platform(:osx) - @parent.platform.should == Pod::Platform.new(:osx, '10.6') + expect(@parent.platform).to eq(Pod::Platform.new(:osx, '10.6')) end it 'raises if the specified platform is unsupported' do - e = lambda { @parent.set_platform(:win) }.should.raise Podfile::StandardError - e.message.should.match /Unsupported platform/ + expect { @parent.set_platform(:win) }.to raise_error(Podfile::StandardError, /Unsupported platform/) end #--------------------------------------# it 'returns nil for swift_version by default' do - @parent.swift_version.should.nil? + expect(@parent.swift_version).to be_nil end it 'allows you to set the swift_version' do @parent.swift_version = '2.3' - @parent.swift_version.should == '2.3' + expect(@parent.swift_version).to eq('2.3') end it 'stores a single swift version requirement' do @parent.store_swift_version_requirements('3.0') - @parent.send(:get_hash_value, 'swift_version_requirements').should == [ + expect(@parent.send(:get_hash_value, 'swift_version_requirements')).to eq([ '3.0', - ] + ]) end it 'stores swift version requirements as strings' do @parent.store_swift_version_requirements('>= 3.0', '< 4.0') - @parent.send(:get_hash_value, 'swift_version_requirements').should == [ + expect(@parent.send(:get_hash_value, 'swift_version_requirements')).to eq([ '>= 3.0', '< 4.0', - ] + ]) end it 'stores swift version requirements as an array of strings' do @parent.store_swift_version_requirements(['>= 3.0', '< 4.0']) - @parent.send(:get_hash_value, 'swift_version_requirements').should == [ + expect(@parent.send(:get_hash_value, 'swift_version_requirements')).to eq([ '>= 3.0', '< 4.0', - ] + ]) end it 'stores swift version requirements as versions' do @parent.store_swift_version_requirements(Version.new('3.0'), Version.new('4.0')) - @parent.send(:get_hash_value, 'swift_version_requirements').should == [ + expect(@parent.send(:get_hash_value, 'swift_version_requirements')).to eq([ '3.0', '4.0', - ] + ]) end it 'correctly returns whether a version of Swift is supported based on requirements' do @parent.store_swift_version_requirements('>= 3.0', '< 4.0') - @parent.supports_swift_version?(Version.new('1.0')).should.be.false - @parent.supports_swift_version?(Version.new('2.0')).should.be.false - @parent.supports_swift_version?(Version.new('3.0')).should.be.true - @parent.supports_swift_version?(Version.new('3.2')).should.be.true - @parent.supports_swift_version?(Version.new('4.0')).should.be.false + expect(@parent.supports_swift_version?(Version.new('1.0'))).to be(false) + expect(@parent.supports_swift_version?(Version.new('2.0'))).to be(false) + expect(@parent.supports_swift_version?(Version.new('3.0'))).to be(true) + expect(@parent.supports_swift_version?(Version.new('3.2'))).to be(true) + expect(@parent.supports_swift_version?(Version.new('4.0'))).to be(false) end it 'correclty returns whether a version of Swift is supported based on Version requirements' do @parent.store_swift_version_requirements(Version.new('3.0')) - @parent.supports_swift_version?(Version.new('1.0')).should.be.false - @parent.supports_swift_version?(Version.new('2.0')).should.be.false - @parent.supports_swift_version?(Version.new('3.0')).should.be.true - @parent.supports_swift_version?(Version.new('3.2')).should.be.false - @parent.supports_swift_version?(Version.new('4.0')).should.be.false + expect(@parent.supports_swift_version?(Version.new('1.0'))).to be(false) + expect(@parent.supports_swift_version?(Version.new('2.0'))).to be(false) + expect(@parent.supports_swift_version?(Version.new('3.0'))).to be(true) + expect(@parent.supports_swift_version?(Version.new('3.2'))).to be(false) + expect(@parent.supports_swift_version?(Version.new('4.0'))).to be(false) end it 'delegates to the parent for Swift version support if current target does not specify requirements' do @parent.store_swift_version_requirements('>= 3.0', '< 4.0') - @child.supports_swift_version?(Version.new('1.0')).should.be.false - @child.supports_swift_version?(Version.new('2.0')).should.be.false - @child.supports_swift_version?(Version.new('3.0')).should.be.true - @child.supports_swift_version?(Version.new('3.2')).should.be.true - @child.supports_swift_version?(Version.new('4.0')).should.be.false + expect(@child.supports_swift_version?(Version.new('1.0'))).to be(false) + expect(@child.supports_swift_version?(Version.new('2.0'))).to be(false) + expect(@child.supports_swift_version?(Version.new('3.0'))).to be(true) + expect(@child.supports_swift_version?(Version.new('3.2'))).to be(true) + expect(@child.supports_swift_version?(Version.new('4.0'))).to be(false) end it 'returns the Swift version supported of the current target definition if specified' do @child.store_swift_version_requirements('>= 4.0') @parent.store_swift_version_requirements('>= 3.0', '< 4.0') - @child.supports_swift_version?(Version.new('1.0')).should.be.false - @child.supports_swift_version?(Version.new('2.0')).should.be.false - @child.supports_swift_version?(Version.new('3.0')).should.be.false - @child.supports_swift_version?(Version.new('3.2')).should.be.false - @child.supports_swift_version?(Version.new('4.0')).should.be.true - @child.supports_swift_version?(Version.new('4.2')).should.be.true + expect(@child.supports_swift_version?(Version.new('1.0'))).to be(false) + expect(@child.supports_swift_version?(Version.new('2.0'))).to be(false) + expect(@child.supports_swift_version?(Version.new('3.0'))).to be(false) + expect(@child.supports_swift_version?(Version.new('3.2'))).to be(false) + expect(@child.supports_swift_version?(Version.new('4.0'))).to be(true) + expect(@child.supports_swift_version?(Version.new('4.2'))).to be(true) end it 'accepts all Swift versions if no requirements are specified' do - @parent.supports_swift_version?(Version.new('1.0')).should.be.true - @parent.supports_swift_version?(Version.new('2.0')).should.be.true - @parent.supports_swift_version?(Version.new('3.0')).should.be.true - @parent.supports_swift_version?(Version.new('3.2')).should.be.true - @parent.supports_swift_version?(Version.new('4.0')).should.be.true + expect(@parent.supports_swift_version?(Version.new('1.0'))).to be(true) + expect(@parent.supports_swift_version?(Version.new('2.0'))).to be(true) + expect(@parent.supports_swift_version?(Version.new('3.0'))).to be(true) + expect(@parent.supports_swift_version?(Version.new('3.2'))).to be(true) + expect(@parent.supports_swift_version?(Version.new('4.0'))).to be(true) end #--------------------------------------# it 'stores a dependency on a pod as a sting if no requirements are provided' do @parent.store_pod('BlocksKit') - @parent.send(:get_hash_value, 'dependencies').should == [ + expect(@parent.send(:get_hash_value, 'dependencies')).to eq([ 'BlocksKit', - ] + ]) end it 'stores a dependency on a pod as a hash if requirements provided' do @parent.store_pod('Reachability', '1.0') - @parent.send(:get_hash_value, 'dependencies').should == [ + expect(@parent.send(:get_hash_value, 'dependencies')).to eq([ { 'Reachability' => ['1.0'] }, - ] + ]) end #--------------------------------------# it 'stores a dependency on a podspec' do @parent.store_podspec(:name => 'BlocksKit') - @parent.send(:get_hash_value, 'podspecs').should == [ + expect(@parent.send(:get_hash_value, 'podspecs')).to eq([ { :name => 'BlocksKit' }, - ] + ]) end it 'stores a dependency on a podspec and sets is as auto-detect if no options are provided' do @parent.store_podspec - @parent.send(:get_hash_value, 'podspecs').should == [ + expect(@parent.send(:get_hash_value, 'podspecs')).to eq([ { :autodetect => true }, - ] + ]) end it 'stores a dependency on a podspec\'s subspec' do @parent.store_podspec(:subspec => 'Subspec') - @parent.send(:get_hash_value, 'podspecs').should == [ + expect(@parent.send(:get_hash_value, 'podspecs')).to eq([ { :autodetect => true, :subspec => 'Subspec', }, - ] + ]) end it 'stores a dependency on a podspec\'s subspecs' do @parent.store_podspec(:subspecs => ['Subspec']) - @parent.send(:get_hash_value, 'podspecs').should == [ + expect(@parent.send(:get_hash_value, 'podspecs')).to eq([ { :autodetect => true, :subspecs => ['Subspec'], }, - ] + ]) end it 'raises if the provided podspec option type is error' do - e = lambda { @parent.store_podspec(:subspec => 123) }.should.raise Podfile::StandardError - e.message.should.match /should be a String/ + expect { @parent.store_podspec(:subspec => 123) }.to raise_error(Podfile::StandardError, /should be a String/) - e = lambda { @parent.store_podspec(:subspecs => 123) }.should.raise Podfile::StandardError - e.message.should.match /should be an Array of Strings/ + expect { @parent.store_podspec(:subspecs => 123) }.to raise_error(Podfile::StandardError, /should be an Array of Strings/) - e = lambda { @parent.store_podspec(:subspecs => ['a', 123]) }.should.raise Podfile::StandardError - e.message.should.match /should be an Array of Strings/ + expect { @parent.store_podspec(:subspecs => ['a', 123]) }.to raise_error(Podfile::StandardError, /should be an Array of Strings/) end it 'raises if the provided podspec options are unsupported' do - e = lambda { @parent.store_podspec(:invent => 'BlocksKit') }.should.raise Podfile::StandardError - e.message.should.match /Unrecognized options/ + expect { @parent.store_podspec(:invent => 'BlocksKit') }.to raise_error(Podfile::StandardError, /Unrecognized options/) end end @@ -796,20 +787,20 @@ module Pod it 'returns the hash representation' do @child.store_pod('BlocksKit') @child.set_platform(:ios) - @child.to_hash.should == { + expect(@child.to_hash).to eq({ 'name' => 'MyAppTests', 'abstract' => false, 'inheritance' => 'search_paths', 'dependencies' => ['BlocksKit'], 'platform' => 'ios', - } + }) end it 'stores the children in the hash representation' do Podfile::TargetDefinition.new('MoarTests', @parent) @parent.store_pod('BlocksKit') @child.store_pod('RestKit') - @parent.to_hash.should == { + expect(@parent.to_hash).to eq({ 'name' => 'MyApp', 'platform' => { 'ios' => '6.0' }, 'dependencies' => ['BlocksKit'], @@ -824,14 +815,14 @@ module Pod 'name' => 'MoarTests', }, ], - } + }) end it 'can be initialized from a hash' do @parent.store_pod('BlocksKit') @child.store_pod('RestKit') converted = Podfile::TargetDefinition.from_hash(@parent.to_hash, @podfile) - converted.to_hash.should == @parent.to_hash + expect(converted.to_hash).to eq(@parent.to_hash) end end @@ -846,19 +837,19 @@ module Pod it 'sets and retrieves a value in the internal hash' do @parent.send(:set_hash_value, 'name', 'Fabio') - @parent.send(:get_hash_value, 'name').should.equal 'Fabio' + expect(@parent.send(:get_hash_value, 'name')).to eq('Fabio') end it 'raises if there is an attempt to access or set an unknown key in the internal hash' do - lambda { @parent.send(:set_hash_value, 'unknown', true) }.should.raise Pod::Podfile::StandardError - lambda { @parent.send(:get_hash_value, 'unknown') }.should.raise Pod::Podfile::StandardError + expect { @parent.send(:set_hash_value, 'unknown', true) }.to raise_error(Pod::Podfile::StandardError) + expect { @parent.send(:get_hash_value, 'unknown') }.to raise_error(Pod::Podfile::StandardError) end it 'returns the dependencies specified by the user' do @parent.store_pod('BlocksKit') @parent.store_pod('AFNetworking', '1.0') dependencies = @parent.send(:pod_dependencies) - dependencies.map(&:to_s).should == ['BlocksKit', 'AFNetworking (= 1.0)'] + expect(dependencies.map(&:to_s)).to eq(['BlocksKit', 'AFNetworking (= 1.0)']) end #--------------------------------------# @@ -866,30 +857,30 @@ module Pod describe '#pod_dependencies' do it 'handles dependencies which only indicate the name of the Pod' do @parent.store_pod('BlocksKit') - @parent.send(:pod_dependencies).should == [ + expect(@parent.send(:pod_dependencies)).to eq([ Dependency.new('BlocksKit'), - ] + ]) end it 'handles requirements' do @parent.store_pod('BlocksKit', '> 1.0', '< 2.5') - @parent.send(:pod_dependencies).should == [ + expect(@parent.send(:pod_dependencies)).to eq([ Dependency.new('BlocksKit', ['> 1.0', '< 2.5']), - ] + ]) end it 'handles subspecs' do @parent.store_pod('Spec/Subspec') - @parent.send(:pod_dependencies).should == [ + expect(@parent.send(:pod_dependencies)).to eq([ Dependency.new('Spec/Subspec'), - ] + ]) end it 'handles dependencies options' do @parent.store_pod('BlocksKit', :git => 'GIT-URL', :commit => '1234') - @parent.send(:pod_dependencies).should == [ + expect(@parent.send(:pod_dependencies)).to eq([ Dependency.new('BlocksKit', :git => 'GIT-URL', :commit => '1234'), - ] + ]) end end @@ -899,20 +890,20 @@ module Pod it 'returns the dependencies of podspecs' do path = SpecHelper::Fixture.fixture('BananaLib.podspec').to_s @parent.store_podspec(:path => path) - @parent.send(:podspec_dependencies).should == [ + expect(@parent.send(:podspec_dependencies)).to eq([ Dependency.new('monkey', '< 1.0.9', '~> 1.0.1'), Dependency.new('AFNetworking'), Dependency.new('SDWebImage'), - ] + ]) end it 'returns the dependencies of a subspec' do path = SpecHelper::Fixture.fixture('BananaLib.podspec').to_s @parent.store_podspec(:path => path, :subspec => 'GreenBanana') - @parent.send(:podspec_dependencies).should == [ + expect(@parent.send(:podspec_dependencies)).to eq([ Dependency.new('monkey', '< 1.0.9', '~> 1.0.1'), Dependency.new('AFNetworking'), - ] + ]) end it 'reject the dependencies on subspecs' do @@ -922,9 +913,9 @@ module Pod internal_dep = Dependency.new('BananaLib/subspec') deps = [external_dep, internal_dep] Specification.any_instance.stubs(:dependencies).returns([deps]) - @parent.send(:podspec_dependencies).should == [ + expect(@parent.send(:podspec_dependencies)).to eq([ Dependency.new('monkey', '< 1.0.9', '~> 1.0.1'), - ] + ]) end end @@ -934,57 +925,56 @@ module Pod it 'resolves a podspec given the absolute path' do options = { :path => SpecHelper::Fixture.fixture('BananaLib') } file = @parent.send(:podspec_path_from_options, options) - file.should == SpecHelper::Fixture.fixture('BananaLib.podspec') + expect(file).to eq(SpecHelper::Fixture.fixture('BananaLib.podspec')) end it 'resolves a podspec given the relative path' do options = { :path => 'BananaLib.podspec' } file = @parent.send(:podspec_path_from_options, options) - file.should == SpecHelper::Fixture.fixture('BananaLib.podspec') + expect(file).to eq(SpecHelper::Fixture.fixture('BananaLib.podspec')) end it 'add the extension if needed' do options = { :path => 'BananaLib' } file = @parent.send(:podspec_path_from_options, options) - file.should == SpecHelper::Fixture.fixture('BananaLib.podspec') + expect(file).to eq(SpecHelper::Fixture.fixture('BananaLib.podspec')) end it "doesn't add an extension for json podspecs" do options = { :path => 'BananaLib.podspec.json' } file = @parent.send(:podspec_path_from_options, options) - file.should == SpecHelper::Fixture.fixture('BananaLib.podspec.json') + expect(file).to eq(SpecHelper::Fixture.fixture('BananaLib.podspec.json')) end it 'it expands the tilde in the provided path' do home_dir = File.expand_path('~') options = { :path => '~/BananaLib.podspec' } file = @parent.send(:podspec_path_from_options, options) - file.should == Pathname.new("#{home_dir}/BananaLib.podspec") + expect(file).to eq(Pathname.new("#{home_dir}/BananaLib.podspec")) end it 'resolves a podspec given its name' do options = { :name => 'BananaLib' } file = @parent.send(:podspec_path_from_options, options) - file.should == SpecHelper::Fixture.fixture('BananaLib.podspec') + expect(file).to eq(SpecHelper::Fixture.fixture('BananaLib.podspec')) end it "doesn't add an extension for json podspecs" do options = { :name => 'BananaLib.podspec.json' } file = @parent.send(:podspec_path_from_options, options) - file.should == SpecHelper::Fixture.fixture('BananaLib.podspec.json') + expect(file).to eq(SpecHelper::Fixture.fixture('BananaLib.podspec.json')) end it 'auto-detects the podspec' do options = { :autodetect => true } file = @parent.send(:podspec_path_from_options, options) - file.should == SpecHelper::Fixture.fixture('BananaLib.podspec') + expect(file).to eq(SpecHelper::Fixture.fixture('BananaLib.podspec')) end it 'raise an Informative error if the podspec cannot be auto-detected' do @parent.podfile.defined_in_file = SpecHelper::Fixture.fixture('podfile_without_root_podspec/Podfile') options = { :autodetect => true } - e = lambda { @parent.send(:podspec_path_from_options, options) }.should.raise Pod::Informative - e.message.should.match /Could not locate a podspec in the/ + expect { @parent.send(:podspec_path_from_options, options) }.to raise_error(Pod::Informative, /Could not locate a podspec in the/) end end end diff --git a/spec/podfile_spec.rb b/spec/podfile_spec.rb index 85227a832..57ead1043 100644 --- a/spec/podfile_spec.rb +++ b/spec/podfile_spec.rb @@ -5,33 +5,33 @@ module Pod describe 'In general' do it 'stores the path of the file it is loaded from' do podfile = Podfile.from_file(fixture('Podfile')) - podfile.defined_in_file.should == fixture('Podfile') + expect(podfile.defined_in_file).to eq(fixture('Podfile')) end it 'returns the string representation' do - Podfile.new {}.to_s.should == 'Podfile' + expect(Podfile.new {}.to_s).to eq('Podfile') end it 'creates a default target definition if a block is provided' do podfile = Podfile.new {} - podfile.root_target_definitions.count.should == 1 - podfile.root_target_definitions.first.name.should == 'Pods' + expect(podfile.root_target_definitions.count).to eq(1) + expect(podfile.root_target_definitions.first.name).to eq('Pods') end it 'names the default target definition as Pods' do podfile = Podfile.new {} - podfile.root_target_definitions.first.name.should == 'Pods' + expect(podfile.root_target_definitions.first.name).to eq('Pods') end it 'is equatable' do - Podfile.new.should == Podfile.new + expect(Podfile.new).to eq(Podfile.new) - Podfile.from_file(fixture('Podfile')).should == Podfile.from_file(fixture('Podfile')) - Podfile.from_file(fixture('Podfile')).should == Podfile.from_file(fixture('Podfile')).tap { |pf| pf.defined_in_file = Pathname('foo') } - Podfile.from_file(fixture('Podfile')).should == Podfile.from_file(fixture('Podfile.yaml')) + expect(Podfile.from_file(fixture('Podfile'))).to eq(Podfile.from_file(fixture('Podfile'))) + expect(Podfile.from_file(fixture('Podfile'))).to eq(Podfile.from_file(fixture('Podfile')).tap { |pf| pf.defined_in_file = Pathname('foo') }) + expect(Podfile.from_file(fixture('Podfile'))).to eq(Podfile.from_file(fixture('Podfile.yaml'))) - Podfile.from_file(fixture('Podfile')).should.not == Podfile.new - Podfile.from_file(fixture('Podfile')).should.not == Podfile.from_ruby(fixture('Podfile'), fixture('Podfile').read.gsub(/pod '/, "pod 'A_")) + expect(Podfile.from_file(fixture('Podfile'))).not_to eq(Podfile.new) + expect(Podfile.from_file(fixture('Podfile'))).not_to eq(Podfile.from_ruby(fixture('Podfile'), fixture('Podfile').read.gsub(/pod '/, "pod 'A_"))) end extend SpecHelper::TemporaryDirectory @@ -45,11 +45,11 @@ module Pod Podfile.from_file(podfile_file) rescue DSLError => e raised = true - e.message.should.match %r{from .*/tmp/Podfile:3} - e.message.should.match /requires a name/ - e.message.should.match /# Comment/ + expect(e.message).to match(%r{from .*/tmp/Podfile:3}) + expect(e.message).to match(/requires a name/) + expect(e.message).to match(/# Comment/) end - raised.should.be.true + expect(raised).to be(true) end end @@ -69,41 +69,41 @@ module Pod end it 'returns the string representation' do - @podfile.to_s.should == 'Podfile' + expect(@podfile.to_s).to eq('Podfile') end it 'returns the target definitions' do - @podfile.target_definitions.count.should == 2 - @podfile.target_definitions['Pods'].name.should == 'Pods' - @podfile.target_definitions['sub-target'].name.should == 'sub-target' + expect(@podfile.target_definitions.count).to eq(2) + expect(@podfile.target_definitions['Pods'].name).to eq('Pods') + expect(@podfile.target_definitions['sub-target'].name).to eq('sub-target') end it 'indicates if the pre install hook was executed' do - Podfile.new {}.pre_install!(:an_installer).should.be == false + expect(Podfile.new {}.pre_install!(:an_installer)).to eq(false) result = Podfile.new { pre_install { |_installer| } }.pre_install!(:an_installer) - result.should.be == true + expect(result).to eq(true) end it 'indicates if the pre integrate hook was executed' do - Podfile.new {}.pre_integrate!(:an_installer).should.be == false + expect(Podfile.new {}.pre_integrate!(:an_installer)).to eq(false) result = Podfile.new { pre_integrate { |_installer| } }.pre_integrate!(:an_installer) - result.should.be == true + expect(result).to eq(true) end it 'returns all dependencies of all targets combined' do - @podfile.dependencies.map(&:name).sort.should == %w(ASIHTTPRequest JSONKit Reachability SSZipArchive) + expect(@podfile.dependencies.map(&:name).sort).to eq(%w(ASIHTTPRequest JSONKit Reachability SSZipArchive)) end it 'indicates if the post install hook was executed' do - Podfile.new {}.post_install!(:an_installer).should.be == false + expect(Podfile.new {}.post_install!(:an_installer)).to eq(false) result = Podfile.new { post_install { |_installer| } }.post_install!(:an_installer) - result.should.be == true + expect(result).to eq(true) end it 'indicates if the post integrate hook was executed' do - Podfile.new {}.post_integrate!(:an_installer).should.be == false + expect(Podfile.new {}.post_integrate!(:an_installer)).to eq(false) result = Podfile.new { post_integrate { |_installer| } }.post_integrate!(:an_installer) - result.should.be == true + expect(result).to eq(true) end end @@ -111,63 +111,68 @@ module Pod describe 'Attributes' do it 'returns the workspace' do - Podfile.new do + podfile = Podfile.new do workspace 'MyWorkspace.xcworkspace' - end.workspace_path.should == 'MyWorkspace.xcworkspace' + end + expect(podfile.workspace_path).to eq('MyWorkspace.xcworkspace') end it 'appends the extension to the specified workspaces if needed' do - Podfile.new do + podfile = Podfile.new do workspace 'MyWorkspace' - end.workspace_path.should == 'MyWorkspace.xcworkspace' + end + expect(podfile.workspace_path).to eq('MyWorkspace.xcworkspace') end it 'returns whether the BridgeSupport metadata should be generated' do - Podfile.new {}.should.not.generate_bridge_support - Podfile.new { generate_bridge_support! }.should.generate_bridge_support + expect(Podfile.new {}.generate_bridge_support?).to be_falsey + expect(Podfile.new { generate_bridge_support! }.generate_bridge_support?).to be_truthy end it 'returns whether the ARC compatibility flag should be set' do - Podfile.new {}.should.not.set_arc_compatibility_flag - Podfile.new { set_arc_compatibility_flag! }.should.set_arc_compatibility_flag + expect(Podfile.new {}.set_arc_compatibility_flag?).to be_falsey + expect(Podfile.new { set_arc_compatibility_flag! }.set_arc_compatibility_flag?).to be_truthy end it 'returns the installation method' do name, options = Podfile.new {}.installation_method - name.should == 'cocoapods' - options.should == {} + expect(name).to eq('cocoapods') + expect(options).to eq({}) name, options = Podfile.new { install! 'install-method', :option1 => 'value1', 'option2' => false }.installation_method - name.should == 'install-method' - options.should == { :option1 => 'value1', 'option2' => false } + expect(name).to eq('install-method') + expect(options).to eq({ :option1 => 'value1', 'option2' => false }) end describe 'source' do it 'can have multiple sources' do - Podfile.new do + podfile = Podfile.new do source 'new_repo_1' source 'new_repo_2' - end.sources.size.should == 2 + end + expect(podfile.sources.size).to eq(2) - Podfile.new do + podfile = Podfile.new do source 'new_repo_1' source 'new_repo_2' source 'master' - end.sources.size.should == 3 + end + expect(podfile.sources.size).to eq(3) end end describe 'plugin' do it 'can have mutiple plugins' do - Podfile.new do + podfile = Podfile.new do plugin 'slather' plugin 'cocoapods-keys', :keyring => 'Eidolon' - end.plugins.should == { + end + expect(podfile.plugins).to eq({ 'slather' => {}, 'cocoapods-keys' => { 'keyring' => 'Eidolon', }, - } + }) end end end @@ -181,7 +186,7 @@ module Pod target 'App' do end end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'target_definitions' => [ 'name' => 'Pods', 'abstract' => true, @@ -192,7 +197,7 @@ module Pod }, ], ], - } + }) end it 'includes the podfile wide settings in the hash representation' do @@ -202,7 +207,7 @@ module Pod set_arc_compatibility_flag! install! 'install-method', :option1 => 'value1', 'option2' => false end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'target_definitions' => [{ 'name' => 'Pods', 'abstract' => true }], 'workspace' => 'MyApp.xcworkspace', 'generate_bridge_support' => true, @@ -214,7 +219,7 @@ module Pod 'option2' => false, }, }, - } + }) end it 'includes the targets definitions tree in the hash representation' do @@ -227,7 +232,7 @@ module Pod end end end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'target_definitions' => [ { 'name' => 'Pods', @@ -248,7 +253,7 @@ module Pod ], }, ], - } + }) end it 'returns the yaml representation' do @@ -279,19 +284,18 @@ module Pod generate_bridge_support: true set_arc_compatibility_flag: true EOF - YAMLHelper.load_string(podfile.to_yaml).should == - YAMLHelper.load_string(expected) + expect(YAMLHelper.load_string(podfile.to_yaml)).to eq(YAMLHelper.load_string(expected)) end describe '#checksum' do it 'returns the checksum of the file in which it is defined' do podfile = Podfile.from_file(fixture('Podfile')) - podfile.checksum.should == 'c140d332c2d286f26b6439dc3570be477d1897b8' + expect(podfile.checksum).to eq('c140d332c2d286f26b6439dc3570be477d1897b8') end it 'returns a nil checksum if the podfile is not defined in a file' do podfile = Podfile.new - podfile.checksum.should.be.nil + expect(podfile.checksum).to be_nil end end @@ -300,7 +304,7 @@ module Pod pod 'ASIHTTPRequest', :inhibit_warnings => true pod 'ObjectiveSugar' end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'target_definitions' => [ 'name' => 'Pods', 'abstract' => true, @@ -309,7 +313,7 @@ module Pod }, 'dependencies' => %w(ASIHTTPRequest ObjectiveSugar), ], - } + }) end it 'excludes inhibit warnings per pod' do @@ -317,7 +321,7 @@ module Pod pod 'ASIHTTPRequest', :inhibit_warnings => false pod 'ObjectiveSugar' end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'target_definitions' => [ 'name' => 'Pods', 'abstract' => true, @@ -326,7 +330,7 @@ module Pod }, 'dependencies' => %w(ASIHTTPRequest ObjectiveSugar), ], - } + }) end it 'includes inhibit all warnings' do @@ -334,7 +338,7 @@ module Pod pod 'ObjectiveSugar' inhibit_all_warnings! end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'target_definitions' => [ 'name' => 'Pods', 'abstract' => true, @@ -343,7 +347,7 @@ module Pod 'all' => true, }, ], - } + }) end it 'includes build type' do @@ -351,14 +355,14 @@ module Pod pod 'ObjectiveSugar' use_frameworks! end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'target_definitions' => [ 'name' => 'Pods', 'abstract' => true, 'dependencies' => ['ObjectiveSugar'], 'uses_frameworks' => { :linkage => :dynamic, :packaging => :framework }, ], - } + }) end it 'includes the specified sources in the hash representation' do @@ -366,7 +370,7 @@ module Pod source 'new_ASIHTTPRequest_source' pod 'ASIHTTPRequest' end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'sources' => %w(new_ASIHTTPRequest_source), 'target_definitions' => [ { @@ -375,7 +379,7 @@ module Pod 'dependencies' => %w(ASIHTTPRequest), }, ], - } + }) end it 'includes the specified plugins in the hash representation' do @@ -384,7 +388,7 @@ module Pod plugin 'cocoapods-keys', :keyring => 'Eidolon' pod 'ASIHTTPRequest' end - podfile.to_hash.should == { + expect(podfile.to_hash).to eq({ 'plugins' => { 'slather' => {}, 'cocoapods-keys' => { @@ -398,7 +402,7 @@ module Pod 'dependencies' => %w(ASIHTTPRequest), }, ], - } + }) end end @@ -407,8 +411,8 @@ module Pod describe 'Class methods' do it 'can be initialized from a ruby DSL file' do ruby_podfile = Podfile.from_file(fixture('Podfile')) - ruby_podfile.target_definitions.keys.should == ['Pods'] - ruby_podfile.dependencies.map(&:name).should == %w(SSZipArchive ASIHTTPRequest Reachability ASIWebPageRequest) + expect(ruby_podfile.target_definitions.keys).to eq(['Pods']) + expect(ruby_podfile.dependencies.map(&:name)).to eq(%w(SSZipArchive ASIHTTPRequest Reachability ASIWebPageRequest)) end it 'can handle smartquotes in a ruby DSL file' do @@ -416,8 +420,8 @@ module Pod pod “AFNetworking”, ‘~> 2.0’ DSL podfile = Podfile.from_ruby(fixture('Podfile'), dsl) - podfile.dependencies.should == [Dependency.new('AFNetworking', '~> 2.0')] - CoreUI.warnings.should.match /smart quotes/ + expect(podfile.dependencies).to eq([Dependency.new('AFNetworking', '~> 2.0')]) + expect(CoreUI.warnings).to match(/smart quotes/) end it 'handles the `podfile` extension' do @@ -437,42 +441,42 @@ module Pod it 'can be initialized from a YAML file' do ruby_podfile = Podfile.from_file(fixture('Podfile')) yaml_podfile = Podfile.from_file(fixture('Podfile.yaml')) - ruby_podfile.to_hash.should == yaml_podfile.to_hash + expect(ruby_podfile.to_hash).to eq(yaml_podfile.to_hash) end it 'can properly parse a boolean uses_frameworks value from a YAML file' do podfile = Podfile.from_file(fixture('Podfile_UsesFrameworksBoolean.yaml')) target_definition = podfile.target_definitions['SampleApp'] - target_definition.uses_frameworks?.should.be.true - target_definition.build_type.should == BuildType.dynamic_framework + expect(target_definition.uses_frameworks?).to be(true) + expect(target_definition.build_type).to eq(BuildType.dynamic_framework) end it 'can properly parse a hash uses_frameworks value from a YAML file' do podfile = Podfile.from_file(fixture('Podfile_UsesFrameworksHash.yaml')) target_definition = podfile.target_definitions['SampleApp'] - target_definition.uses_frameworks?.should.be.true - target_definition.build_type.should == BuildType.dynamic_framework + expect(target_definition.uses_frameworks?).to be(true) + expect(target_definition.build_type).to eq(BuildType.dynamic_framework) end it "raises if the given initialization file doesn't exists" do - should.raise Informative do + expect do Podfile.from_file('Missing-file') - end.message.should.match /No Podfile exists/ + end.to raise_error(Informative, /No Podfile exists/) end it 'raises if the given initialization file has an unsupported extension' do Pathname.any_instance.stubs(:exist?).returns(true) File.stubs(:open).returns('') - should.raise Informative do + expect do Podfile.from_file('Podfile.json') - end.message.should.match /Unsupported Podfile format/ + end.to raise_error(Informative, /Unsupported Podfile format/) end it 'can be initialized from a hash' do fixture_podfile = Podfile.from_file(fixture('Podfile')) hash = fixture_podfile.to_hash podfile = Podfile.from_hash(hash) - podfile.to_hash.should == fixture_podfile.to_hash + expect(podfile.to_hash).to eq(fixture_podfile.to_hash) end end @@ -482,22 +486,22 @@ module Pod it 'sets and retrieves a value in the internal hash' do podfile = Podfile.new podfile.send(:set_hash_value, 'generate_bridge_support', true) - podfile.send(:get_hash_value, 'generate_bridge_support').should.be.true + expect(podfile.send(:get_hash_value, 'generate_bridge_support')).to be(true) end it 'allows specifying a default value when fetching from the hash' do podfile = Podfile.new - podfile.send(:get_hash_value, 'generate_bridge_support', 'default').should == 'default' + expect(podfile.send(:get_hash_value, 'generate_bridge_support', 'default')).to eq('default') podfile.send(:set_hash_value, 'generate_bridge_support', true) - podfile.send(:get_hash_value, 'generate_bridge_support', 'default').should.be.true + expect(podfile.send(:get_hash_value, 'generate_bridge_support', 'default')).to be(true) end it 'raises if there is an attempt to access or set an unknown key in the internal hash' do podfile = Podfile.new - lambda { podfile.send(:set_hash_value, 'unknown', true) }.should.raise Pod::Podfile::StandardError - lambda { podfile.send(:get_hash_value, 'unknown') }.should.raise Pod::Podfile::StandardError + expect { podfile.send(:set_hash_value, 'unknown', true) }.to raise_error(Pod::Podfile::StandardError) + expect { podfile.send(:get_hash_value, 'unknown') }.to raise_error(Pod::Podfile::StandardError) end end @@ -537,68 +541,68 @@ module Pod it 'adds dependencies outside of any explicit target block to the default target' do target = @podfile.target_definitions['Pods'] - target.label.should == 'Pods' - target.dependencies.should == [Dependency.new('ASIHTTPRequest')] + expect(target.label).to eq('Pods') + expect(target.dependencies).to eq([Dependency.new('ASIHTTPRequest')]) end it 'adds dependencies of the outer target to non-exclusive targets' do target = @podfile.target_definitions[:debug] - target.label.should == 'Pods-debug' - target.dependencies.sort_by(&:name).should == [ + expect(target.label).to eq('Pods-debug') + expect(target.dependencies.sort_by(&:name)).to eq([ Dependency.new('ASIHTTPRequest'), Dependency.new('SSZipArchive'), - ] + ]) end it 'does not add dependencies of the outer target to exclusive targets' do target = @podfile.target_definitions[:test] - target.label.should == 'Pods-test' - target.dependencies.should == [Dependency.new('JSONKit')] + expect(target.label).to eq('Pods-test') + expect(target.dependencies).to eq([Dependency.new('JSONKit')]) end it 'adds dependencies of the outer target to nested targets' do target = @podfile.target_definitions[:subtarget] - target.label.should == 'Pods-test-subtarget' - target.dependencies.should == [Dependency.new('Reachability'), Dependency.new('JSONKit')] + expect(target.label).to eq('Pods-test-subtarget') + expect(target.dependencies).to eq([Dependency.new('Reachability'), Dependency.new('JSONKit')]) end it 'returns the platform of the target' do - @podfile.target_definitions['Pods'].platform.should == :ios - @podfile.target_definitions[:test].platform.should == :ios - @podfile.target_definitions[:osx_target].platform.should == :osx + expect(@podfile.target_definitions['Pods'].platform).to eq(:ios) + expect(@podfile.target_definitions[:test].platform).to eq(:ios) + expect(@podfile.target_definitions[:osx_target].platform).to eq(:osx) end it 'assigns a deployment target to the platforms if not specified' do - @podfile.target_definitions['Pods'].platform.deployment_target.to_s.should == '4.3' - @podfile.target_definitions[:test].platform.deployment_target.to_s.should == '4.3' - @podfile.target_definitions[:osx_target].platform.deployment_target.to_s.should == '10.6' + expect(@podfile.target_definitions['Pods'].platform.deployment_target.to_s).to eq('4.3') + expect(@podfile.target_definitions[:test].platform.deployment_target.to_s).to eq('4.3') + expect(@podfile.target_definitions[:osx_target].platform.deployment_target.to_s).to eq('10.6') end it "automatically marks a target as exclusive if the parent platform doesn't match" do - @podfile.target_definitions[:osx_target].should.be.exclusive - @podfile.target_definitions[:nested_osx_target].should.not.be.exclusive + expect(@podfile.target_definitions[:osx_target]).to be_exclusive + expect(@podfile.target_definitions[:nested_osx_target]).not_to be_exclusive end it 'inhibits warnings for any asked pod if inhibit_all_warnings! is called' do - @podfile.target_definitions['Pods'].inhibits_warnings_for_pod?('SSZipArchive').should.not.be.true - @podfile.target_definitions[:test].inhibits_warnings_for_pod?('JSONKit').should.be.true - @podfile.target_definitions[:subtarget].inhibits_warnings_for_pod?('Reachability').should.be.true + expect(@podfile.target_definitions['Pods'].inhibits_warnings_for_pod?('SSZipArchive')).not_to be(true) + expect(@podfile.target_definitions[:test].inhibits_warnings_for_pod?('JSONKit')).to be(true) + expect(@podfile.target_definitions[:subtarget].inhibits_warnings_for_pod?('Reachability')).to be(true) end it 'uses frameworks for any target if use_frameworks! is called' do - @podfile.target_definitions['Pods'].uses_frameworks?.should.not.be.true - @podfile.target_definitions[:test].uses_frameworks?.should.be.true - @podfile.target_definitions[:subtarget].uses_frameworks?.should.be.true + expect(@podfile.target_definitions['Pods'].uses_frameworks?).not_to be(true) + expect(@podfile.target_definitions[:test].uses_frameworks?).to be(true) + expect(@podfile.target_definitions[:subtarget].uses_frameworks?).to be(true) end it 'returns the Xcode project that contains the target to link with' do ['Pods', :debug, :test, :subtarget].each do |target_name| target = @podfile.target_definitions[target_name] - target.user_project_path.to_s.should == 'iOS Project.xcodeproj' + expect(target.user_project_path.to_s).to eq('iOS Project.xcodeproj') end [:osx_target, :nested_osx_target].each do |target_name| target = @podfile.target_definitions[target_name] - target.user_project_path.to_s.should == 'OSX Project.xcodeproj' + expect(target.user_project_path.to_s).to eq('OSX Project.xcodeproj') end end end diff --git a/spec/requirement_spec.rb b/spec/requirement_spec.rb index d5611653a..22adcb239 100644 --- a/spec/requirement_spec.rb +++ b/spec/requirement_spec.rb @@ -5,32 +5,32 @@ module Pod describe 'In general' do it 'can be initialized with a string' do requirement = Requirement.new('<= 1.0') - requirement.to_s.should == '<= 1.0' + expect(requirement.to_s).to eq('<= 1.0') end it 'defaults to the equality operator on initialization' do requirement = Requirement.new('1.0') - requirement.to_s.should == '= 1.0' + expect(requirement.to_s).to eq('= 1.0') end it 'can be initialized with an array of versions' do requirement = Requirement.new([Version.new('1.0'), Version.new('2.0')]) - requirement.to_s.should == '= 1.0, = 2.0' + expect(requirement.to_s).to eq('= 1.0, = 2.0') end it 'can be initialized with a pre-release version' do requirement = Requirement.new(Version.new('1.0-beta')) - requirement.to_s.should == '= 1.0-beta' + expect(requirement.to_s).to eq('= 1.0-beta') end it 'raises if initialized with an invalid input' do - should.raise ArgumentError do + expect do Requirement.new(Version.new('1.0!beta')) - end + end.to raise_error(ArgumentError) end it 'returns the default requirement' do - Requirement.default.to_s.should == '>= 0' + expect(Requirement.default.to_s).to eq('>= 0') end end @@ -40,27 +40,27 @@ module Pod it 'can be created with a requirement' do req = Requirement.new('<= 1.0') requirement = Requirement.create(req) - requirement.should == req + expect(requirement).to eq(req) end it 'can be created with a version' do requirement = Requirement.create(Version.new('1.0')) - requirement.to_s.should == '= 1.0' + expect(requirement.to_s).to eq('= 1.0') end it 'can be created with an array of versions' do requirement = Requirement.create([Version.new('1.0'), Version.new('2.0')]) - requirement.to_s.should == '= 1.0, = 2.0' + expect(requirement.to_s).to eq('= 1.0, = 2.0') end it 'can be created with a string' do requirement = Requirement.create('1.0') - requirement.to_s.should == '= 1.0' + expect(requirement.to_s).to eq('= 1.0') end it 'can be created with a nil input' do requirement = Requirement.create(nil) - requirement.to_s.should == '>= 0' + expect(requirement.to_s).to eq('>= 0') end end diff --git a/spec/source/acceptor_spec.rb b/spec/source/acceptor_spec.rb index 801d4a474..b72fbc1fc 100644 --- a/spec/source/acceptor_spec.rb +++ b/spec/source/acceptor_spec.rb @@ -20,23 +20,23 @@ module Pod describe 'In general' do it 'returns the source that should accept the podspecs' do - @acceptor.source.name.should == 'test_repo' + expect(@acceptor.source.name).to eq('test_repo') end it 'accepts a valid specification' do errors = @acceptor.analyze(@spec) - errors.should == [] + expect(errors).to eq([]) end it 'accepts a given path with a valid specification' do errors = @acceptor.analyze_path(@spec_path) - errors.should == [] + expect(errors).to eq([]) end it 'handles gracefully malformed specifications' do File.any_instance.stubs(:read).returns('raise') errors = @acceptor.analyze_path(@spec_path) - errors.should == ['Unable to load the specification.'] + expect(errors).to eq(['Unable to load the specification.']) end end @@ -46,25 +46,25 @@ module Pod it 'checks if the source of the specification did change' do @spec.source = { :git => 'http://EVIL-GORILLA-FORK/banana-lib.git', :tag => 'v1.0' } errors = @acceptor.analyze(@spec).join("\n") - errors.should.match /The source of the spec doesn't match/ + expect(errors).to match(/The source of the spec doesn't match/) end it "doesn't check if the source of the specification did change for HTTP sources" do @spec.source = { :http => 'http://banana-lib/lib.zip' } errors = @acceptor.analyze(@spec).join("\n") - errors.should.not.match /The source of the spec doesn't match/ + expect(errors).not_to match(/The source of the spec doesn't match/) end it "doesn't fail if the new source of the specification is a redirect" do @spec.source = { :git => 'http://NEW-URL/banana-lib.git', :tag => 'v1.0' } errors = @acceptor.analyze(@spec).join("\n") - errors.should.not.match /The source of the spec doesn't match/ + expect(errors).not_to match(/The source of the spec doesn't match/) end it 'rejects a Git based specification without tag if there is at least one tagged version' do @spec.source = { :git => 'http://banana-corp.local/banana-lib.git', :commit => 'SHA' } errors = @acceptor.analyze(@spec).join("\n") - errors.should.match /There is already at least one versioned specification/ + expect(errors).to match(/There is already at least one versioned specification/) end it 'checks if there is an attempt to change the commit of an untagged version' do @@ -76,13 +76,13 @@ module Pod @spec.source = { :git => repo, :commit => 'SHA_2' } @acceptor.stubs(:related_specifications).returns(nil) errors = @acceptor.analyze(@spec, previous_spec).join("\n") - errors.should.match /Attempt to rewrite the commit/ + expect(errors).to match(/Attempt to rewrite the commit/) end it 'checks that the dependencies of the specification are available' do Specification.any_instance.unstub(:dependencies) errors = @acceptor.analyze(@spec).join("\n") - errors.should.match /Unable to find a specification for the.*monkey.*dependency/ + expect(errors).to match(/Unable to find a specification for the.*monkey.*dependency/) end end end diff --git a/spec/source/aggregate_spec.rb b/spec/source/aggregate_spec.rb index 25c387a25..3c369d014 100644 --- a/spec/source/aggregate_spec.rb +++ b/spec/source/aggregate_spec.rb @@ -14,49 +14,49 @@ module Pod describe 'In general' do it 'returns the sources' do - @aggregate.sources.map(&:name).sort.should == %w(artsy test_repo) + expect(@aggregate.sources.map(&:name).sort).to eq(%w(artsy test_repo)) end it 'returns the name of all the available pods' do root_spec_names = @aggregate.all_pods - root_spec_names.should.include('JSONKit') - root_spec_names.should.include('BananaLib') + expect(root_spec_names).to include('JSONKit') + expect(root_spec_names).to include('BananaLib') end it 'returns all the available sets with the sources configured' do sets = @aggregate.all_sets banana_sets = sets.select { |set| set.name == 'BananaLib' } - banana_sets.count.should == 1 - banana_sets.first.sources.map(&:name).should == %w(test_repo) + expect(banana_sets.count).to eq(1) + expect(banana_sets.first.sources.map(&:name)).to eq(%w(test_repo)) json_set = sets.select { |set| set.name == 'React' } - json_set.count.should == 1 - json_set.first.sources.map(&:name).should == %w(test_repo artsy) + expect(json_set.count).to eq(1) + expect(json_set.first.sources.map(&:name)).to eq(%w(test_repo artsy)) end it 'searches the sets by dependency' do dep = Dependency.new('React') set = @aggregate.search(dep) - set.name.should == 'React' - set.sources.map(&:name).should == %w(test_repo artsy) + expect(set.name).to eq('React') + expect(set.sources.map(&:name)).to eq(%w(test_repo artsy)) end it 'searches the sets specifying a dependency on a subspec' do dep = Dependency.new('React/Core') set = @aggregate.search(dep) - set.name.should == 'React' - set.sources.map(&:name).should == %w(test_repo artsy) + expect(set.name).to eq('React') + expect(set.sources.map(&:name)).to eq(%w(test_repo artsy)) end it "returns nil if a specification can't be found" do dep = Dependency.new('Does-not-exist') set = @aggregate.search(dep) - set.should.nil? + expect(set).to be_nil end it 'returns a set configured to use only the source which contains the highest version' do set = @aggregate.representative_set('JSONKit') - set.versions.map(&:to_s).should == ['999.999.999', '1.13', '1.4'] + expect(set.versions.map(&:to_s)).to eq(['999.999.999', '1.13', '1.4']) end end @@ -66,30 +66,30 @@ module Pod it 'searches the sets by name' do sets = @aggregate.search_by_name('React') set = sets.find { |s| s.name == 'React' } - set.name.should == 'React' - set.sources.map(&:name).should == %w(test_repo artsy) + expect(set.name).to eq('React') + expect(set.sources.map(&:name)).to eq(%w(test_repo artsy)) end it 'properly configures the sources of a set in search by name' do sets = @aggregate.search_by_name('BananaLib') - sets.count.should == 1 + expect(sets.count).to eq(1) set = sets.first - set.name.should == 'BananaLib' - set.sources.map(&:name).should == %w(test_repo) + expect(set.name).to eq('BananaLib') + expect(set.sources.map(&:name)).to eq(%w(test_repo)) end it 'performs a full text search' do @aggregate.stubs(:sources).returns([Source.new(fixture('spec-repos/test_repo'))]) sets = @aggregate.search_by_name('Banana Corp', true) - sets.count.should == 1 - sets.first.name.should == 'BananaLib' + expect(sets.count).to eq(1) + expect(sets.first.name).to eq('BananaLib') end it 'raises an informative if unable to find a Pod with the given name' do @aggregate.stubs(:sources).returns([Source.new(fixture('spec-repos/test_repo'))]) - should.raise Informative do + expect do @aggregate.search_by_name('Some-funky-name', true) - end.message.should.match /Unable to find/ + end.to raise_error(Informative, /Unable to find/) end end @@ -104,16 +104,16 @@ module Pod index = @aggregate.generate_search_index_for_source(@test_source) text = 'BananaLib Chunky bananas! Full chunky bananas. Banana Corp Monkey Boy monkey@banana-corp.local' text.split.each do |word| - index[word].should == %w(BananaLib) + expect(index[word]).to eq(%w(BananaLib)) end - index['Faulty_spec'].should.be.nil + expect(index['Faulty_spec']).to be_nil end it 'generates the search index for changes in source' do changed_paths = ['Specs/JSONKit/1.4/JSONKit.podspec'] index = @aggregate.generate_search_index_for_changes_in_source(@test_source, changed_paths) - index['JSONKit'].should == %w(JSONKit) - index['BananaLib'].should.be.nil + expect(index['JSONKit']).to eq(%w(JSONKit)) + expect(index['BananaLib']).to be_nil end it 'generates correct vocabulary form given set' do @@ -125,7 +125,7 @@ module Pod set.stubs(:specification).returns(spec) vocabulary = %w(PodName Summary of pod name author1 author2 ***woww---@mymail.com) - @aggregate.send(:word_list_from_set, set).should == vocabulary + expect(@aggregate.send(:word_list_from_set, set)).to eq(vocabulary) end end diff --git a/spec/source/health_reporter_spec.rb b/spec/source/health_reporter_spec.rb index 06c2e19a5..da74abcf1 100644 --- a/spec/source/health_reporter_spec.rb +++ b/spec/source/health_reporter_spec.rb @@ -18,42 +18,42 @@ module Pod names << name end @reporter.analyze - names.should.include?('BananaLib') + expect(names).to include('BananaLib') end it 'analyzes all the specifications of a repo' do @reporter.analyze - @reporter.report.analyzed_paths.count.should == 14 + expect(@reporter.report.analyzed_paths.count).to eq(14) end it 'is robust against malformed specifications' do @reporter.analyze errors = @reporter.report.pods_by_error.keys.join(' - ') - errors.should.match /Faulty_spec.podspec.*could not be loaded/ + expect(errors).to match(/Faulty_spec.podspec.*could not be loaded/) end it 'lints the specifications' do @reporter.analyze errors = @reporter.report.pods_by_error.keys.join(' - ') - errors.should.match /Missing required attribute/ + expect(errors).to match(/Missing required attribute/) end it 'checks the path of the specifications' do @reporter.analyze errors = @reporter.report.pods_by_error.keys.join("\n") - errors.should.match /Incorrect path/ + expect(errors).to match(/Incorrect path/) end it 'checks if requires_arc has the string value of true or false' do @reporter.analyze warnings = @reporter.report.pods_by_warning.keys.join("\n") - warnings.should.match /true is considered to be the name of a file/ + expect(warnings).to match(/true is considered to be the name of a file/) end it 'checks for any stray specifications' do @reporter.analyze errors = @reporter.report.pods_by_error.keys.join("\n") - errors.should.match /Stray spec/ + expect(errors).to match(/Stray spec/) end end diff --git a/spec/source/manager_spec.rb b/spec/source/manager_spec.rb index e44ad7613..779894b84 100644 --- a/spec/source/manager_spec.rb +++ b/spec/source/manager_spec.rb @@ -25,24 +25,24 @@ module Pod describe 'In general' do it 'does not fail if the repos directory does not exist' do @sources_manager.stubs(:repos_dir).returns(Pathname.new('/foo/bar')) - @sources_manager.aggregate.sources.should == [] - @sources_manager.all.should == [] + expect(@sources_manager.aggregate.sources).to eq([]) + expect(@sources_manager.all).to eq([]) end it 'returns all the sources' do - @sources_manager.all.map(&:name).should == %w(artsy test_cdn_repo_local test_empty_dir_repo test_prefixed_repo test_repo test_repo_without_specs_dir trunk) + expect(@sources_manager.all.map(&:name)).to eq(%w(artsy test_cdn_repo_local test_empty_dir_repo test_prefixed_repo test_repo test_repo_without_specs_dir trunk)) end it 'includes all sources in an aggregate for a dependency if no source is specified' do dependency = Dependency.new('JSONKit', '1.4') aggregate = @sources_manager.aggregate_for_dependency(dependency) - aggregate.sources.map(&:name).should == %w(artsy test_cdn_repo_local test_empty_dir_repo test_prefixed_repo test_repo test_repo_without_specs_dir trunk) + expect(aggregate.sources.map(&:name)).to eq(%w(artsy test_cdn_repo_local test_empty_dir_repo test_prefixed_repo test_repo test_repo_without_specs_dir trunk)) end it 'includes all sources in an aggregate for a dependency if non-existent source is specified' do dependency = Dependency.new('JSONKit', '1.4', :source => 'https://url/to/nonexistent/specs.git') aggregate = @sources_manager.aggregate_for_dependency(dependency) - aggregate.sources.map(&:name).should == %w(artsy test_cdn_repo_local test_empty_dir_repo test_prefixed_repo test_repo test_repo_without_specs_dir trunk) + expect(aggregate.sources.map(&:name)).to eq(%w(artsy test_cdn_repo_local test_empty_dir_repo test_prefixed_repo test_repo test_repo_without_specs_dir trunk)) end it 'includes only the one source in an aggregate for a dependency if a source is specified by URL' do @@ -57,7 +57,7 @@ module Pod @sources_manager.expects(:source_from_path).with('path').returns(source) aggregate = @sources_manager.aggregate_for_dependency(dependency) - aggregate.sources.map(&:name).should == [source.name] + expect(aggregate.sources.map(&:name)).to eq([source.name]) end it 'includes only the one source in an aggregate for a dependency if a source is specified by name' do @@ -72,40 +72,40 @@ module Pod @sources_manager.expects(:source_from_path).with('path').returns(source) aggregate = @sources_manager.aggregate_for_dependency(dependency) - aggregate.sources.map(&:name).should == [source.name] + expect(aggregate.sources.map(&:name)).to eq([source.name]) end it 'searches for the set of a dependency' do set = @sources_manager.search(Dependency.new('BananaLib')) - set.class.should == Specification::Set - set.name.should == 'BananaLib' + expect(set.class).to eq(Specification::Set) + expect(set.name).to eq('BananaLib') end it 'returns nil if it is not able to find a pod for the given dependency' do set = @sources_manager.search(Dependency.new('Windows-Lib')) - set.should.be.nil + expect(set).to be_nil end it 'searches sets by name' do sets = @sources_manager.search_by_name('BananaLib') - sets.all? { |s| s.class == Specification::Set }.should.be.true - sets.any? { |s| s.name == 'BananaLib' }.should.be.true + expect(sets.all? { |s| s.class == Specification::Set }).to be(true) + expect(sets.any? { |s| s.name == 'BananaLib' }).to be(true) end it 'can perform a full text search of the sets' do @sources_manager.stubs(:all).returns([@test_source]) @sources_manager.stubs(:all_non_indexable).returns([]) sets = @sources_manager.search_by_name('Chunky', true) - sets.all? { |s| s.class == Specification::Set }.should.be.true - sets.any? { |s| s.name == 'BananaLib' }.should.be.true + expect(sets.all? { |s| s.class == Specification::Set }).to be(true) + expect(sets.any? { |s| s.name == 'BananaLib' }).to be(true) end it 'can perform a full text regexp search of the sets' do @sources_manager.stubs(:all).returns([@test_source]) @sources_manager.stubs(:all_non_indexable).returns([]) sets = @sources_manager.search_by_name('Ch[aeiou]nky', true) - sets.all? { |s| s.class == Specification::Set }.should.be.true - sets.any? { |s| s.name == 'BananaLib' }.should.be.true + expect(sets.all? { |s| s.class == Specification::Set }).to be(true) + expect(sets.any? { |s| s.name == 'BananaLib' }).to be(true) end it 'can perform a full text search of the sets on a CDN' do @@ -113,8 +113,8 @@ module Pod @sources_manager.stubs(:all_non_indexable).returns([@test_source_cdn]) Algolia::Index.any_instance.stubs(:search).with('beacon', :attributesToRetrieve => 'name').returns('hits' => [{ 'name' => 'BeaconKit' }]) sets = @sources_manager.search_by_name('beacon', true) - sets.all? { |s| s.class == Specification::Set }.should.be.true - sets.any? { |s| s.name == 'BeaconKit' }.should.be.true + expect(sets.all? { |s| s.class == Specification::Set }).to be(true) + expect(sets.any? { |s| s.name == 'BeaconKit' }).to be(true) end describe 'Sorting algorithm' do @@ -128,50 +128,50 @@ module Pod it 'puts pod with exact match at the first index while sorting' do regexps = [/networking/i] sets = @sources_manager.sorted_sets(@test_search_results, regexps) - sets[0].name.should == 'Networking' + expect(sets[0].name).to eq('Networking') end it 'puts pod with less prefix length before pods with more prefix length in search results' do regexps = [/reachability/i] sets = @sources_manager.sorted_sets(@test_search_results, regexps) - sets.index { |s| s.name == 'AVReachability' }.should.be < sets.index { |s| s.name == 'VCLReachability' } + expect(sets.index { |s| s.name == 'AVReachability' }).to be < sets.index { |s| s.name == 'VCLReachability' } end it 'puts pod with more query word match before pods with less match in multi word query search results' do regexps = [/network/i, /reachability/i] sets = @sources_manager.sorted_sets(@test_search_results, regexps) - sets.index { |s| s.name == 'SCNetworkReachability' }.should.be < sets.index { |s| s.name == 'AVReachability' } + expect(sets.index { |s| s.name == 'SCNetworkReachability' }).to be < sets.index { |s| s.name == 'AVReachability' } end it 'puts pod matching first query word before pods matching later words in multi word query search results' do regexps = [/network/i, /reachability/i] sets = @sources_manager.sorted_sets(@test_search_results, regexps) - sets.index { |s| s.name == 'PYNetwork' }.should.be < sets.index { |s| s.name == 'AVReachability' } + expect(sets.index { |s| s.name == 'PYNetwork' }).to be < sets.index { |s| s.name == 'AVReachability' } end it 'puts pod matching first query word before pods matching later words in multi word query search results' do regexps = [/network/i, /reachability/i] sets = @sources_manager.sorted_sets(@test_search_results, regexps) - sets.index { |s| s.name == 'PYNetwork' }.should.be < sets.index { |s| s.name == 'AVReachability' } + expect(sets.index { |s| s.name == 'PYNetwork' }).to be < sets.index { |s| s.name == 'AVReachability' } end it 'alphabetically sorts pods having exact other conditions' do regexps = [/reachability/i] sets = @sources_manager.sorted_sets(@test_search_results, regexps) - sets.index { |s| s.name == 'AVReachability' }.should.be < sets.index { |s| s.name == 'NPReachability' } + expect(sets.index { |s| s.name == 'AVReachability' }).to be < sets.index { |s| s.name == 'NPReachability' } end it 'alphabetically sorts pods whose names does not match query' do regexps = [/reachability/i] sets = @sources_manager.sorted_sets(@test_search_results, regexps) - sets.index { |s| s.name == 'DLSuit' }.should.be < sets.index { |s| s.name == 'HockeyKit' } + expect(sets.index { |s| s.name == 'DLSuit' }).to be < sets.index { |s| s.name == 'HockeyKit' } end end it 'deletes the search index file if it is invalid' do @sources_manager.save_search_index(nil) - @sources_manager.stored_search_index.should.be.nil - @sources_manager.search_index_path.exist?.should.be.false + expect(@sources_manager.stored_search_index).to be_nil + expect(@sources_manager.search_index_path.exist?).to be(false) end it "generates the search index before performing a search if it doesn't exist" do @@ -188,142 +188,126 @@ module Pod url = 'https://cdn.cocoapods.org/' Pathname.any_instance.stubs(:exist?). returns(false).then.returns(true) - @sources_manager.send(:name_for_url, url).should == 'trunk' + expect(@sources_manager.send(:name_for_url, url)).to eq('trunk') end it 'uses `trunk` for the CDN CocoaPods repository without a slash' do url = 'https://cdn.cocoapods.org' Pathname.any_instance.stubs(:exist?). returns(false).then.returns(true) - @sources_manager.send(:name_for_url, url).should == 'trunk' + expect(@sources_manager.send(:name_for_url, url)).to eq('trunk') end it 'uses the organization and repo name for github.com URLs' do url = 'https://github.com/segiddins/banana.git' - @sources_manager.send(:name_for_url, url).should == 'segiddins-banana' + expect(@sources_manager.send(:name_for_url, url)).to eq('segiddins-banana') end it 'uses the organization name only for github.com specs URLs' do url = 'https://github.com/segiddins/Specs.git' - @sources_manager.send(:name_for_url, url).should == 'segiddins' + expect(@sources_manager.send(:name_for_url, url)).to eq('segiddins') end it 'uses a combination of host and path for other URLs' do url = 'https://sourceforge.org/Artsy/Specs.git' - @sources_manager.send(:name_for_url, url). - should == 'sourceforge-artsy' + expect(@sources_manager.send(:name_for_url, url)).to eq('sourceforge-artsy') url = 'https://sourceforge.org.au/Artsy/Specs.git' - @sources_manager.send(:name_for_url, url). - should == 'sourceforge-artsy' + expect(@sources_manager.send(:name_for_url, url)).to eq('sourceforge-artsy') url = 'https://pvt.sourceforge.org.au/Artsy/Specs.git' - @sources_manager.send(:name_for_url, url). - should == 'sourceforge-artsy' + expect(@sources_manager.send(:name_for_url, url)).to eq('sourceforge-artsy') end it 'does not remove /specs path component if it is not the last one' do url = 'https://sourceforge.org.au/Specs/Path/Repo.git' - @sources_manager.send(:name_for_url, url).should == 'sourceforge-specs-path-repo' + expect(@sources_manager.send(:name_for_url, url)).to eq('sourceforge-specs-path-repo') end it 'can understand arbitrary URI schemes' do url = 'banana://website.org/Artsy/Specs.git' - @sources_manager.send(:name_for_url, url). - should == 'website-artsy' + expect(@sources_manager.send(:name_for_url, url)).to eq('website-artsy') end it 'should raise on completely ridiculous non-URL input' do url = ' ' - should.raise Informative do + expect do @sources_manager.send(:name_for_url, url) - end.message.should.== "Couldn't determine repo name for URL: #{url}" + end.to raise_error(Informative, "Couldn't determine repo name for URL: #{url}") end it 'supports scp-style URLs' do url = 'git@git-host.com:specs.git' - @sources_manager.send(:name_for_url, url). - should == 'git-host' + expect(@sources_manager.send(:name_for_url, url)).to eq('git-host') url = 'org-123456789@github.com:mycompany/ios-companypods.git' - @sources_manager.send(:name_for_url, url). - should == 'mycompany-ios-companypods' + expect(@sources_manager.send(:name_for_url, url)).to eq('mycompany-ios-companypods') url = 'git@git-host.com/specs.git' - @sources_manager.send(:name_for_url, url). - should == 'git-host' + expect(@sources_manager.send(:name_for_url, url)).to eq('git-host') url = 'git@git-host.com:/specs.git' - @sources_manager.send(:name_for_url, url). - should == 'git-host' + expect(@sources_manager.send(:name_for_url, url)).to eq('git-host') url = 'git@github.com/segiddins/Specs' - @sources_manager.send(:name_for_url, url). - should == 'segiddins' + expect(@sources_manager.send(:name_for_url, url)).to eq('segiddins') end it 'supports ssh URLs with an aliased hostname' do url = 'ssh://user@companyalias/pod-specs' - @sources_manager.send(:name_for_url, url). - should == 'companyalias-pod-specs' + expect(@sources_manager.send(:name_for_url, url)).to eq('companyalias-pod-specs') end it 'supports file URLs' do url = 'file:///Users/kurrytran/etc' - @sources_manager.send(:name_for_url, url). - should == 'users-kurrytran-etc' + expect(@sources_manager.send(:name_for_url, url)).to eq('users-kurrytran-etc') url = 'file:///Users/kurrytran/specs' - @sources_manager.send(:name_for_url, url). - should == 'users-kurrytran' + expect(@sources_manager.send(:name_for_url, url)).to eq('users-kurrytran') end it 'uses the repo name if no parent directory' do url = 'file:///pod-specs' - @sources_manager.send(:name_for_url, url). - should == 'pod-specs' + expect(@sources_manager.send(:name_for_url, url)).to eq('pod-specs') end it 'supports ssh URLs with no user component' do url = 'ssh://company.com/pods/specs.git' - @sources_manager.send(:name_for_url, url). - should == 'company-pods' + expect(@sources_manager.send(:name_for_url, url)).to eq('company-pods') end it 'supports ssh URLs with user and port' do url = 'ssh://git@company.com:1234/pods/specs.git' - @sources_manager.send(:name_for_url, url). - should == 'company-pods' + expect(@sources_manager.send(:name_for_url, url)).to eq('company-pods') end it 'supports ssh URls without .git' do url = 'git@ssh.dev.azure.com:v3/aa-aaaaa/aaa_aaa_aaaaa/aaa-aaa-aaaaa' - @sources_manager.send(:name_for_url, url). - should == 'azure-v3-aa-aaaaa-aaa_aaa_aaaaa-aaa-aaa-aaaaa' + expect(@sources_manager.send(:name_for_url, url)).to eq('azure-v3-aa-aaaaa-aaa_aaa_aaaaa-aaa-aaa-aaaaa') end it 'appends a number to the name if the base name dir exists' do url = 'https://github.com/segiddins/banana.git' Pathname.any_instance.stubs(:exist?). returns(true).then.returns(false) - @sources_manager.send(:name_for_url, url).should == 'segiddins-banana-1' + expect(@sources_manager.send(:name_for_url, url)).to eq('segiddins-banana-1') url = 'https://sourceforge.org/Artsy/Specs.git' Pathname.any_instance.stubs(:exist?). returns(true).then.returns(false) - @sources_manager.send(:name_for_url, url).should == 'sourceforge-artsy-1' + expect(@sources_manager.send(:name_for_url, url)).to eq('sourceforge-artsy-1') url = 'https://sourceforge.org/Artsy/Specs.git' Pathname.any_instance.stubs(:exist?). returns(true).then. returns(true).then.returns(false) - @sources_manager.send(:name_for_url, url).should == 'sourceforge-artsy-2' + expect(@sources_manager.send(:name_for_url, url)).to eq('sourceforge-artsy-2') end end describe '#source_with_url' do it 'should find CDN with trailing slash' do - @sources_manager.send(:source_with_url, 'https://cdn.cocoapods.org/').name.should == 'trunk' + expect(@sources_manager.send(:source_with_url, 'https://cdn.cocoapods.org/').name).to eq('trunk') end it 'should find CDN without trailing slash' do - @sources_manager.send(:source_with_url, 'https://cdn.cocoapods.org').name.should == 'trunk' + expect(@sources_manager.send(:source_with_url, 'https://cdn.cocoapods.org').name).to eq('trunk') end end end @@ -341,13 +325,13 @@ module Pod @sources_manager.expects(:stored_search_index).returns(prev_index) @sources_manager.expects(:save_search_index).with do |value| - value[@test_source.name]['BananaLib'].should.include('BananaLib') - value[@test_source.name]['JSONKit'].should.include('JSONKit') - value[@test_source.name]['Banana'].should.include('SOME_POD') - value[@test_source.name]['Banana'].should.include('BananaLib') - value[@test_source.name]['NON_EXISTING_WORD'].should.not.include('JSONKit') - value[@test_source.name]['NON_EXISTING_WORD'].should.not.include('BananaLib') - value[@test_source.name]['NON_EXISTING_WORD'].should.include('SOME_POD') + expect(value[@test_source.name]['BananaLib']).to include('BananaLib') + expect(value[@test_source.name]['JSONKit']).to include('JSONKit') + expect(value[@test_source.name]['Banana']).to include('SOME_POD') + expect(value[@test_source.name]['Banana']).to include('BananaLib') + expect(value[@test_source.name]['NON_EXISTING_WORD']).not_to include('JSONKit') + expect(value[@test_source.name]['NON_EXISTING_WORD']).not_to include('BananaLib') + expect(value[@test_source.name]['NON_EXISTING_WORD']).to include('SOME_POD') end changed_paths = { @test_source => %w(Specs/BananaLib/1.0/BananaLib.podspec Specs/JSONKit/1.4/JSONKit.podspec) } @sources_manager.update_search_index_if_needed(changed_paths) @@ -358,7 +342,7 @@ module Pod @sources_manager.expects(:stored_search_index).returns(prev_index) @sources_manager.expects(:save_search_index).with do |value| - value[@test_source.name].should.be.nil + expect(value[@test_source.name]).to be_nil end changed_paths = { @test_source => %w(Specs/BananaLib/1.0/BananaLib.podspec Specs/JSONKit/1.4/JSONKit.podspec) } @sources_manager.update_search_index_if_needed(changed_paths) @@ -384,18 +368,18 @@ module Pod describe 'Master repo' do it 'returns the master repo dir' do - @sources_manager.master_repo_dir.to_s.should.match %r{fixtures/spec-repos/trunk} + expect(@sources_manager.master_repo_dir.to_s).to match(%r{fixtures/spec-repos/trunk}) end it 'returns an empty array for master sources when the master repo has not been set up' do Pathname.any_instance.stubs(:directory?).returns(false) - @sources_manager.master.should == [] + expect(@sources_manager.master).to eq([]) end it 'returns whether the master repo is functional' do - @sources_manager.master_repo_functional?.should.be.true + expect(@sources_manager.master_repo_functional?).to be(true) @sources_manager.stubs(:repos_dir).returns(SpecHelper.temporary_directory) - @sources_manager.master_repo_functional?.should.be.false + expect(@sources_manager.master_repo_functional?).to be(false) end end end diff --git a/spec/source/metadata_spec.rb b/spec/source/metadata_spec.rb index a5d9a4ff9..5ad00de6a 100644 --- a/spec/source/metadata_spec.rb +++ b/spec/source/metadata_spec.rb @@ -15,41 +15,41 @@ module Pod describe '#initialize' do it 'sets the minimum_cocoapods_version' do - @metadata.minimum_cocoapods_version.should == Version.new('0.33.1') + expect(@metadata.minimum_cocoapods_version).to eq(Version.new('0.33.1')) end it 'sets the maximum_cocoapods_version' do - @metadata.maximum_cocoapods_version.should == Version.new('1.9.9') + expect(@metadata.maximum_cocoapods_version).to eq(Version.new('1.9.9')) end it 'sets the prefix_lengths' do - @metadata.prefix_lengths.should == [1, 1, 1] + expect(@metadata.prefix_lengths).to eq([1, 1, 1]) end it 'sets the latest_cocoapods_version' do - @metadata.latest_cocoapods_version.should == Version.new(CORE_VERSION) + expect(@metadata.latest_cocoapods_version).to eq(Version.new(CORE_VERSION)) end it 'sets the last_compatible_versions' do - @metadata.last_compatible_versions.should == [ + expect(@metadata.last_compatible_versions).to eq([ Pod::Version.new('0.11.0'), Pod::Version.new('0.20.5'), Pod::Version.new('0.22.0'), - ] + ]) end end describe '#path_fragment' do it 'returns correct shard in array form' do - @metadata.path_fragment('DfPodTest').should == %w(2 2 2 DfPodTest) + expect(@metadata.path_fragment('DfPodTest')).to eq(%w(2 2 2 DfPodTest)) end it 'handles one-character names' do - @metadata.path_fragment('T').should == %w(b 9 e T) + expect(@metadata.path_fragment('T')).to eq(%w(b 9 e T)) end it 'handles non-ascii names' do - @metadata.path_fragment('🔒').should == %w(c 5 1 🔒) + expect(@metadata.path_fragment('🔒')).to eq(%w(c 5 1 🔒)) end end @@ -62,7 +62,7 @@ module Pod } metadata = Source::Metadata.new(metadata_hash) result = metadata.last_compatible_version(Version.new('1.5.0')) - result.should == Pod::Version.new('1.4.0') + expect(result).to eq(Pod::Version.new('1.4.0')) end it 'raises when unable to find a compatible version' do @@ -71,44 +71,44 @@ module Pod 'max' => '2.0.0', } metadata = Source::Metadata.new(metadata_hash) - should.raise Pod::Informative do + expect do metadata.last_compatible_version(Version.new('1.5.0')) - end.message.should.match /Unable to find compatible version/ + end.to raise_error(Pod::Informative, /Unable to find compatible version/) end end describe '#compatible?' do it 'returns whether a repository is compatible' do @metadata = Source::Metadata.new('min' => '0.0.1') - @metadata.compatible?('1.0.0').should.be.true + expect(@metadata.compatible?('1.0.0')).to be(true) @metadata = Source::Metadata.new('max' => '999.0') - @metadata.compatible?('1.0.0').should.be.true + expect(@metadata.compatible?('1.0.0')).to be(true) @metadata = Source::Metadata.new('min' => '999.0') - @metadata.compatible?('1.0.0').should.be.false + expect(@metadata.compatible?('1.0.0')).to be(false) @metadata = Source::Metadata.new('max' => '0.0.1') - @metadata.compatible?('1.0.0').should.be.false + expect(@metadata.compatible?('1.0.0')).to be(false) end end describe '#to_hash' do it 'returns a hash representation of the metadata' do - @metadata.to_hash.should == { + expect(@metadata.to_hash).to eq({ 'min' => '0.33.1', 'max' => '1.9.9', 'last' => CORE_VERSION, 'prefix_lengths' => [1, 1, 1], 'last_compatible_versions' => ['0.11.0', '0.20.5', '0.22.0'], - } + }) end it 'excludes missing properties' do @metadata = Source::Metadata.new('min' => '999.0') - @metadata.to_hash.should == { + expect(@metadata.to_hash).to eq({ 'min' => '999.0', - } + }) end end end diff --git a/spec/source_spec.rb b/spec/source_spec.rb index c940248bc..8e781d9da 100644 --- a/spec/source_spec.rb +++ b/spec/source_spec.rb @@ -11,24 +11,24 @@ module Pod describe 'In general' do it 'return its name' do - @source.name.should == 'test_repo' + expect(@source.name).to eq('test_repo') end it 'return its type when git' do - @source.type.should == 'git' + expect(@source.type).to eq('git') end it 'return its type when git' do @path = fixture('spec-repos/test_empty_dir_repo') @source = Source.new(@path) - @source.type.should == 'file system' + expect(@source.type).to eq('file system') end it 'can be ordered according to its name' do s1 = Source.new(Pathname.new 'customized') s2 = Source.new(Pathname.new 'master') s3 = Source.new(Pathname.new 'private') - [s3, s1, s2].sort.should == [s1, s2, s3] + expect([s3, s1, s2].sort).to eq([s1, s2, s3]) end end @@ -36,22 +36,22 @@ module Pod describe '#pods' do it 'returns the available Pods' do - @source.pods.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec React) + expect(@source.pods).to eq(%w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec React)) end it "raises if the repo doesn't exists" do @path = fixture('spec-repos/non_existing') @source = Source.new(@path) - should.raise Informative do + expect do @source.pods - end.message.should.match /Unable to find a source named: `non_existing`/ + end.to raise_error(Informative, /Unable to find a source named: `non_existing`/) end it 'returns corresponding pods for given specification paths' do paths = %w(Specs/BananaLib/1.0/BananaLib.podspec) - @source.pods_for_specification_paths(paths).should == %w(BananaLib) + expect(@source.pods_for_specification_paths(paths)).to eq(%w(BananaLib)) paths = %w(Specs/monkey/1.0.2/monkey.podspec Specs/JSONKit/1.4/JSONKit.podspec) - @source.pods_for_specification_paths(paths).should == %w(monkey JSONKit) + expect(@source.pods_for_specification_paths(paths)).to eq(%w(monkey JSONKit)) end end @@ -59,11 +59,11 @@ module Pod describe '#versions' do it 'returns the available versions of a Pod' do - @source.versions('JSONKit').map(&:to_s).should == ['999.999.999', '1.13', '1.4'] + expect(@source.versions('JSONKit').map(&:to_s)).to eq(['999.999.999', '1.13', '1.4']) end it 'returns nil if the Pod could not be found' do - @source.versions('Unknown_Pod').should.be.nil + expect(@source.versions('Unknown_Pod')).to be_nil end it 'returns cached versions for a Pod' do @@ -72,9 +72,9 @@ module Pod pod_path_children.each { |v| v.expects(:directory?).returns(true).once } pod_path.expects(:children).returns(pod_path_children) @source.expects(:pod_path).with('JSONKit').twice.returns(pod_path) - @source.versions('JSONKit').map(&:to_s).should == ['999.999.999', '1.13', '1.4'] - @source.versions('JSONKit').map(&:to_s).should == ['999.999.999', '1.13', '1.4'] - @source.instance_variable_get(:@versions_by_name).should == { 'JSONKit' => [Version.new('999.999.999'), Version.new('1.13'), Version.new('1.4')] } + expect(@source.versions('JSONKit').map(&:to_s)).to eq(['999.999.999', '1.13', '1.4']) + expect(@source.versions('JSONKit').map(&:to_s)).to eq(['999.999.999', '1.13', '1.4']) + expect(@source.instance_variable_get(:@versions_by_name)).to eq({ 'JSONKit' => [Version.new('999.999.999'), Version.new('1.13'), Version.new('1.4')] }) end end @@ -83,8 +83,8 @@ module Pod describe '#specification' do it 'returns the specification for the given name and version' do spec = @source.specification('JSONKit', Version.new('1.4')) - spec.name.should == 'JSONKit' - spec.version.to_s.should == '1.4' + expect(spec.name).to eq('JSONKit') + expect(spec.version.to_s).to eq('1.4') end end @@ -93,7 +93,7 @@ module Pod describe '#all_specs' do it 'returns all the specifications' do expected = %w(BananaLib IncorrectPath JSONKit JSONSpec React) - @source.all_specs.map(&:name).sort.uniq.should == expected + expect(@source.all_specs.map(&:name).sort.uniq).to eq(expected) end end @@ -102,8 +102,8 @@ module Pod describe '#set' do it 'returns the set of a given Pod' do set = @source.set('BananaLib') - set.name.should == 'BananaLib' - set.sources.should == [@source] + expect(set.name).to eq('BananaLib') + expect(set.sources).to eq([@source]) end end @@ -112,7 +112,7 @@ module Pod describe '#pod_sets' do it 'returns all the pod sets' do expected = %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec React) - @source.pod_sets.map(&:name).sort.uniq.should == expected + expect(@source.pod_sets.map(&:name).sort.uniq).to eq(expected) end end @@ -120,21 +120,21 @@ module Pod describe '#search' do it 'searches for the Pod with the given name' do - @source.search('BananaLib').name.should == 'BananaLib' + expect(@source.search('BananaLib').name).to eq('BananaLib') end it 'searches for the pod with the given dependency' do dep = Dependency.new('BananaLib') - @source.search(dep).name.should == 'BananaLib' + expect(@source.search(dep).name).to eq('BananaLib') end it 'supports dependencies on subspecs' do dep = Dependency.new('BananaLib/subspec') - @source.search(dep).name.should == 'BananaLib' + expect(@source.search(dep).name).to eq('BananaLib') end it 'matches case' do - @source.search('bAnAnAlIb').should.be.nil? + expect(@source.search('bAnAnAlIb')).to be_nil end describe 'when there is an empty directory' do @@ -142,7 +142,7 @@ module Pod after { FileUtils.rm_r @empty_dir } it 'returns nil' do - @source.search('Empty').should.be.nil + expect(@source.search('Empty')).to be_nil end end @@ -150,16 +150,16 @@ module Pod it 'properly configures the sources of a set in search by name' do source = Source.new(fixture('spec-repos/test_repo')) sets = source.search_by_name('monkey', true) - sets.count.should == 1 + expect(sets.count).to eq(1) set = sets.first - set.name.should == 'BananaLib' - set.sources.map(&:name).should == %w(test_repo) + expect(set.name).to eq('BananaLib') + expect(set.sources.map(&:name)).to eq(%w(test_repo)) end it 'can use regular expressions' do source = Source.new(fixture('spec-repos/test_repo')) sets = source.search_by_name('mon[ijk]ey', true) - sets.first.name.should == 'BananaLib' + expect(sets.first.name).to eq('BananaLib') end end end @@ -169,28 +169,28 @@ module Pod describe '#search_by_name' do it 'supports full text search' do sets = @source.search_by_name('monkey', true) - sets.map(&:name).should == ['BananaLib'] - sets.map(&:sources).should == [[@source]] + expect(sets.map(&:name)).to eq(['BananaLib']) + expect(sets.map(&:sources)).to eq([[@source]]) end it 'The search is case insensitive' do pods = @source.search_by_name('MONKEY', true) - pods.map(&:name).should == ['BananaLib'] + expect(pods.map(&:name)).to eq(['BananaLib']) end it 'supports partial matches' do pods = @source.search_by_name('MON', true) - pods.map(&:name).should == ['BananaLib'] + expect(pods.map(&:name)).to eq(['BananaLib']) end it "handles gracefully specification which can't be loaded" do - should.raise Informative do + expect do @source.specification('Faulty_spec', '1.0.0') - end.message.should.include 'Invalid podspec' + end.to raise_error(Informative, a_string_including('Invalid podspec')) - should.not.raise do + expect do @source.search_by_name('monkey', true) - end + end.not_to raise_error end end @@ -198,23 +198,23 @@ module Pod describe '#fuzzy_search' do it 'is case insensitive' do - @source.fuzzy_search('bananalib').name.should == 'BananaLib' + expect(@source.fuzzy_search('bananalib').name).to eq('BananaLib') end it 'matches misspells' do - @source.fuzzy_search('banalib').name.should == 'BananaLib' + expect(@source.fuzzy_search('banalib').name).to eq('BananaLib') end it 'matches suffixes' do - @source.fuzzy_search('Lib').name.should == 'BananaLib' + expect(@source.fuzzy_search('Lib').name).to eq('BananaLib') end it 'returns nil if there is no match' do - @source.fuzzy_search('12345').should.be.nil + expect(@source.fuzzy_search('12345')).to be_nil end it 'matches abbreviations' do - @source.fuzzy_search('BLib').name.should == 'BananaLib' + expect(@source.fuzzy_search('BLib').name).to eq('BananaLib') end end @@ -247,9 +247,9 @@ module Pod VCR.use_cassette('Source_fetch', :record => :new_episodes) do @source.expects(:update_git_repo).with(true) @source.versions('React') - @source.instance_variable_get(:@versions_by_name).count.should == 1 + expect(@source.instance_variable_get(:@versions_by_name).count).to eq(1) @source.send :update, true - @source.instance_variable_get(:@versions_by_name).should.be.empty + expect(@source.instance_variable_get(:@versions_by_name)).to be_empty end end end @@ -282,12 +282,12 @@ module Pod end it 'uses git diff with name only option' do - @source.expects(:`).with { |cmd| cmd.should.include('--name-only') }.returns('') + @source.expects(:`).with { |cmd| expect(cmd).to include('--name-only') }.returns('') @source.send :diff_until_commit_hash, 'DUMMY_HASH' end it 'finds diff of commits before/after repo update' do - @source.expects(:`).with { |cmd| cmd.should.include('DUMMY_HASH..HEAD') }.returns('') + @source.expects(:`).with { |cmd| expect(cmd).to include('DUMMY_HASH..HEAD') }.returns('') @source.send :diff_until_commit_hash, 'DUMMY_HASH' end end @@ -297,13 +297,15 @@ module Pod describe '#verify_compatibility!' do it 'raises while asked to version information of a source if it is not compatible' do @source.stubs(:metadata).returns(Source::Metadata.new('min' => '999.0')) - e = lambda { @source.verify_compatibility! }.should.raise Informative - e.message.should.match /Update CocoaPods/ - e.message.should.match /(currently using #{CORE_VERSION})/ + expect { @source.verify_compatibility! }.to raise_error(Informative) do |e| + expect(e.message).to match(/Update CocoaPods/) + expect(e.message).to match(/(currently using #{CORE_VERSION})/) + end @source.stubs(:metadata).returns(Source::Metadata.new('max' => '0.0.1')) - e = lambda { @source.verify_compatibility! }.should.raise Informative - e.message.should.match /Update CocoaPods/ - e.message.should.match /(currently using #{CORE_VERSION})/ + expect { @source.verify_compatibility! }.to raise_error(Informative) do |e| + expect(e.message).to match(/Update CocoaPods/) + expect(e.message).to match(/(currently using #{CORE_VERSION})/) + end end end @@ -311,13 +313,13 @@ module Pod describe 'Representations' do it 'returns the hash representation' do - @source.to_hash['BananaLib']['1.0']['name'].should == 'BananaLib' + expect(@source.to_hash['BananaLib']['1.0']['name']).to eq('BananaLib') end it 'returns the yaml representation' do yaml = @source.to_yaml - yaml.should.match /---/ - yaml.should.match /BananaLib:/ + expect(yaml).to match(/---/) + expect(yaml).to match(/BananaLib:/) end end @@ -332,7 +334,7 @@ module Pod describe 'In general' do it 'returns its name' do - @source.name.should == 'test_repo' + expect(@source.name).to eq('test_repo') end end @@ -340,36 +342,36 @@ module Pod describe '#pods' do it 'returns the available Pods' do - @source.pods.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec React) + expect(@source.pods).to eq(%w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec React)) end it 'raises if the repo does not exist' do path = fixture('spec-repos/non_existing') @source = Source.new(path) - should.raise Informative do + expect do @source.pods - end.message.should.match /Unable to find a source named: `non_existing`/ + end.to raise_error(Informative, /Unable to find a source named: `non_existing`/) end it "doesn't include the `.` and the `..` dir entries" do - @source.pods.should.not.include?('.') - @source.pods.should.not.include?('..') + expect(@source.pods).not_to include('.') + expect(@source.pods).not_to include('..') end it 'only consider directories' do File.stubs(:directory?).returns(false) Pathname.any_instance.stubs(:directory?).returns(false) - @source.pods.should == [] + expect(@source.pods).to eq([]) end it 'uses the `Specs` dir if it is present' do - @source.send(:specs_dir).to_s.should.end_with('test_repo/Specs') + expect(@source.send(:specs_dir).to_s).to end_with('test_repo/Specs') end it 'uses the root of the repo as the specs dir if the `Specs` folder is not present' do repo = fixture('spec-repos/test_repo_without_specs_dir') @source = Source.new(repo) - @source.send(:specs_dir).to_s.should.end_with('test_repo_without_specs_dir') + expect(@source.send(:specs_dir).to_s).to end_with('test_repo_without_specs_dir') end end @@ -377,25 +379,26 @@ module Pod describe '#versions' do it 'returns the versions for the given Pod' do - @source.versions('JSONKit').map(&:to_s).should == ['999.999.999', '1.13', '1.4'] + expect(@source.versions('JSONKit').map(&:to_s)).to eq(['999.999.999', '1.13', '1.4']) end it 'returns nil the Pod is unknown' do - @source.versions('Unknown_Pod').should.be.nil + expect(@source.versions('Unknown_Pod')).to be_nil end it 'raises if the name of the Pod is not provided' do - should.raise ArgumentError do + expect do @source.versions(nil) - end.message.should.match /No name/ + end.to raise_error(ArgumentError, /No name/) end it 'raises if a non-version-name directory is encountered' do Pathname.any_instance.stubs(:children).returns([Pathname.new('/Hello')]) Pathname.any_instance.stubs(:directory?).returns(true) - e = lambda { @source.versions('JSONKit') }.should.raise Informative - e.message.should.match /Hello/ - e.message.should.not.match /Malformed version number string/ + expect { @source.versions('JSONKit') }.to raise_error(Informative) do |e| + expect(e.message).to match(/Hello/) + expect(e.message).not_to match(/Malformed version number string/) + end end end @@ -404,32 +407,32 @@ module Pod describe '#specification' do it 'returns the specification for the given version of a Pod' do spec = @source.specification('JSONKit', '1.4') - spec.name.should == 'JSONKit' - spec.version.to_s.should == '1.4' + expect(spec.name).to eq('JSONKit') + expect(spec.version.to_s).to eq('1.4') end it 'returns nil if the Pod is unknown' do - should.raise StandardError do + expect do @source.specification('Unknown_Pod', '1.4') - end.message.should.match /Unable to find the specification Unknown_Pod/ + end.to raise_error(StandardError, /Unable to find the specification Unknown_Pod/) end it "raises if the version of the Pod doesn't exists" do - should.raise StandardError do + expect do @source.specification('JSONKit', '0.99.0') - end.message.should.match /Unable to find the specification JSONKit/ + end.to raise_error(StandardError, /Unable to find the specification JSONKit/) end it 'raises if the name of the Pod is not provided' do - should.raise ArgumentError do + expect do @source.specification(nil, '1.4') - end.message.should.match /No name/ + end.to raise_error(ArgumentError, /No name/) end it 'raises if the name of the Pod is not provided' do - should.raise ArgumentError do + expect do @source.specification('JSONKit', nil) - end.message.should.match /No version/ + end.to raise_error(ArgumentError, /No version/) end end @@ -438,25 +441,25 @@ module Pod describe '#specification_path' do it 'returns the path of a specification' do path = @source.specification_path('JSONKit', '1.4') - path.to_s.should.end_with?('test_repo/Specs/JSONKit/1.4/JSONKit.podspec') + expect(path.to_s).to end_with('test_repo/Specs/JSONKit/1.4/JSONKit.podspec') end it 'prefers JSON podspecs if one exists' do Pathname.any_instance.stubs(:exist?).returns(true) path = @source.specification_path('JSONSpec', '0.9') - path.to_s.should.end_with?('Specs/JSONSpec/0.9/JSONSpec.podspec.json') + expect(path.to_s).to end_with('Specs/JSONSpec/0.9/JSONSpec.podspec.json') end it 'raises if the name of the Pod is not provided' do - should.raise ArgumentError do + expect do @source.specification_path(nil, '1.4') - end.message.should.match /No name/ + end.to raise_error(ArgumentError, /No name/) end it 'raises if the name of the Pod is not provided' do - should.raise ArgumentError do + expect do @source.specification_path('JSONKit', nil) - end.message.should.match /No version/ + end.to raise_error(ArgumentError, /No version/) end end @@ -470,14 +473,14 @@ module Pod describe '#pods' do it 'returns the available Pods' do - @source.pods.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) + expect(@source.pods).to eq(%w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec)) end it 'returns corresponding pods for given specification paths' do paths = %w(Specs/BananaLib/1.0/BananaLib.podspec) - @source.pods_for_specification_paths(paths).should == %w(BananaLib) + expect(@source.pods_for_specification_paths(paths)).to eq(%w(BananaLib)) paths = %w(Specs/monkey/1.0.2/monkey.podspec Specs/JSONKit/1.4/JSONKit.podspec) - @source.pods_for_specification_paths(paths).should == %w(monkey JSONKit) + expect(@source.pods_for_specification_paths(paths)).to eq(%w(monkey JSONKit)) end end @@ -485,11 +488,11 @@ module Pod describe '#versions' do it 'returns the available versions of a Pod' do - @source.versions('JSONKit').map(&:to_s).should == ['999.999.999', '1.13', '1.4'] + expect(@source.versions('JSONKit').map(&:to_s)).to eq(['999.999.999', '1.13', '1.4']) end it 'returns nil if the Pod could not be found' do - @source.versions('Unknown_Pod').should.be.nil + expect(@source.versions('Unknown_Pod')).to be_nil end end @@ -498,8 +501,8 @@ module Pod describe '#specification' do it 'returns the specification for the given name and version' do spec = @source.specification('JSONKit', Version.new('1.4')) - spec.name.should == 'JSONKit' - spec.version.to_s.should == '1.4' + expect(spec.name).to eq('JSONKit') + expect(spec.version.to_s).to eq('1.4') end end @@ -508,7 +511,7 @@ module Pod describe '#all_specs' do it 'returns all the specifications' do expected = %w(BananaLib IncorrectPath JSONKit JSONSpec) - @source.all_specs.map(&:name).sort.uniq.should == expected + expect(@source.all_specs.map(&:name).sort.uniq).to eq(expected) end end @@ -517,8 +520,8 @@ module Pod describe '#set' do it 'returns the set of a given Pod' do set = @source.set('BananaLib') - set.name.should == 'BananaLib' - set.sources.should == [@source] + expect(set.name).to eq('BananaLib') + expect(set.sources).to eq([@source]) end end @@ -527,7 +530,7 @@ module Pod describe '#pod_sets' do it 'returns all the pod sets' do expected = %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) - @source.pod_sets.map(&:name).sort.uniq.should == expected + expect(@source.pod_sets.map(&:name).sort.uniq).to eq(expected) end end @@ -535,25 +538,25 @@ module Pod describe '#search' do it 'searches for the Pod with the given name' do - @source.search('BananaLib').name.should == 'BananaLib' + expect(@source.search('BananaLib').name).to eq('BananaLib') end it 'matches case' do - @source.search('bAnAnAlIb').should.be.nil? + expect(@source.search('bAnAnAlIb')).to be_nil end describe '#search_by_name' do it 'properly configures the sources of a set in search by name' do sets = @source.search_by_name('monkey', true) - sets.count.should == 1 + expect(sets.count).to eq(1) set = sets.first - set.name.should == 'BananaLib' - set.sources.map(&:name).should == %w(test_prefixed_repo) + expect(set.name).to eq('BananaLib') + expect(set.sources.map(&:name)).to eq(%w(test_prefixed_repo)) end it 'can use regular expressions' do sets = @source.search_by_name('mon[ijk]ey', true) - sets.first.name.should == 'BananaLib' + expect(sets.first.name).to eq('BananaLib') end end end @@ -563,28 +566,28 @@ module Pod describe '#search_by_name' do it 'supports full text search' do sets = @source.search_by_name('monkey', true) - sets.map(&:name).should == ['BananaLib'] - sets.map(&:sources).should == [[@source]] + expect(sets.map(&:name)).to eq(['BananaLib']) + expect(sets.map(&:sources)).to eq([[@source]]) end it 'The search is case insensitive' do pods = @source.search_by_name('MONKEY', true) - pods.map(&:name).should == ['BananaLib'] + expect(pods.map(&:name)).to eq(['BananaLib']) end it 'supports partial matches' do pods = @source.search_by_name('MON', true) - pods.map(&:name).should == ['BananaLib'] + expect(pods.map(&:name)).to eq(['BananaLib']) end it "handles gracefully specification which can't be loaded" do - should.raise Informative do + expect do @source.specification('Faulty_spec', '1.0.0') - end.message.should.include 'Invalid podspec' + end.to raise_error(Informative, a_string_including('Invalid podspec')) - should.not.raise do + expect do @source.search_by_name('monkey', true) - end + end.not_to raise_error end end @@ -592,23 +595,23 @@ module Pod describe '#fuzzy_search' do it 'is case insensitive' do - @source.fuzzy_search('bananalib').name.should == 'BananaLib' + expect(@source.fuzzy_search('bananalib').name).to eq('BananaLib') end it 'matches misspells' do - @source.fuzzy_search('banalib').name.should == 'BananaLib' + expect(@source.fuzzy_search('banalib').name).to eq('BananaLib') end it 'matches suffixes' do - @source.fuzzy_search('Lib').name.should == 'BananaLib' + expect(@source.fuzzy_search('Lib').name).to eq('BananaLib') end it 'returns nil if there is no match' do - @source.fuzzy_search('12345').should.be.nil + expect(@source.fuzzy_search('12345')).to be_nil end it 'matches abbreviations' do - @source.fuzzy_search('BLib').name.should == 'BananaLib' + expect(@source.fuzzy_search('BLib').name).to eq('BananaLib') end end @@ -616,13 +619,13 @@ module Pod describe 'Representations' do it 'returns the hash representation' do - @source.to_hash['BananaLib']['1.0']['name'].should == 'BananaLib' + expect(@source.to_hash['BananaLib']['1.0']['name']).to eq('BananaLib') end it 'returns the yaml representation' do yaml = @source.to_yaml - yaml.should.match /---/ - yaml.should.match /BananaLib:/ + expect(yaml).to match(/---/) + expect(yaml).to match(/BananaLib:/) end end @@ -630,18 +633,18 @@ module Pod describe '#pods' do it 'returns the available Pods' do - @source.pods.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) + expect(@source.pods).to eq(%w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec)) end it "doesn't include the `.` and the `..` dir entries" do - @source.pods.should.not.include?('.') - @source.pods.should.not.include?('..') + expect(@source.pods).not_to include('.') + expect(@source.pods).not_to include('..') end it 'only consider directories' do File.stubs(:directory?).returns(false) Pathname.any_instance.stubs(:directory?).returns(false) - @source.pods.should == [] + expect(@source.pods).to eq([]) end end @@ -649,19 +652,20 @@ module Pod describe '#versions' do it 'returns the versions for the given Pod' do - @source.versions('JSONKit').map(&:to_s).should == ['999.999.999', '1.13', '1.4'] + expect(@source.versions('JSONKit').map(&:to_s)).to eq(['999.999.999', '1.13', '1.4']) end it 'returns nil the Pod is unknown' do - @source.versions('Unknown_Pod').should.be.nil + expect(@source.versions('Unknown_Pod')).to be_nil end it 'raises if a non-version-name directory is encountered' do Pathname.any_instance.stubs(:children).returns([Pathname.new('/Hello')]) Pathname.any_instance.stubs(:directory?).returns(true) - e = lambda { @source.versions('JSONKit') }.should.raise Informative - e.message.should.match /Hello/ - e.message.should.not.match /Malformed version number string/ + expect { @source.versions('JSONKit') }.to raise_error(Informative) do |e| + expect(e.message).to match(/Hello/) + expect(e.message).not_to match(/Malformed version number string/) + end end end @@ -670,20 +674,20 @@ module Pod describe '#specification' do it 'returns the specification for the given version of a Pod' do spec = @source.specification('JSONKit', '1.4') - spec.name.should == 'JSONKit' - spec.version.to_s.should == '1.4' + expect(spec.name).to eq('JSONKit') + expect(spec.version.to_s).to eq('1.4') end it 'returns nil if the Pod is unknown' do - should.raise StandardError do + expect do @source.specification('Unknown_Pod', '1.4') - end.message.should.match /Unable to find the specification Unknown_Pod/ + end.to raise_error(StandardError, /Unable to find the specification Unknown_Pod/) end it "raises if the version of the Pod doesn't exists" do - should.raise StandardError do + expect do @source.specification('JSONKit', '0.99.0') - end.message.should.match /Unable to find the specification JSONKit/ + end.to raise_error(StandardError, /Unable to find the specification JSONKit/) end end @@ -692,7 +696,7 @@ module Pod describe '#specification_path' do it 'returns the path of a specification' do path = @source.specification_path('JSONKit', '1.4') - path.to_s.should.end_with?('test_prefixed_repo/Specs/1/3/f/JSONKit/1.4/JSONKit.podspec') + expect(path.to_s).to end_with('test_prefixed_repo/Specs/1/3/f/JSONKit/1.4/JSONKit.podspec') end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1025269cc..39bc7aebd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,7 +10,6 @@ require 'bundler/setup' require 'rspec' require 'mocha/api' -require 'spec_helper/bacon_compat' require 'cocoapods-core' # Helpers @@ -87,12 +86,8 @@ def self.warn(message) RSpec.configure do |config| config.mock_with :mocha - # Only `expect` is enabled: RSpec's own `should` syntax would otherwise - # replace the bacon-style `should` provided by BaconCompat. config.expect_with(:rspec) { |c| c.syntax = :expect } - config.extend BaconCompat::GroupExtensions - config.include BaconCompat::ExampleExtensions config.include SpecHelper::Fixture config.before do @@ -101,4 +96,4 @@ def self.warn(message) end end -Mocha::Configuration.prevent(:stubbing_non_existent_method) +Mocha.configure { |c| c.stubbing_non_existent_method = :prevent } diff --git a/spec/spec_helper/bacon_compat.rb b/spec/spec_helper/bacon_compat.rb deleted file mode 100644 index fd321d811..000000000 --- a/spec/spec_helper/bacon_compat.rb +++ /dev/null @@ -1,169 +0,0 @@ -require 'rspec/expectations' - -# Transitional shim that implements bacon's `should` assertion chain on top of -# RSpec, so the existing specs run unchanged under RSpec. -# -# RSpec's own `should` syntax is not a drop-in replacement: it only supports -# the operator forms (`should ==`, `should =~`, …), rejects `should !=`, and has -# no `.not`, `.be`, predicate, or `.raise` chaining. -# -# New specs should use `expect` syntax. Once the existing specs have been -# converted, this file should be deleted. -# -# Supported forms (all may be prefixed with `.not`, and `.be`/`.a`/`.an` are -# no-op connectors): -# -# obj.should == other obj.should.equal other # == -# obj.should != other # != -# obj.should =~ other obj.should.match other # obj =~ other -# obj.should.be < other # < > <= >= -# obj.should.be.identical_to o obj.should.be.same_as o # equal? -# obj.should.be.true obj.should.be.false # strict -# obj.should.satisfy { |o| … } -# obj.should.be.nil obj.should.include x # any predicate: -# # calls `nil?`, -# # `include?(x)` -# lambda { … }.should.raise(Klass) # returns the -# should.raise(Klass) { … } # exception -# should.not.raise { … } -# should.flunk 'reason' -# -module BaconCompat - class Should < BasicObject - def initialize(object) - @object = object - @negated = false - end - - def not(*args, &block) - @negated = !@negated - args.empty? ? self : be(*args, &block) - end - - def be(*args, &block) - return self if args.empty? - satisfy(*args, &block) - end - alias a be - alias an be - - def satisfy(description = '') - result = yield(@object) - ::RSpec::Expectations.fail_with(description) unless @negated ^ result - result - end - - def ==(other) - check(::RSpec::Matchers::BuiltIn::Eq.new(other)) - end - alias equal == - - def !=(other) - @negated = !@negated - self == other - end - - # Bacon calls the receiver's own `=~` (e.g. `Requirement#=~` checks whether - # a version satisfies it), which RSpec's `match` matcher does not. - def =~(other) - satisfy("#{negation}#{@object.inspect} =~ #{other.inspect} failed") { |o| o =~ other } - end - alias match =~ - - def identical_to(other) - check(::RSpec::Matchers::BuiltIn::Equal.new(other)) - end - alias same_as identical_to - alias equal? identical_to - - [:<, :>, :<=, :>=].each do |operator| - define_method(operator) do |other| - check(::RSpec::Matchers::BuiltIn::BeComparedTo.new(other, operator)) - end - end - - def true - check(::RSpec::Matchers::BuiltIn::Equal.new(true)) - end - - def false - check(::RSpec::Matchers::BuiltIn::Equal.new(false)) - end - - # Like bacon, defaults to RuntimeError, does not rescue other exceptions, - # and returns the raised exception so callers can inspect it. - def raise(*exceptions, &block) - callable = block || @object - if @negated - check(::RSpec::Matchers::BuiltIn::RaiseError.new(nil, nil), callable) - return false - end - - exceptions = [::RuntimeError] if exceptions.empty? - begin - callable.call - rescue *exceptions => e - return e - end - ::RSpec::Expectations.fail_with("expected #{exceptions.inspect} to be raised, but nothing was raised") - end - - def flunk(reason = 'Flunked') - ::RSpec::Expectations.fail_with(reason) - end - - # Anything else is a predicate: `should.be.empty` calls `empty?`. - def method_missing(name, *args, &block) - name = "#{name}?" if name.to_s =~ /\w[^?]\z/ - description = "#{negation}#{@object.inspect}.#{name}(#{args.map(&:inspect).join(', ')}) failed" - satisfy(description) { |o| o.__send__(name, *args, &block) } - end - - private - - def negation - @negated ? 'not ' : '' - end - - def check(matcher, actual = @object) - target = ::RSpec::Expectations::ExpectationTarget.for(actual, nil) - @negated ? target.not_to(matcher) : target.to(matcher) - true - end - end - - module ObjectExtensions - def should - Should.new(self) - end - end - - # Inside examples, rspec-core's one-liner `should` (MemoizedHelpers) takes - # precedence over Object#should, which breaks bare `should.raise { … }`. - module ExampleExtensions - def should - Should.new(self) - end - end - - def self.shared_blocks - @shared_blocks ||= {} - end - - # `behaves_like` evaluates a `shared` block in the current group, like bacon. - module GroupExtensions - def behaves_like(*names) - names.each { |name| class_exec(&BaconCompat.shared_blocks.fetch(name)) } - end - end -end - -Object.include(BaconCompat::ObjectExtensions) - -module Kernel - private - - def shared(name, &block) - BaconCompat.shared_blocks[name] = block - end -end diff --git a/spec/spec_helper/temporary_directory.rb b/spec/spec_helper/temporary_directory.rb index c6a1e919b..b6b598a2e 100644 --- a/spec/spec_helper/temporary_directory.rb +++ b/spec/spec_helper/temporary_directory.rb @@ -20,8 +20,8 @@ def teardown_temporary_directory temporary_directory.rmtree if temporary_directory.exist? end - # Bacon contexts are instances, so `extend` exposed these helpers to - # examples. RSpec groups are classes, so they need to be included too. + # Extending an example group wipes the temporary directory before each + # example and makes these helpers available inside examples. def self.extended(base) base.include(self) base.before do diff --git a/spec/specification/consumer_spec.rb b/spec/specification/consumer_spec.rb index 71b930776..30b7b5502 100644 --- a/spec/specification/consumer_spec.rb +++ b/spec/specification/consumer_spec.rb @@ -12,23 +12,22 @@ module Pod end it 'returns the specification' do - @consumer.spec.should == @spec + expect(@consumer.spec).to eq(@spec) end it 'returns the platform' do - @consumer.platform_name.should == :ios + expect(@consumer.platform_name).to eq(:ios) end it 'can be initialized with a platform instance' do @consumer = Specification::Consumer.new(@spec, Platform.new(:ios, '6.1')) - @consumer.platform_name.class.should == Symbol - @consumer.platform_name.should == :ios + expect(@consumer.platform_name.class).to eq(Symbol) + expect(@consumer.platform_name).to eq(:ios) end it 'raises if the specification does not supports the given platform' do platform = Platform.new(:ios, '4.3') - e = lambda { Specification::Consumer.new(@spec, platform) }.should.raise StandardError - e.message.should.match /not compatible with iOS 4.3/ + expect { Specification::Consumer.new(@spec, platform) }.to raise_error(StandardError, /not compatible with iOS 4.3/) end end @@ -50,123 +49,123 @@ module Pod it 'allows to specify whether the specification requires ARC' do @spec.requires_arc = false - @consumer.requires_arc?.should.be.false + expect(@consumer.requires_arc?).to be(false) end it 'requires arc by default' do - @consumer.requires_arc?.should.be.true + expect(@consumer.requires_arc?).to be(true) end it 'inherits where it requires arc from the parent' do @spec.requires_arc = false - @subspec_consumer.requires_arc?.should.be.false + expect(@subspec_consumer.requires_arc?).to be(false) end it "doesn't inherit whether it requires ARC from the parent if it is false" do @spec.requires_arc = true @subspec.requires_arc = false - @subspec_consumer.requires_arc?.should.be.false + expect(@subspec_consumer.requires_arc?).to be(false) end #----------------# it 'allows to specify the frameworks' do @spec.framework = %w(QuartzCore CoreData) - @consumer.frameworks.should == %w(QuartzCore CoreData) + expect(@consumer.frameworks).to eq(%w(QuartzCore CoreData)) end it 'allows to specify a single framework' do @spec.framework = 'QuartzCore' - @consumer.frameworks.should == %w(QuartzCore) + expect(@consumer.frameworks).to eq(%w(QuartzCore)) end it 'inherits the frameworks of the parent' do @spec.framework = 'QuartzCore' @subspec.framework = 'CoreData' - @subspec_consumer.frameworks.should == %w(QuartzCore CoreData) + expect(@subspec_consumer.frameworks).to eq(%w(QuartzCore CoreData)) end #------------------# it 'allows to specify the weak frameworks' do @spec.weak_frameworks = %w(Twitter iAd) - @consumer.weak_frameworks.should == %w(Twitter iAd) + expect(@consumer.weak_frameworks).to eq(%w(Twitter iAd)) end it 'allows to specify a single weak framework' do @spec.weak_framework = 'Twitter' - @consumer.weak_frameworks.should == %w(Twitter) + expect(@consumer.weak_frameworks).to eq(%w(Twitter)) end it 'inherits the weak frameworks of the parent' do @spec.weak_framework = 'Twitter' @subspec.weak_framework = 'iAd' - @subspec_consumer.weak_frameworks.should == %w(Twitter iAd) + expect(@subspec_consumer.weak_frameworks).to eq(%w(Twitter iAd)) end #------------------# it 'allows to specify the libraries' do @spec.libraries = 'z', 'xml2' - @consumer.libraries.should == %w(z xml2) + expect(@consumer.libraries).to eq(%w(z xml2)) end it 'allows to specify a single library' do @spec.library = 'z' - @consumer.libraries.should == %w(z) + expect(@consumer.libraries).to eq(%w(z)) end it 'inherits the libraries from the parent' do @spec.library = 'z' @subspec.library = 'xml2' - @subspec_consumer.libraries.should == %w(z xml2) + expect(@subspec_consumer.libraries).to eq(%w(z xml2)) end #------------------# it 'allows to specify compiler flags' do @spec.compiler_flags = %w(-Wdeprecated-implementations -Wunused-value) - @consumer.compiler_flags.should == %w(-Wdeprecated-implementations -Wunused-value) + expect(@consumer.compiler_flags).to eq(%w(-Wdeprecated-implementations -Wunused-value)) end it 'allows to specify a single compiler flag' do @spec.compiler_flag = '-Wdeprecated-implementations' - @consumer.compiler_flags.should == %w(-Wdeprecated-implementations) + expect(@consumer.compiler_flags).to eq(%w(-Wdeprecated-implementations)) end it 'inherits the compiler flags from the parent' do @spec.compiler_flag = '-Wdeprecated-implementations' @subspec.compiler_flag = '-Wunused-value' - @subspec_consumer.compiler_flags.should == %w(-Wdeprecated-implementations -Wunused-value) + expect(@subspec_consumer.compiler_flags).to eq(%w(-Wdeprecated-implementations -Wunused-value)) end it 'merges the compiler flags so values for platforms can be specified' do @spec.compiler_flags = '-Wdeprecated-implementations' @spec.ios.compiler_flags = '-Wunused-value' - @consumer.compiler_flags.should == %w(-Wdeprecated-implementations -Wunused-value) + expect(@consumer.compiler_flags).to eq(%w(-Wdeprecated-implementations -Wunused-value)) osx_consumer = Specification::Consumer.new(@spec, :osx) - osx_consumer.compiler_flags.should == %w(-Wdeprecated-implementations) + expect(osx_consumer.compiler_flags).to eq(%w(-Wdeprecated-implementations)) end #------------------# it 'allows to specify xcconfig settings' do @spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' } - @consumer.pod_target_xcconfig.should == { 'OTHER_LDFLAGS' => '-lObjC' } + expect(@consumer.pod_target_xcconfig).to eq({ 'OTHER_LDFLAGS' => '-lObjC' }) end it 'inherits the xcconfig values from the parent' do @spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' } @subspec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-Wl -no_compact_unwind' } - @subspec_consumer.pod_target_xcconfig.should == { 'OTHER_LDFLAGS' => '-lObjC -Wl -no_compact_unwind' } + expect(@subspec_consumer.pod_target_xcconfig).to eq({ 'OTHER_LDFLAGS' => '-lObjC -Wl -no_compact_unwind' }) end it 'merges the xcconfig values so values for platforms can be specified' do @spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' } @spec.ios.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-Wl -no_compact_unwind' } - @consumer.pod_target_xcconfig.should == { 'OTHER_LDFLAGS' => '-lObjC -Wl -no_compact_unwind' } + expect(@consumer.pod_target_xcconfig).to eq({ 'OTHER_LDFLAGS' => '-lObjC -Wl -no_compact_unwind' }) osx_consumer = Specification::Consumer.new(@spec, :osx) - osx_consumer.pod_target_xcconfig.should == { 'OTHER_LDFLAGS' => '-lObjC' } + expect(osx_consumer.pod_target_xcconfig).to eq({ 'OTHER_LDFLAGS' => '-lObjC' }) end it 'merges the legacy xcconfig attribute' do @@ -174,8 +173,8 @@ module Pod @spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' } @spec.user_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' } - @consumer.pod_target_xcconfig.should == { 'OTHER_LDFLAGS' => '-Wl -lObjC' } - @consumer.user_target_xcconfig.should == { 'OTHER_LDFLAGS' => '-Wl -lObjC' } + expect(@consumer.pod_target_xcconfig).to eq({ 'OTHER_LDFLAGS' => '-Wl -lObjC' }) + expect(@consumer.user_target_xcconfig).to eq({ 'OTHER_LDFLAGS' => '-Wl -lObjC' }) end #------------------# @@ -186,7 +185,7 @@ module Pod 'SOME_VAR' => 'SOME_VALUE', } @spec.info_plist = value - @consumer.info_plist.should == value + expect(@consumer.info_plist).to eq(value) end it 'does not inherit values from the parent' do @@ -196,17 +195,17 @@ module Pod @subspec.info_plist = { 'OTHER_VAR' => 'OTHER_VALUE', } - @subspec_consumer.info_plist.should == { + expect(@subspec_consumer.info_plist).to eq({ 'OTHER_VAR' => 'OTHER_VALUE', - } + }) end it 'allows specifying values by platform' do @spec.info_plist = { 'CFBundleIdentifier' => 'org.cocoapods.MyLib' } @spec.osx.info_plist = { 'CFBundleIdentifier' => 'org.cocoapods.MyLibOSX' } osx_consumer = Specification::Consumer.new(@spec, :osx) - osx_consumer.info_plist.should == { 'CFBundleIdentifier' => 'org.cocoapods.MyLibOSX' } - @consumer.info_plist.should == { 'CFBundleIdentifier' => 'org.cocoapods.MyLib' } + expect(osx_consumer.info_plist).to eq({ 'CFBundleIdentifier' => 'org.cocoapods.MyLibOSX' }) + expect(@consumer.info_plist).to eq({ 'CFBundleIdentifier' => 'org.cocoapods.MyLib' }) end end @@ -214,12 +213,12 @@ module Pod it 'allows to specify the contents of the prefix header' do @spec.prefix_header_contents = '#import ' - @consumer.prefix_header_contents.should == '#import ' + expect(@consumer.prefix_header_contents).to eq('#import ') end it 'allows to specify the contents of the prefix header as an array' do @spec.prefix_header_contents = ['#import ', '#import '] - @consumer.prefix_header_contents.should == "#import \n#import " + expect(@consumer.prefix_header_contents).to eq("#import \n#import ") end it 'strips the indentation of the prefix headers' do @@ -228,72 +227,72 @@ module Pod #import DESC @spec.prefix_header_contents = headers - @consumer.prefix_header_contents.should == "#import \n#import " + expect(@consumer.prefix_header_contents).to eq("#import \n#import ") end it 'inherits the contents of the prefix header' do @spec.prefix_header_contents = '#import ' - @subspec_consumer.prefix_header_contents.should == '#import ' + expect(@subspec_consumer.prefix_header_contents).to eq('#import ') end #------------------# it 'allows to specify the path of compiler header file' do @spec.prefix_header_file = 'iphone/include/prefix.pch' - @consumer.prefix_header_file.should == 'iphone/include/prefix.pch' + expect(@consumer.prefix_header_file).to eq('iphone/include/prefix.pch') end it 'inherits the path of compiler header file from the parent' do @spec.prefix_header_file = 'iphone/include/prefix.pch' - @subspec_consumer.prefix_header_file.should == 'iphone/include/prefix.pch' + expect(@subspec_consumer.prefix_header_file).to eq('iphone/include/prefix.pch') end #------------------# it 'allows to specify a module name' do @spec.module_name = 'Three20Core' - @consumer.module_name.should == 'Three20Core' + expect(@consumer.module_name).to eq('Three20Core') end #------------------# it 'allows to specify a directory to use for the headers' do @spec.header_dir = 'Three20Core' - @consumer.header_dir.should == 'Three20Core' + expect(@consumer.header_dir).to eq('Three20Core') end it 'inherits the directory to use for the headers from the parent' do @spec.header_dir = 'Three20Core' - @subspec_consumer.header_dir.should == 'Three20Core' + expect(@subspec_consumer.header_dir).to eq('Three20Core') end #------------------# it 'allows to specify a directory to preserver the namespacing of the headers' do @spec.header_mappings_dir = 'src/include' - @consumer.header_mappings_dir.should == 'src/include' + expect(@consumer.header_mappings_dir).to eq('src/include') end it 'inherits the directory to use for the headers from the parent' do @spec.header_mappings_dir = 'src/include' - @subspec_consumer.header_mappings_dir.should == 'src/include' + expect(@subspec_consumer.header_mappings_dir).to eq('src/include') end #------------------# it 'returns nil for test type for a root spec' do - @consumer.test_type.should.be.nil + expect(@consumer.test_type).to be_nil end it 'returns nil for test type for subspec' do - @subspec_consumer.test_type.should.be.nil + expect(@subspec_consumer.test_type).to be_nil end it 'returns the default test type for a test subspec' do @spec.test_spec {} test_spec = @spec.test_specs.first test_consumer = Specification::Consumer.new(test_spec, :ios) - test_consumer.test_type.should.be == :unit + expect(test_consumer.test_type).to eq(:unit) end it 'allows to specify the unit test type for a test subspec' do @@ -301,7 +300,7 @@ module Pod test_spec = @spec.test_specs.first test_spec.test_type = :unit test_consumer = Specification::Consumer.new(test_spec, :ios) - test_consumer.test_type.should.be == :unit + expect(test_consumer.test_type).to eq(:unit) end it 'allows to specify the ui test type for a test subspec' do @@ -309,7 +308,7 @@ module Pod test_spec = @spec.test_specs.first test_spec.test_type = :ui test_consumer = Specification::Consumer.new(test_spec, :ios) - test_consumer.test_type.should.be == :ui + expect(test_consumer.test_type).to eq(:ui) end it 'returns the test type as a symbol when consuming JSON specs' do @@ -318,7 +317,7 @@ module Pod test_spec.test_type = :unit json_spec = @spec.to_json test_consumer = Specification::Consumer.new(Specification.from_json(json_spec).test_specs.first, :ios) - test_consumer.test_type.should.be == :unit + expect(test_consumer.test_type).to eq(:unit) end it 'allows to specify whether the specification requires an app host' do @@ -326,7 +325,7 @@ module Pod test_spec = @spec.test_specs.first test_spec.requires_app_host = true test_consumer = Specification::Consumer.new(test_spec, :ios) - test_consumer.requires_app_host?.should.be.true + expect(test_consumer.requires_app_host?).to be(true) end it 'allows to specify a specific app host to use' do @@ -334,7 +333,7 @@ module Pod test_spec = @spec.test_specs.first test_spec.app_host_name = 'Foo/App' test_consumer = Specification::Consumer.new(test_spec, :ios) - test_consumer.app_host_name.should == 'Foo/App' + expect(test_consumer.app_host_name).to eq('Foo/App') end it 'returns the scheme configuration of a test spec' do @@ -342,19 +341,21 @@ module Pod test_spec = @spec.test_specs.first test_spec.scheme = { :launch_arguments => ['Arg1'] } test_consumer = Specification::Consumer.new(test_spec, :ios) - test_consumer.scheme.should == { :launch_arguments => ['Arg1'] } + expect(test_consumer.scheme).to eq({ :launch_arguments => ['Arg1'] }) end #------------------# it 'returns the script phases in correct format' do @spec.script_phases = { :name => 'Hello World', :script => 'echo "Hello World"' } - @consumer.script_phases.should == [{ :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :any }] + expect(@consumer.script_phases).to eq([{ :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :any }]) end it 'returns the script phases in correct format with optional options' do @spec.script_phases = { :name => 'Hello Ruby World', :script => 'puts "Hello Ruby World"', :shell_path => 'usr/bin/ruby' } - @consumer.script_phases.should == [{ :name => 'Hello Ruby World', :script => 'puts "Hello Ruby World"', :shell_path => 'usr/bin/ruby', :execution_position => :any }] + expect(@consumer.script_phases).to eq([ + { :name => 'Hello Ruby World', :script => 'puts "Hello Ruby World"', :shell_path => 'usr/bin/ruby', :execution_position => :any }, + ]) end it 'returns the script phases in correct format for multiple script phases' do @@ -362,37 +363,37 @@ module Pod { :name => 'Hello World', :script => 'echo "Hello World"' }, { :name => 'Hello Ruby World', :script => 'puts "Hello Ruby World"', :shell_path => 'usr/bin/ruby' }, ] - @consumer.script_phases.should == [ + expect(@consumer.script_phases).to eq([ { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :any }, { :name => 'Hello Ruby World', :script => 'puts "Hello Ruby World"', :shell_path => 'usr/bin/ruby', :execution_position => :any }, - ] + ]) end it 'handles multi-platform script phases' do @spec.ios.script_phases = { :name => 'Hello World iOS', :script => 'echo "Hello World iOS"' } - @consumer.script_phases.should == [{ :name => 'Hello World iOS', :script => 'echo "Hello World iOS"', :execution_position => :any }] + expect(@consumer.script_phases).to eq([{ :name => 'Hello World iOS', :script => 'echo "Hello World iOS"', :execution_position => :any }]) end it 'returns both global and multi platform script phases' do @spec.script_phases = { :name => 'Hello World', :script => 'echo "Hello World"' } @spec.ios.script_phases = { :name => 'Hello World iOS', :script => 'echo "Hello World iOS"', :execution_position => :any } - @consumer.script_phases.should == [ + expect(@consumer.script_phases).to eq([ { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :any }, { :name => 'Hello World iOS', :script => 'echo "Hello World iOS"', :execution_position => :any }, - ] + ]) end it 'retains the value set for execution position' do @spec.script_phases = { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :before_compile } @spec.ios.script_phases = { :name => 'Hello World iOS', :script => 'echo "Hello World iOS"', :execution_position => :after_compile } - @consumer.script_phases.should == [ + expect(@consumer.script_phases).to eq([ { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :before_compile }, { :name => 'Hello World iOS', :script => 'echo "Hello World iOS"', :execution_position => :after_compile }, - ] + ]) end it 'returns the empty array if no script phases have been specified' do - @consumer.script_phases.should == [] + expect(@consumer.script_phases).to eq([]) end end @@ -413,156 +414,156 @@ module Pod it "doesn't inherits the files patterns from the parent" do @spec.source_files = ['lib_classes/**/*'] @subspec.source_files = ['subspec_classes/**/*'] - @subspec_consumer.source_files.should == ['subspec_classes/**/*'] + expect(@subspec_consumer.source_files).to eq(['subspec_classes/**/*']) end it 'wraps strings in an array' do @spec.source_files = 'lib_classes/**/*' - @consumer.source_files.should == ['lib_classes/**/*'] + expect(@consumer.source_files).to eq(['lib_classes/**/*']) end #------------------# it 'returns the source files' do @spec.source_files = ['lib_classes/**/*'] - @consumer.source_files.should == ['lib_classes/**/*'] + expect(@consumer.source_files).to eq(['lib_classes/**/*']) end #------------------# it 'returns the public headers files' do @spec.public_header_files = ['include/**/*'] - @consumer.public_header_files.should == ['include/**/*'] + expect(@consumer.public_header_files).to eq(['include/**/*']) end it 'returns the project headers files' do @spec.project_header_files = ['project/**/*'] - @consumer.project_header_files.should == ['project/**/*'] + expect(@consumer.project_header_files).to eq(['project/**/*']) end it 'returns the private headers files' do @spec.private_header_files = ['private/**/*'] - @consumer.private_header_files.should == ['private/**/*'] + expect(@consumer.private_header_files).to eq(['private/**/*']) end #------------------# it 'returns the frameworks bundles' do @spec.vendored_frameworks = ['MyFramework.framework', 'MyOtherFramework.framework'] - @consumer.vendored_frameworks.should == ['MyFramework.framework', 'MyOtherFramework.framework'] + expect(@consumer.vendored_frameworks).to eq(['MyFramework.framework', 'MyOtherFramework.framework']) end #------------------# it 'returns the library files' do @spec.vendored_libraries = ['libProj4.a', 'libJavaScriptCore.a'] - @consumer.vendored_libraries.should == ['libProj4.a', 'libJavaScriptCore.a'] + expect(@consumer.vendored_libraries).to eq(['libProj4.a', 'libJavaScriptCore.a']) end #------------------# it 'returns the on demand resources specified as a string wrapped in an array' do @spec.on_demand_resources = { 'Maps' => 'MapView/Map/Resources/*.png' } - @consumer.on_demand_resources.should == { 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :download_on_demand } } + expect(@consumer.on_demand_resources).to eq({ 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :download_on_demand } }) end it 'returns the on demand resources specified as an array wrapped in an array' do @spec.on_demand_resources = { 'Levels' => %w[Levels/Level1/Resources/*.png Levels/Level2/Resources/*.png] } - @consumer.on_demand_resources.should == { + expect(@consumer.on_demand_resources).to eq({ 'Levels' => { :paths => %w[Levels/Level1/Resources/*.png Levels/Level2/Resources/*.png], :category => :download_on_demand }, - } + }) end it 'handles multi-platform on demand resources' do @spec.ios.on_demand_resources = { 'Maps' => 'MapView/Map/Resources/*.png' } - @consumer.on_demand_resources.should == { 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :download_on_demand } } + expect(@consumer.on_demand_resources).to eq({ 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :download_on_demand } }) end it 'handles on demand resources with categories' do @spec.on_demand_resources = { 'Maps' => { :paths => 'MapView/Map/Resources/*.png', :category => :initial_install } } - @consumer.on_demand_resources.should == { 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :initial_install } } + expect(@consumer.on_demand_resources).to eq({ 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :initial_install } }) end it 'handles on demand resources with keys and values as strings' do @spec.on_demand_resources = { 'Maps' => { 'paths' => 'MapView/Map/Resources/*.png', 'category' => 'initial_install' } } - @consumer.on_demand_resources.should == { 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :initial_install } } + expect(@consumer.on_demand_resources).to eq({ 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :initial_install } }) end it 'merges multi platform on demand resources if needed' do @spec.on_demand_resources = { 'Maps' => 'MapView/Map/Resources/*.png' } @spec.ios.on_demand_resources = { 'Maps-iOS' => ['MapView/Map/iOS/Resources/*.png'] } - @consumer.on_demand_resources.should == { + expect(@consumer.on_demand_resources).to eq({ 'Maps' => { :paths => ['MapView/Map/Resources/*.png'], :category => :download_on_demand }, 'Maps-iOS' => { :paths => ['MapView/Map/iOS/Resources/*.png'], :category => :download_on_demand }, - } + }) end it 'returns the resource bundles' do @spec.resource_bundles = { 'MapBox' => 'MapView/Map/Resources/*.png' } - @consumer.resource_bundles.should == { 'MapBox' => ['MapView/Map/Resources/*.png'] } + expect(@consumer.resource_bundles).to eq({ 'MapBox' => ['MapView/Map/Resources/*.png'] }) end it 'handles multi-platform resource bundles' do @spec.ios.resource_bundles = { 'MapBox' => 'MapView/Map/Resources/*.png' } - @consumer.resource_bundles.should == { 'MapBox' => ['MapView/Map/Resources/*.png'] } + expect(@consumer.resource_bundles).to eq({ 'MapBox' => ['MapView/Map/Resources/*.png'] }) end it 'merges multi platform resource bundles if needed' do @spec.resource_bundles = { 'MapBox' => 'MapView/Map/Resources/*.png' } @spec.ios.resource_bundles = { 'MapBox-iOS' => ['MapView/Map/iOS/Resources/*.png'] } - @consumer.resource_bundles.should == { + expect(@consumer.resource_bundles).to eq({ 'MapBox' => ['MapView/Map/Resources/*.png'], 'MapBox-iOS' => ['MapView/Map/iOS/Resources/*.png'], - } + }) end it 'merges the file patterns of multi platform resource bundles if needed' do @spec.resource_bundles = { 'MapBox' => 'MapView/Map/Resources/*.png' } @spec.ios.resource_bundles = { 'MapBox' => ['MapView/Map/iOS/Resources/*.png'] } - @consumer.resource_bundles.should == { + expect(@consumer.resource_bundles).to eq({ 'MapBox' => ['MapView/Map/Resources/*.png', 'MapView/Map/iOS/Resources/*.png'], - } + }) end it 'returns the empty hash if no resource bundles have been specified' do - @consumer.resource_bundles.should == {} + expect(@consumer.resource_bundles).to eq({}) end #------------------# it 'returns the resources files' do @spec.resources = ['frameworks/CrashReporter.framework'] - @consumer.resources.should == ['frameworks/CrashReporter.framework'] + expect(@consumer.resources).to eq(['frameworks/CrashReporter.framework']) end it "doesn't inherit resources from the parent" do @spec.resources = ['parent_resources/*'] @subspec.resources = ['subspec_resources/*'] - @subspec_consumer.resources.should == ['subspec_resources/*'] + expect(@subspec_consumer.resources).to eq(['subspec_resources/*']) end it 'has a singular form for resources' do @spec.resource = 'lib_resources/file.png' - @consumer.resources.should == ['lib_resources/file.png'] + expect(@consumer.resources).to eq(['lib_resources/file.png']) end #------------------# it 'returns the paths to exclude' do @spec.exclude_files = 'Classes/**/unused.{h,m}' - @consumer.exclude_files.should == ['Classes/**/unused.{h,m}'] + expect(@consumer.exclude_files).to eq(['Classes/**/unused.{h,m}']) end #------------------# it 'returns the paths to preserve' do @spec.preserve_paths = ['Frameworks/*.framework'] - @consumer.preserve_paths.should == ['Frameworks/*.framework'] + expect(@consumer.preserve_paths).to eq(['Frameworks/*.framework']) end it 'can accept a single path to preserve' do @spec.preserve_path = 'Frameworks/*.framework' - @consumer.preserve_paths.should == ['Frameworks/*.framework'] + expect(@consumer.preserve_paths).to eq(['Frameworks/*.framework']) end end @@ -585,18 +586,18 @@ module Pod end it 'returns the dependencies on other Pods for the activated platform' do - @consumer.dependencies.should == [Dependency.new('AFNetworking')] + expect(@consumer.dependencies).to eq([Dependency.new('AFNetworking')]) end it 'inherits the dependencies of the parent' do - @subspec_consumer.dependencies.sort.should == [ - Dependency.new('AFNetworking'), Dependency.new('libPusher', '1.0')] + expect(@subspec_consumer.dependencies.sort).to eq([ + Dependency.new('AFNetworking'), Dependency.new('libPusher', '1.0')]) end it 'takes into account the dependencies specified for a platform' do osx_consumer = Specification::Consumer.new(@spec, :osx) - osx_consumer.dependencies.sort.should == [ - Dependency.new('AFNetworking'), Dependency.new('MagicalRecord')] + expect(osx_consumer.dependencies.sort).to eq([ + Dependency.new('AFNetworking'), Dependency.new('MagicalRecord')]) end end @@ -623,21 +624,21 @@ module Pod describe '#value_for_attribute' do it 'takes into account inheritance' do - @subspec_consumer.frameworks.should == %w(spec_framework subspec_framework) + expect(@subspec_consumer.frameworks).to eq(%w(spec_framework subspec_framework)) end it 'takes into account multiplatform values' do - @consumer.source_files.should == %w(spec_files ios_files) + expect(@consumer.source_files).to eq(%w(spec_files ios_files)) osx_consumer = Specification::Consumer.new(@spec, :osx) - osx_consumer.source_files.should == ['spec_files'] + expect(osx_consumer.source_files).to eq(['spec_files']) end it 'takes into account a default value if specified' do - @consumer.requires_arc.should == true + expect(@consumer.requires_arc).to eq(true) end it 'initializes the value to the empty container if no value could be resolved' do - @consumer.libraries.should == [] + expect(@consumer.libraries).to eq([]) end end @@ -647,20 +648,20 @@ module Pod it 'handles root specs' do attr = Specification::DSL.attributes[:source_files] value = @consumer.send(:value_with_inheritance, @spec, attr) - value.should == %w(spec_files ios_files) + expect(value).to eq(%w(spec_files ios_files)) end it 'takes into account the value of the parent if needed' do attr = Specification::DSL.attributes[:frameworks] value = @consumer.send(:value_with_inheritance, @subspec, attr) - value.should == %w(spec_framework subspec_framework) + expect(value).to eq(%w(spec_framework subspec_framework)) end it "doesn't inherits value of the parent if the attribute is not inherited" do attr = Specification::DSL.attributes[:source_files] attr.stubs(:inherited?).returns(false) value = @consumer.send(:value_with_inheritance, @subspec, attr) - value.should == ['subspec_files'] + expect(value).to eq(['subspec_files']) end end @@ -671,13 +672,13 @@ module Pod attr = Specification::DSL.attributes[:source_files] osx_consumer = Specification::Consumer.new(@spec, :osx) value = osx_consumer.send(:raw_value_for_attribute, @spec, attr) - value.should == ['spec_files'] + expect(value).to eq(['spec_files']) end it 'takes into account the multi-platform values' do attr = Specification::DSL.attributes[:source_files] value = @consumer.send(:raw_value_for_attribute, @spec, attr) - value.should == %w(spec_files ios_files) + expect(value).to eq(%w(spec_files ios_files)) end end @@ -687,36 +688,36 @@ module Pod it 'returns the current value if the value to merge is nil' do attr = Specification::DSL::Attribute.new(:test, :container => Hash) result = @consumer.send(:merge_values, attr, 'value', nil) - result.should == 'value' + expect(result).to eq('value') end it 'returns the value to merge if the current value is nil' do attr = Specification::DSL::Attribute.new(:test, :container => Hash) result = @consumer.send(:merge_values, attr, nil, 'value') - result.should == 'value' + expect(result).to eq('value') end it 'handles boolean values' do attr = Specification::DSL::Attribute.new(:test, :types => [TrueClass, FalseClass]) - @consumer.send(:merge_values, attr, false, nil).should == false - @consumer.send(:merge_values, attr, false, false).should == false - @consumer.send(:merge_values, attr, false, true).should == true - @consumer.send(:merge_values, attr, true, false).should == false + expect(@consumer.send(:merge_values, attr, false, nil)).to eq(false) + expect(@consumer.send(:merge_values, attr, false, false)).to eq(false) + expect(@consumer.send(:merge_values, attr, false, true)).to eq(true) + expect(@consumer.send(:merge_values, attr, true, false)).to eq(false) end it 'concatenates the values of attributes contained in an array' do attr = Specification::DSL::Attribute.new(:test, :container => Array) result = @consumer.send(:merge_values, attr, 'CoreGraphics', 'CoreData') - result.should == %w(CoreGraphics CoreData) + expect(result).to eq(%w(CoreGraphics CoreData)) end it 'handles hashes while merging values' do attr = Specification::DSL::Attribute.new(:test, :container => Hash) result = @consumer.send(:merge_values, attr, { :value1 => '1' }, :value2 => '2') - result.should == { + expect(result).to eq({ :value1 => '1', :value2 => '2', - } + }) end it 'merges the values of the keys of hashes contained in an array' do @@ -724,7 +725,7 @@ module Pod value = { :resources => %w(A B) } value_to_mege = { :resources => 'C' } result = @consumer.send(:merge_values, attr, value, value_to_mege) - result.should == { :resources => %w(A B C) } + expect(result).to eq({ :resources => %w(A B C) }) end it 'merges the values of the keys of hashes contained in a string' do @@ -732,7 +733,7 @@ module Pod value = { 'OTHER_LDFLAGS' => '-lObjC' } value_to_mege = { 'OTHER_LDFLAGS' => '-framework SystemConfiguration' } result = @consumer.send(:merge_values, attr, value, value_to_mege) - result.should == { 'OTHER_LDFLAGS' => '-lObjC -framework SystemConfiguration' } + expect(result).to eq({ 'OTHER_LDFLAGS' => '-lObjC -framework SystemConfiguration' }) end it 'returns the original value if the attribute is a string' do @@ -740,7 +741,7 @@ module Pod existing_value = 'header_dir_1' value_to_mege = 'header_dir_2' result = @consumer.send(:merge_values, attr, existing_value, value_to_mege) - result.should == 'header_dir_2' + expect(result).to eq('header_dir_2') end end diff --git a/spec/specification/dsl/attribute_spec.rb b/spec/specification/dsl/attribute_spec.rb index 5c14048d6..9163aed4e 100644 --- a/spec/specification/dsl/attribute_spec.rb +++ b/spec/specification/dsl/attribute_spec.rb @@ -5,22 +5,22 @@ module Pod describe 'In general' do it 'returns the name' do attr = Attribute.new('name', {}) - attr.name.should == 'name' + expect(attr.name).to eq('name') end it 'raises for not recognized options' do opts = { :unrecognized => true } - lambda { Attribute.new('name', opts) }.should.raise StandardError + expect { Attribute.new('name', opts) }.to raise_error(StandardError) end it 'returns a string representation suitable for UI' do s = 'Specification attribute `name`' - Attribute.new('name', {}).to_s.should == s + expect(Attribute.new('name', {}).to_s).to eq(s) end it 'returns the accepted classes for the value of the attribute' do opts = { :types => [String], :container => Array } - Attribute.new('name', opts).supported_types.should == [String, Array] + expect(Attribute.new('name', opts).supported_types).to eq([String, Array]) end end @@ -32,53 +32,53 @@ module Pod end it 'is multi platform by default' do - @attr.should.be.multi_platform + expect(@attr).to be_multi_platform end it 'is not inherited by default' do - @attr.should.not.be.inherited + expect(@attr).not_to be_inherited end it 'is not root only by default' do - @attr.should.not.be.root_only + expect(@attr).not_to be_root_only end it 'is not required by default' do - @attr.should.not.be.required + expect(@attr).not_to be_required end it "doesn't want a singular form by default" do - @attr.should.not.be.required + expect(@attr).not_to be_required end it 'is not a file pattern by default' do - @attr.should.not.be.file_patterns + expect(@attr).not_to be_file_patterns end it "doesn't specifies a container by default" do - @attr.container.should.be.nil + expect(@attr.container).to be_nil end it "doesn't specifies accepted keys for a hash container by default" do - @attr.keys.should.be.nil + expect(@attr.keys).to be_nil end it "doesn't specifies a default value by default (multi platform)" do - @attr.default_value.should.be.nil + expect(@attr.default_value).to be_nil end it "doesn't specifies a default value by default (no multi platform)" do @attr = Attribute.new('name', :multi_platform => false) - @attr.default_value.should.be.nil + expect(@attr.default_value).to be_nil end it 'specifies `String` as the default type' do - @attr.types.should == [String] + expect(@attr.types).to eq([String]) end it 'is inherited by default if it is root only' do attr = Attribute.new('name', :root_only => true) - attr.should.be.inherited + expect(attr).to be_inherited end end @@ -87,30 +87,30 @@ module Pod describe 'Accessors support' do it 'returns the default value' do attr1 = Attribute.new(:frameworks, :multi_platform => false) - attr1.default.should.be.nil? + expect(attr1.default).to be_nil attr2 = Attribute.new(:frameworks, :multi_platform => false, :default_value => ['Cocoa']) - attr2.default.should == ['Cocoa'] + expect(attr2.default).to eq(['Cocoa']) end it 'returns the default value for a platform' do attr = Attribute.new(:frameworks, :default_value => ['CoreGraphics']) - attr.default(:ios).should == ['CoreGraphics'] + expect(attr.default(:ios)).to eq(['CoreGraphics']) end it 'allows to specify the default value per platform' do attr = Attribute.new(:frameworks, :ios_default => ['CoreGraphics']) - attr.default(:ios).should == ['CoreGraphics'] - attr.default(:osx).should.be.nil + expect(attr.default(:ios)).to eq(['CoreGraphics']) + expect(attr.default(:osx)).to be_nil end it 'returns the name of the writer method' do attr = Attribute.new(:frameworks, :singularize => true) - attr.writer_name.should == 'frameworks=' + expect(attr.writer_name).to eq('frameworks=') end it 'returns the singular form of the writer method' do attr = Attribute.new(:frameworks, :singularize => true) - attr.writer_singular_form.should == 'framework=' + expect(attr.writer_singular_form).to eq('framework=') end end end diff --git a/spec/specification/dsl/attribute_support_spec.rb b/spec/specification/dsl/attribute_support_spec.rb index 1e551292a..f40b49ad4 100644 --- a/spec/specification/dsl/attribute_support_spec.rb +++ b/spec/specification/dsl/attribute_support_spec.rb @@ -15,39 +15,39 @@ class << self #-------------------------------------------------------------------------# it 'stores the attributes' do - TestClass.attributes.keys.sort_by(&:to_s).should == [ + expect(TestClass.attributes.keys.sort_by(&:to_s)).to eq([ :test_attribute, :test_root_attribute - ] + ]) end it 'declares a root attribute' do attr = TestClass.attributes[:test_root_attribute] - attr.class.should == Specification::DSL::Attribute + expect(attr.class).to eq(Specification::DSL::Attribute) end it 'declares root attributes with the `root_only` option' do attr = TestClass.attributes[:test_root_attribute] - attr.should.be.root_only? + expect(attr).to be_root_only end it 'declares root attributes without the `multi_platform` option' do attr = TestClass.attributes[:test_root_attribute] - attr.should.not.be.multi_platform? + expect(attr).not_to be_multi_platform end it 'declares a normal attribute' do attr = TestClass.attributes[:test_attribute] - attr.class.should == Specification::DSL::Attribute + expect(attr.class).to eq(Specification::DSL::Attribute) end it 'declares normal attributes without the `root_only` option' do attr = TestClass.attributes[:test_attribute] - attr.should.not.be.root_only? + expect(attr).not_to be_root_only end it 'declares root attributes with the `multi_platform` option by default' do attr = TestClass.attributes[:test_attribute] - attr.should.be.multi_platform? + expect(attr).to be_multi_platform end #-------------------------------------------------------------------------# diff --git a/spec/specification/dsl/platform_proxy_spec.rb b/spec/specification/dsl/platform_proxy_spec.rb index d1cc02356..40dba2a23 100644 --- a/spec/specification/dsl/platform_proxy_spec.rb +++ b/spec/specification/dsl/platform_proxy_spec.rb @@ -27,39 +27,38 @@ module Pod it 'does not respond to non multiplatform attributes' do attrs = Specification::DSL.attributes.values.select { |a| !a.multi_platform? } attrs.each do |attr| - e = lambda { @proxy.send(attr.writer_name, 'a_value') }.should.raise NoMethodError - e.message.should.include "`#{attr.name}` cannot be set per-platform" + expect { @proxy.send(attr.writer_name, 'a_value') }.to raise_error(NoMethodError, a_string_including("`#{attr.name}` cannot be set per-platform")) end end it 'does not respond to platform=' do - lambda { @proxy.platform = :ios, '9.0' }.should.raise NoMethodError + expect { @proxy.platform = :ios, '9.0' }.to raise_error(NoMethodError) end it 'allows to specify a dependency' do @proxy.dependency('A-pod', '~> 1.0') - @spec.attributes_hash['ios']['dependencies'].should == { + expect(@spec.attributes_hash['ios']['dependencies']).to eq({ 'A-pod' => ['~> 1.0'], - } + }) end it 'allows to specify a dependency without version requirements' do @proxy.dependency('A-pod') - @spec.attributes_hash['ios']['dependencies'].should == { + expect(@spec.attributes_hash['ios']['dependencies']).to eq({ 'A-pod' => [], - } + }) end it 'allows to specify a dependency with multiple version requirements' do @proxy.dependency('A-pod', '~> 1.0', '< 2.0') - @spec.attributes_hash['ios']['dependencies'].should == { + expect(@spec.attributes_hash['ios']['dependencies']).to eq({ 'A-pod' => ['~> 1.0', '< 2.0'], - } + }) end it 'allows to declare the deployment target' do @proxy.deployment_target = '6.0' - @spec.attributes_hash['platforms']['ios'].should == '6.0' + expect(@spec.attributes_hash['platforms']['ios']).to eq('6.0') end end end diff --git a/spec/specification/dsl_spec.rb b/spec/specification/dsl_spec.rb index 312349aac..33fd10dc4 100644 --- a/spec/specification/dsl_spec.rb +++ b/spec/specification/dsl_spec.rb @@ -11,124 +11,124 @@ module Pod it 'allows to specify the name' do @spec.name = 'Name' - @spec.attributes_hash['name'].should == 'Name' + expect(@spec.attributes_hash['name']).to eq('Name') end it 'allows to specify the version' do @spec.version = '1.0' - @spec.attributes_hash['version'].should == '1.0' + expect(@spec.attributes_hash['version']).to eq('1.0') end it 'allows specifying the swift version in singular form' do @spec.swift_version = '3.0' - @spec.attributes_hash['swift_versions'].should == '3.0' + expect(@spec.attributes_hash['swift_versions']).to eq('3.0') end it 'allows specifying multiple swift versions in singular form' do @spec.swift_version = '3.0', '4.0' - @spec.attributes_hash['swift_versions'].should == ['3.0', '4.0'] + expect(@spec.attributes_hash['swift_versions']).to eq(['3.0', '4.0']) end it 'allows specifying multiple swift versions as an array in singular form' do @spec.swift_version = ['3.0', '4.0'] - @spec.attributes_hash['swift_versions'].should == ['3.0', '4.0'] + expect(@spec.attributes_hash['swift_versions']).to eq(['3.0', '4.0']) end it 'allows specifying the swift version in plural form' do @spec.swift_versions = '3.0' - @spec.attributes_hash['swift_versions'].should == '3.0' + expect(@spec.attributes_hash['swift_versions']).to eq('3.0') end it 'allows specifying multiple swift versions in plural form' do @spec.swift_versions = '3.0', '4.0' - @spec.attributes_hash['swift_versions'].should == ['3.0', '4.0'] + expect(@spec.attributes_hash['swift_versions']).to eq(['3.0', '4.0']) end it 'allows specifying multiple swift versions as an array in plural form' do @spec.swift_versions = ['3.0', '4.0'] - @spec.attributes_hash['swift_versions'].should == ['3.0', '4.0'] + expect(@spec.attributes_hash['swift_versions']).to eq(['3.0', '4.0']) end it 'allows specifying the cocoapods version' do @spec.cocoapods_version = '>= 0.36' - @spec.attributes_hash['cocoapods_version'].should == '>= 0.36' + expect(@spec.attributes_hash['cocoapods_version']).to eq('>= 0.36') end it 'allows to specify the authors' do hash = { 'Darth Vader' => 'darthvader@darkside.com', 'Wookiee' => 'wookiee@aggrrttaaggrrt.com' } @spec.authors = hash - @spec.attributes_hash['authors'].should == hash + expect(@spec.attributes_hash['authors']).to eq(hash) end it 'allows to specify the authors in the singular form' do @spec.author = { 'orta' => 'orta.therox@gmail.com' } - @spec.attributes_hash['authors'].should == { 'orta' => 'orta.therox@gmail.com' } + expect(@spec.attributes_hash['authors']).to eq({ 'orta' => 'orta.therox@gmail.com' }) end it 'allows to specify the social media contact' do @spec.social_media_url = 'https://twitter.com/cocoapods' - @spec.attributes_hash['social_media_url'].should == 'https://twitter.com/cocoapods' + expect(@spec.attributes_hash['social_media_url']).to eq('https://twitter.com/cocoapods') end it 'allows to specify the readme' do @spec.readme = 'https://www.example.com/readme' - @spec.attributes_hash['readme'].should == 'https://www.example.com/readme' + expect(@spec.attributes_hash['readme']).to eq('https://www.example.com/readme') end it 'allows to specify the changelog' do @spec.changelog = 'https://www.example.com/changelog' - @spec.attributes_hash['changelog'].should == 'https://www.example.com/changelog' + expect(@spec.attributes_hash['changelog']).to eq('https://www.example.com/changelog') end it 'allows to specify the license' do @spec.license = { :type => 'MIT', :file => 'MIT-LICENSE' } - @spec.attributes_hash['license'].should == { 'type' => 'MIT', 'file' => 'MIT-LICENSE' } + expect(@spec.attributes_hash['license']).to eq({ 'type' => 'MIT', 'file' => 'MIT-LICENSE' }) end it 'allows to specify the homepage' do @spec.homepage = 'www.example.com' - @spec.attributes_hash['homepage'].should == 'www.example.com' + expect(@spec.attributes_hash['homepage']).to eq('www.example.com') end it 'allows to specify the source' do @spec.source = { :git => 'www.example.com/repo.git' } - @spec.attributes_hash['source'].should == { 'git' => 'www.example.com/repo.git' } + expect(@spec.attributes_hash['source']).to eq({ 'git' => 'www.example.com/repo.git' }) end it 'allows to specify the summary' do @spec.summary = 'text' - @spec.attributes_hash['summary'].should == 'text' + expect(@spec.attributes_hash['summary']).to eq('text') end it 'allows to specify the description' do @spec.description = 'text' - @spec.attributes_hash['description'].should == 'text' + expect(@spec.attributes_hash['description']).to eq('text') end it 'allows to specify the documentation URL' do @spec.documentation_url = 'www.example.com' - @spec.attributes_hash['documentation_url'].should == 'www.example.com' + expect(@spec.attributes_hash['documentation_url']).to eq('www.example.com') end it 'allows to specify a prepare command' do @spec.prepare_command = 'ruby build_files.rb' - @spec.attributes_hash['prepare_command'].should == 'ruby build_files.rb' + expect(@spec.attributes_hash['prepare_command']).to eq('ruby build_files.rb') end it 'allows to specify whether the Pod has a static_framework' do @spec.static_framework = true - @spec.attributes_hash['static_framework'].should == true + expect(@spec.attributes_hash['static_framework']).to eq(true) end it 'allows to specify whether the Pod has been deprecated' do @spec.deprecated = true - @spec.attributes_hash['deprecated'].should == true + expect(@spec.attributes_hash['deprecated']).to eq(true) end it 'allows to specify the name of the Pod that this one has been deprecated in favor of' do @spec.deprecated_in_favor_of = 'NewMoreAwesomePod' - @spec.attributes_hash['deprecated_in_favor_of'].should == 'NewMoreAwesomePod' + expect(@spec.attributes_hash['deprecated_in_favor_of']).to eq('NewMoreAwesomePod') end it 'allows specifying info.plist values' do @@ -136,7 +136,7 @@ module Pod 'SOME_VAR' => 'SOME_VALUE', } @spec.info_plist = hash - @spec.attributes_hash['info_plist'].should == hash + expect(@spec.attributes_hash['info_plist']).to eq(hash) end end @@ -151,52 +151,51 @@ module Pod it 'allows to specify the supported platform' do @spec.platform = :ios - @spec.attributes_hash['platforms'].should == { 'ios' => nil } + expect(@spec.attributes_hash['platforms']).to eq({ 'ios' => nil }) end it 'allows to specify the deployment target along the supported platform as a shortcut' do @spec.platform = :ios, '6.0' - @spec.attributes_hash['platforms'].should == { 'ios' => '6.0' } + expect(@spec.attributes_hash['platforms']).to eq({ 'ios' => '6.0' }) end it 'allows to specify a deployment target for each platform' do @spec.ios.deployment_target = '6.0' - @spec.attributes_hash['platforms']['ios'].should == '6.0' + expect(@spec.attributes_hash['platforms']['ios']).to eq('6.0') end it "doesn't allows to specify the deployment target without a platform" do - e = lambda { @spec.deployment_target = '6.0' }.should.raise Informative - e.message.should.match /declared only per platform/ + expect { @spec.deployment_target = '6.0' }.to raise_error(Informative, /declared only per platform/) end it 'allows to specify visionOS as supported platform' do @spec.platform = :visionos - @spec.attributes_hash['platforms'].should == { 'visionos' => nil } + expect(@spec.attributes_hash['platforms']).to eq({ 'visionos' => nil }) end it 'allows to specify a deployment target for the visionOS platform' do @spec.visionos.deployment_target = '1.0' - @spec.attributes_hash['platforms']['visionos'].should == '1.0' + expect(@spec.attributes_hash['platforms']['visionos']).to eq('1.0') end it 'allows to specify watchOS as supported platform' do @spec.platform = :watchos - @spec.attributes_hash['platforms'].should == { 'watchos' => nil } + expect(@spec.attributes_hash['platforms']).to eq({ 'watchos' => nil }) end it 'allows to specify a deployment target for the watchOS platform' do @spec.watchos.deployment_target = '2.0' - @spec.attributes_hash['platforms']['watchos'].should == '2.0' + expect(@spec.attributes_hash['platforms']['watchos']).to eq('2.0') end it 'allows to specify tvOS as supported platform' do @spec.platform = :tvos - @spec.attributes_hash['platforms'].should == { 'tvos' => nil } + expect(@spec.attributes_hash['platforms']).to eq({ 'tvos' => nil }) end it 'allows to specify a deployment target for the tvOS platform' do @spec.tvos.deployment_target = '9.0' - @spec.attributes_hash['platforms']['tvos'].should == '9.0' + expect(@spec.attributes_hash['platforms']['tvos']).to eq('9.0') end end @@ -214,98 +213,98 @@ module Pod describe 'dependency' do it 'allows to specify a dependencies' do @spec.dependencies = { 'SVStatusHUD' => ['~>1.0', '< 1.4'] } - @spec.attributes_hash['dependencies'].should == { 'SVStatusHUD' => ['~>1.0', '< 1.4'] } + expect(@spec.attributes_hash['dependencies']).to eq({ 'SVStatusHUD' => ['~>1.0', '< 1.4'] }) end it 'allows to specify a single dependency as a shortcut' do @spec.dependency('SVStatusHUD', '~>1.0', '< 1.4') - @spec.attributes_hash['dependencies'].should == { 'SVStatusHUD' => ['~>1.0', '< 1.4'] } + expect(@spec.attributes_hash['dependencies']).to eq({ 'SVStatusHUD' => ['~>1.0', '< 1.4'] }) end it 'allows to specify a single dependency as a shortcut with one version requirement' do @spec.dependency('SVStatusHUD', '~>1.0') - @spec.attributes_hash['dependencies'].should == { 'SVStatusHUD' => ['~>1.0'] } + expect(@spec.attributes_hash['dependencies']).to eq({ 'SVStatusHUD' => ['~>1.0'] }) end it 'allows to specify a single dependency as a shortcut with no version requirements' do @spec.dependency('SVStatusHUD') - @spec.attributes_hash['dependencies'].should == { 'SVStatusHUD' => [] } + expect(@spec.attributes_hash['dependencies']).to eq({ 'SVStatusHUD' => [] }) end it 'allows a dependency whose name matches part of one of its parents names' do @spec.subspec 'subspectest' do |sp| sp.subspec 'subsubspec' do |ssp| ssp.dependency('subspec') - ssp.attributes_hash['dependencies'].should == { 'subspec' => [] } + expect(ssp.attributes_hash['dependencies']).to eq({ 'subspec' => [] }) end end end it 'raises if the specification requires itself' do - should.raise Informative do + expect do @spec.dependency('Pod') - end.message.should.match /can't require itself/ + end.to raise_error(Informative, /can't require itself/) end it 'raises if the specification requires one of its parents' do @spec.subspec 'subspec' do |_sp| end subspec = @spec.subspecs.first - should.raise Informative do + expect do subspec.dependency('Pod') - end.message.should.match /can't require one of its parents/ + end.to raise_error(Informative, /can't require one of its parents/) # Ensure nested subspecs are prevented from requiring one of their parents @spec.subspec 'subspec' do |sp| sp.subspec 'subsubspec' do |ssp| - should.raise Informative do + expect do ssp.dependency('Pod/subspec') - end.message.should.match /can't require one of its parents/ + end.to raise_error(Informative, /can't require one of its parents/) end end end it 'raises if the requirements are not supported' do - should.raise Informative do + expect do @spec.dependency('SVProgressHUD', :head) - end.message.should.match /Unsupported version requirements. \[\:head\] is not valid/ + end.to raise_error(Informative, /Unsupported version requirements. \[\:head\] is not valid/) end it 'raises if the requirements specify :git' do - should.raise Informative do + expect do @spec.dependency('SVProgressHUD', :git => 'AnyPath') - end.message.should.match /Podspecs cannot specify the source of dependencies. The `:git` option is not supported.\.*/ + end.to raise_error(Informative, /Podspecs cannot specify the source of dependencies. The `:git` option is not supported.\.*/) end it 'raises if the requirements specify :path' do - should.raise Informative do + expect do @spec.dependency('SVProgressHUD', :path => 'AnyPath') - end.message.should.match /Podspecs cannot specify the source of dependencies. The `:path` option is not supported.\.*/ + end.to raise_error(Informative, /Podspecs cannot specify the source of dependencies. The `:path` option is not supported.\.*/) end it 'raises when attempting to assign a value to dependency' do - should.raise Informative do + expect do @spec.dependency = 'JSONKit', '1.5' - end.message.should.match /Cannot assign value to `dependency`. Did you mean: `dependency 'JSONKit', '1.5'`?/ + end.to raise_error(Informative, /Cannot assign value to `dependency`. Did you mean: `dependency 'JSONKit', '1.5'`?/) end describe 'configurations for dependency' do it 'stores the whitelisted configurations for a given dependency' do @spec.dependency('SVProgressHUD', :configurations => %w(Debug Release)) - @spec.attributes_hash['dependencies'].should == { 'SVProgressHUD' => [] } - @spec.attributes_hash['configuration_pod_whitelist'].should == { 'SVProgressHUD' => %w(debug release) } + expect(@spec.attributes_hash['dependencies']).to eq({ 'SVProgressHUD' => [] }) + expect(@spec.attributes_hash['configuration_pod_whitelist']).to eq({ 'SVProgressHUD' => %w(debug release) }) end it 'does not store the whitelisted configurations for a dependency if no configurations are specified' do @spec.dependency('SVProgressHUD') - @spec.attributes_hash['dependencies'].should == { 'SVProgressHUD' => [] } - @spec.attributes_hash['configuration_pod_whitelist'].should.be.nil + expect(@spec.attributes_hash['dependencies']).to eq({ 'SVProgressHUD' => [] }) + expect(@spec.attributes_hash['configuration_pod_whitelist']).to be_nil end it 'raises if a whitelisted configuration for a dependency is not supported' do - should.raise Informative do + expect do @spec.dependency('SVProgressHUD', :configurations => ['Beta']) - end.message.should.equal 'Only `Debug` & `Release` are allowed under configurations for dependency on `SVProgressHUD`. Found `beta`.' + end.to raise_error(Informative, 'Only `Debug` & `Release` are allowed under configurations for dependency on `SVProgressHUD`. Found `beta`.') end end end @@ -314,95 +313,95 @@ module Pod it 'allows to specify whether the specification requires ARC' do @spec.requires_arc = false - @spec.attributes_hash['requires_arc'].should == false + expect(@spec.attributes_hash['requires_arc']).to eq(false) end it 'allows to specify which files require ARC' do @spec.requires_arc = ['arc/*.{h,m}'] - @spec.attributes_hash['requires_arc'].should == ['arc/*.{h,m}'] + expect(@spec.attributes_hash['requires_arc']).to eq(['arc/*.{h,m}']) @spec.requires_arc = 'arc/*.{h,m}' - @spec.attributes_hash['requires_arc'].should == 'arc/*.{h,m}' + expect(@spec.attributes_hash['requires_arc']).to eq('arc/*.{h,m}') end it 'allows to specify the frameworks' do @spec.framework = %w(QuartzCore CoreData) - @spec.attributes_hash['frameworks'].should == %w(QuartzCore CoreData) + expect(@spec.attributes_hash['frameworks']).to eq(%w(QuartzCore CoreData)) end it 'allows to specify the weak frameworks' do @spec.weak_frameworks = %w(Twitter iAd) - @spec.attributes_hash['weak_frameworks'].should == %w(Twitter iAd) + expect(@spec.attributes_hash['weak_frameworks']).to eq(%w(Twitter iAd)) end it 'allows to specify the libraries' do @spec.libraries = 'z', 'xml2' - @spec.attributes_hash['libraries'].should == %w(z xml2) + expect(@spec.attributes_hash['libraries']).to eq(%w(z xml2)) end it 'allows to specify compiler flags' do @spec.compiler_flags = %w(-Wdeprecated-implementations -Wunused-value) - @spec.attributes_hash['compiler_flags'].should == %w(-Wdeprecated-implementations -Wunused-value) + expect(@spec.attributes_hash['compiler_flags']).to eq(%w(-Wdeprecated-implementations -Wunused-value)) end it 'allows to specify pod target xcconfig settings' do @spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' } - @spec.attributes_hash['pod_target_xcconfig'].should == { 'OTHER_LDFLAGS' => '-lObjC' } + expect(@spec.attributes_hash['pod_target_xcconfig']).to eq({ 'OTHER_LDFLAGS' => '-lObjC' }) end it 'allows to specify user target xcconfig settings' do @spec.user_target_xcconfig = { 'OTHER_CPLUSPLUSFLAGS' => '-std=c++1y' } - @spec.attributes_hash['user_target_xcconfig'].should == { 'OTHER_CPLUSPLUSFLAGS' => '-std=c++1y' } + expect(@spec.attributes_hash['user_target_xcconfig']).to eq({ 'OTHER_CPLUSPLUSFLAGS' => '-std=c++1y' }) end it 'allows to specify the contents of the prefix header' do @spec.prefix_header_contents = '#import ' - @spec.attributes_hash['prefix_header_contents'].should == '#import ' + expect(@spec.attributes_hash['prefix_header_contents']).to eq('#import ') end it 'allows to specify the path of compiler header file' do @spec.prefix_header_file = 'iphone/include/prefix.pch' - @spec.attributes_hash['prefix_header_file'].should == 'iphone/include/prefix.pch' + expect(@spec.attributes_hash['prefix_header_file']).to eq('iphone/include/prefix.pch') end it 'allows to skip prefix header file generation' do @spec.prefix_header_file = false - @spec.attributes_hash['prefix_header_file'].should == false + expect(@spec.attributes_hash['prefix_header_file']).to eq(false) end it 'allows to specify a directory to use for the headers' do @spec.header_dir = 'Three20Core' - @spec.attributes_hash['header_dir'].should == 'Three20Core' + expect(@spec.attributes_hash['header_dir']).to eq('Three20Core') end it 'allows to specify a directory to preserver the namespacing of the headers' do @spec.header_mappings_dir = 'src/include' - @spec.attributes_hash['header_mappings_dir'].should == 'src/include' + expect(@spec.attributes_hash['header_mappings_dir']).to eq('src/include') end it 'allows to specify a custom module name' do @spec.module_name = 'Three20' - @spec.attributes_hash['module_name'].should == 'Three20' + expect(@spec.attributes_hash['module_name']).to eq('Three20') end it 'allows to specify a custom module map file' do @spec.module_map = 'module.modulemap' - @spec.attributes_hash['module_map'].should == 'module.modulemap' + expect(@spec.attributes_hash['module_map']).to eq('module.modulemap') end it 'allows to skip modulemap file generation' do @spec.module_map = false - @spec.attributes_hash['module_map'].should == false + expect(@spec.attributes_hash['module_map']).to eq(false) end it 'allows to specify the script phases shipped with the Pod' do @spec.script_phases = { :name => 'Hello World', :script => 'echo "Hello World"' } - @spec.attributes_hash['script_phases'].should == { 'name' => 'Hello World', 'script' => 'echo "Hello World"' } + expect(@spec.attributes_hash['script_phases']).to eq({ 'name' => 'Hello World', 'script' => 'echo "Hello World"' }) end it 'allows to specify the script phases shipped with the Pod as a hash' do @spec.script_phases = { :name => 'Hello Ruby World', :script => 'puts "Hello Ruby World"', :shell_path => 'usr/bin/ruby' } - @spec.attributes_hash['script_phases'].should == { 'name' => 'Hello Ruby World', 'script' => 'puts "Hello Ruby World"', 'shell_path' => 'usr/bin/ruby' } + expect(@spec.attributes_hash['script_phases']).to eq({ 'name' => 'Hello Ruby World', 'script' => 'puts "Hello Ruby World"', 'shell_path' => 'usr/bin/ruby' }) end end @@ -417,62 +416,62 @@ module Pod it 'allows to specify the source files' do @spec.source_files = ['lib_classes/**/*'] - @spec.attributes_hash['source_files'].should == ['lib_classes/**/*'] + expect(@spec.attributes_hash['source_files']).to eq(['lib_classes/**/*']) end it 'allows to specify the public headers files' do @spec.public_header_files = ['include/**/*'] - @spec.attributes_hash['public_header_files'].should == ['include/**/*'] + expect(@spec.attributes_hash['public_header_files']).to eq(['include/**/*']) end it 'allows to specify the project headers files' do @spec.project_header_files = ['project/**/*'] - @spec.attributes_hash['project_header_files'].should == ['project/**/*'] + expect(@spec.attributes_hash['project_header_files']).to eq(['project/**/*']) end it 'allows to specify the private headers files' do @spec.private_header_files = ['private/**/*'] - @spec.attributes_hash['private_header_files'].should == ['private/**/*'] + expect(@spec.attributes_hash['private_header_files']).to eq(['private/**/*']) end it 'allows to specify the frameworks bundles shipped with the Pod' do @spec.vendored_frameworks = ['Parse.framework'] - @spec.attributes_hash['vendored_frameworks'].should == ['Parse.framework'] + expect(@spec.attributes_hash['vendored_frameworks']).to eq(['Parse.framework']) end it 'allows to specify the libraries shipped with the Pod' do @spec.vendored_libraries = ['libProj4.a'] - @spec.attributes_hash['vendored_libraries'].should == ['libProj4.a'] + expect(@spec.attributes_hash['vendored_libraries']).to eq(['libProj4.a']) end it 'allows to specify the on demand resources shipped with the Pod' do @spec.on_demand_resources = { 'Maps' => 'MapView/Map/Resources/*.png' } - @spec.attributes_hash['on_demand_resources'].should == { 'Maps' => 'MapView/Map/Resources/*.png' } + expect(@spec.attributes_hash['on_demand_resources']).to eq({ 'Maps' => 'MapView/Map/Resources/*.png' }) end it 'allows to specify the on demand resources shipped with the Pod as an array' do @spec.on_demand_resources = { 'Levels' => %w[Levels/Level1/Resources/*.png Levels/Level2/Resources/*.png] } - @spec.attributes_hash['on_demand_resources'].should == { 'Levels' => %w[Levels/Level1/Resources/*.png Levels/Level2/Resources/*.png] } + expect(@spec.attributes_hash['on_demand_resources']).to eq({ 'Levels' => %w[Levels/Level1/Resources/*.png Levels/Level2/Resources/*.png] }) end it 'allows to specify the resources bundles shipped with the Pod' do @spec.resource_bundles = { 'MapBox' => 'MapView/Map/Resources/*.png' } - @spec.attributes_hash['resource_bundles'].should == { 'MapBox' => 'MapView/Map/Resources/*.png' } + expect(@spec.attributes_hash['resource_bundles']).to eq({ 'MapBox' => 'MapView/Map/Resources/*.png' }) end it 'allows to specify the resources files' do @spec.resources = ['frameworks/CrashReporter.framework'] - @spec.attributes_hash['resources'].should == ['frameworks/CrashReporter.framework'] + expect(@spec.attributes_hash['resources']).to eq(['frameworks/CrashReporter.framework']) end it 'allows to specify the paths to exclude' do @spec.exclude_files = ['Classes/**/unused.{h,m}'] - @spec.attributes_hash['exclude_files'].should == ['Classes/**/unused.{h,m}'] + expect(@spec.attributes_hash['exclude_files']).to eq(['Classes/**/unused.{h,m}']) end it 'allows to specify the paths to preserve' do @spec.preserve_paths = ['Frameworks/*.framework'] - @spec.attributes_hash['preserve_paths'].should == ['Frameworks/*.framework'] + expect(@spec.attributes_hash['preserve_paths']).to eq(['Frameworks/*.framework']) end end @@ -491,19 +490,19 @@ module Pod end end subspec = @spec.subspecs.first - subspec.parent.should == @spec - subspec.class.should == Specification - subspec.name.should == 'Spec/Subspec' + expect(subspec.parent).to eq(@spec) + expect(subspec.class).to eq(Specification) + expect(subspec.name).to eq('Spec/Subspec') end it 'should allow you to specify a preferred set of dependencies' do @spec.default_subspecs = 'Preferred-Subspec1', 'Preferred-Subspec2' - @spec.attributes_hash['default_subspecs'].should == %w(Preferred-Subspec1 Preferred-Subspec2) + expect(@spec.attributes_hash['default_subspecs']).to eq(%w(Preferred-Subspec1 Preferred-Subspec2)) end it 'should allow you to specify an empty preferred set of dependencies' do @spec.default_subspecs = :none - @spec.attributes_hash['default_subspecs'].should == :none + expect(@spec.attributes_hash['default_subspecs']).to eq(:none) end end @@ -521,10 +520,10 @@ module Pod it 'allows you to specify a unit test spec' do test_spec = @spec.subspecs.first - test_spec.class.should == Specification - test_spec.name.should == 'Spec/Tests' - test_spec.test_specification?.should == true - test_spec.test_type.should == :unit + expect(test_spec.class).to eq(Specification) + expect(test_spec.name).to eq('Spec/Tests') + expect(test_spec.test_specification?).to eq(true) + expect(test_spec.test_type).to eq(:unit) end it 'allows you to specify a unit test type as string' do @@ -535,10 +534,10 @@ module Pod end end test_spec = a_spec.subspecs.first - test_spec.class.should == Specification - test_spec.name.should == 'Spec/Tests' - test_spec.test_specification?.should == true - test_spec.test_type.should == :unit + expect(test_spec.class).to eq(Specification) + expect(test_spec.name).to eq('Spec/Tests') + expect(test_spec.test_specification?).to eq(true) + expect(test_spec.test_type).to eq(:unit) end it 'allows you to specify a ui test spec' do @@ -549,10 +548,10 @@ module Pod end end test_spec = a_spec.subspecs.first - test_spec.class.should == Specification - test_spec.name.should == 'Spec/Tests' - test_spec.test_specification?.should == true - test_spec.test_type.should == :ui + expect(test_spec.class).to eq(Specification) + expect(test_spec.name).to eq('Spec/Tests') + expect(test_spec.test_specification?).to eq(true) + expect(test_spec.test_type).to eq(:ui) end it 'allows you to specify a ui test type as string' do @@ -563,10 +562,10 @@ module Pod end end test_spec = a_spec.subspecs.first - test_spec.class.should == Specification - test_spec.name.should == 'Spec/Tests' - test_spec.test_specification?.should == true - test_spec.test_type.should == :ui + expect(test_spec.class).to eq(Specification) + expect(test_spec.name).to eq('Spec/Tests') + expect(test_spec.test_specification?).to eq(true) + expect(test_spec.test_type).to eq(:ui) end it 'allows you to specify a scheme for a test spec' do @@ -578,7 +577,7 @@ module Pod end end test_spec = a_spec.subspecs.first - test_spec.scheme.should == { :launch_arguments => %w(Arg1 Arg2), :environment_variables => { 'Key1' => 'Val1' } } + expect(test_spec.scheme).to eq({ :launch_arguments => %w(Arg1 Arg2), :environment_variables => { 'Key1' => 'Val1' } }) end end @@ -593,23 +592,23 @@ module Pod it 'allows to specify iOS attributes' do @spec.ios.preserve_paths = ['APath'] - @spec.attributes_hash['ios']['preserve_paths'].should == ['APath'] - @spec.attributes_hash['preserve_paths'].should.be.nil - @spec.attributes_hash['osx'].should.be.nil + expect(@spec.attributes_hash['ios']['preserve_paths']).to eq(['APath']) + expect(@spec.attributes_hash['preserve_paths']).to be_nil + expect(@spec.attributes_hash['osx']).to be_nil end it 'allows to specify OS X attributes' do @spec.osx.preserve_paths = ['APath'] - @spec.attributes_hash['osx']['preserve_paths'].should == ['APath'] - @spec.attributes_hash['preserve_paths'].should.be.nil - @spec.attributes_hash['ios'].should.be.nil + expect(@spec.attributes_hash['osx']['preserve_paths']).to eq(['APath']) + expect(@spec.attributes_hash['preserve_paths']).to be_nil + expect(@spec.attributes_hash['ios']).to be_nil end it 'allows to specify OS X attributes as macOS' do @spec.macos.preserve_paths = ['APath'] - @spec.attributes_hash['osx']['preserve_paths'].should == ['APath'] - @spec.attributes_hash['preserve_paths'].should.be.nil - @spec.attributes_hash['ios'].should.be.nil + expect(@spec.attributes_hash['osx']['preserve_paths']).to eq(['APath']) + expect(@spec.attributes_hash['preserve_paths']).to be_nil + expect(@spec.attributes_hash['ios']).to be_nil end end @@ -618,8 +617,8 @@ module Pod describe 'Attributes default values' do it 'does requires arc by default' do attr = Specification::DSL.attributes[:requires_arc] - attr.default(:ios).should == true - attr.default(:osx).should == true + expect(attr.default(:ios)).to eq(true) + expect(attr.default(:osx)).to eq(true) end end @@ -631,13 +630,13 @@ module Pod singularized = attributes.select(&:singularize?) spec = Specification.new singularized.each do |attr| - spec.should.respond_to(attr.writer_name) + expect(spec).to respond_to(attr.writer_name) end - singularized.map { |attr| attr.name.to_s }.sort.should == %w( + expect(singularized.map { |attr| attr.name.to_s }.sort).to eq(%w( authors compiler_flags default_subspecs frameworks libraries on_demand_resources preserve_paths resource_bundles resources screenshots script_phases swift_versions vendored_frameworks vendored_libraries weak_frameworks - ) + )) end end diff --git a/spec/specification/json_spec.rb b/spec/specification/json_spec.rb index ae77b5183..93d97432b 100644 --- a/spec/specification/json_spec.rb +++ b/spec/specification/json_spec.rb @@ -18,13 +18,13 @@ module Pod 'watchos' => nil, }, } - JSON.parse(spec.to_json).should == expected + expect(JSON.parse(spec.to_json)).to eq(expected) end it 'serializes tags with Pod::Version correctly' do spec = Specification.new(nil, 'BananaLib') do |spec| spec.version = '1.0' - spec.version.class.should == Pod::Version + expect(spec.version.class).to eq(Pod::Version) spec.source = { :git => 'https://github.com/CocoaPods/CocoaPodsExampleLibrary.git', :tag => spec.version, @@ -45,12 +45,12 @@ module Pod 'watchos' => nil, }, } - JSON.parse(spec.to_json).should == expected + expect(JSON.parse(spec.to_json)).to eq(expected) end it 'terminates the json representation with a new line' do spec = Specification.new(nil, 'BananaLib') - spec.to_json.should.end_with "\n" + expect(spec.to_json).to end_with("\n") end it 'allows to specify multi-platform attributes' do @@ -64,7 +64,7 @@ module Pod DOC spec = Specification.from_json(json) consumer = Specification::Consumer.new(spec, :ios) - consumer.source_files.should == ['Files'] + expect(consumer.source_files).to eq(['Files']) end end @@ -85,12 +85,12 @@ module Pod 'watchos' => nil, }, } - JSON.parse(spec.to_pretty_json).should == expected + expect(JSON.parse(spec.to_pretty_json)).to eq(expected) end it 'terminates the json representation with a new line' do spec = Specification.new(nil, 'BananaLib') - spec.to_pretty_json.should.end_with "\n" + expect(spec.to_pretty_json).to end_with("\n") end it 'can round-trip' do @@ -108,7 +108,7 @@ module Pod loaded_spec = Specification.from_json(json) new_json = loaded_spec.to_pretty_json - new_json.should.equal json + expect(new_json).to eq(json) end it 'maintains correct order of keys across versions' do @@ -116,7 +116,7 @@ module Pod json = File.read(File.expand_path("../../fixtures/CannonPodder#{version}.podspec.json", __FILE__)) loaded_spec = Specification.from_json(json) new_json = loaded_spec.to_pretty_json - new_json.should.equal json + expect(new_json).to eq(json) end end @@ -127,8 +127,8 @@ module Pod s.pod_target_xcconfig = {} end json = spec.to_pretty_json - json.should.include '"Dep": []' - json.should.include '"pod_target_xcconfig": {}' + expect(json).to include('"Dep": []') + expect(json).to include('"pod_target_xcconfig": {}') end end @@ -142,13 +142,13 @@ module Pod it 'can be converted to a hash' do hash = @spec.to_hash - hash['name'].should == 'BananaLib' - hash['version'].should == '1.0' + expect(hash['name']).to eq('BananaLib') + expect(hash['version']).to eq('1.0') end it 'handles subspecs when converted to a hash' do hash = @spec.to_hash - hash['subspecs'].should == [ + expect(hash['subspecs']).to eq([ { 'name' => 'GreenBanana', 'source_files' => 'GreenBanana', @@ -159,7 +159,7 @@ module Pod 'source_files' => 'YellowBanana', 'dependencies' => { 'SDWebImage' => [] }, }, - ] + ]) end it 'handles subspecs with different platforms' do @@ -169,7 +169,7 @@ module Pod 'tvos' => '9.0', } hash = @spec.to_hash - hash['subspecs'].should == [ + expect(hash['subspecs']).to eq([ { 'name' => 'GreenBanana', 'source_files' => 'GreenBanana', @@ -184,7 +184,7 @@ module Pod 'source_files' => 'YellowBanana', 'dependencies' => { 'SDWebImage' => [] }, }, - ] + ]) end it 'handles subspecs when the parent spec specifies platforms and the subspec inherits' do @@ -192,7 +192,7 @@ module Pod 'tvos' => '9.0', } hash = @spec.to_hash - hash['subspecs'].should == [ + expect(hash['subspecs']).to eq([ { 'name' => 'GreenBanana', 'source_files' => 'GreenBanana', @@ -203,7 +203,7 @@ module Pod 'source_files' => 'YellowBanana', 'dependencies' => { 'SDWebImage' => [] }, }, - ] + ]) end it 'writes script phases' do @@ -213,17 +213,17 @@ module Pod { :name => 'Hello Ruby World', :script => 'puts "Hello Ruby World"', :shell_path => 'usr/bin/ruby' }, ] hash = @spec.to_hash - hash['script_phases'].should == [ + expect(hash['script_phases']).to eq([ { :name => 'Hello World', :script => 'echo "Hello World"' }, { :name => 'Hello World 2', :script => 'echo "Hello World 2"', :execution_position => :after_compile }, { :name => 'Hello Ruby World', :script => 'puts "Hello Ruby World"', :shell_path => 'usr/bin/ruby' }, - ] + ]) end it 'writes scheme configuration' do @spec.scheme = { :launch_arguments => ['Arg1'] } hash = @spec.to_hash - hash['scheme'].should == { 'launch_arguments' => ['Arg1'] } + expect(hash['scheme']).to eq({ 'launch_arguments' => ['Arg1'] }) end it 'writes Info.plist configuration' do @@ -232,16 +232,16 @@ module Pod 'SOME_VAR' => 'SOME_VALUE', } hash = @spec.to_hash - hash['info_plist'].should == { + expect(hash['info_plist']).to eq({ 'CFBundleIdentifier' => 'org.cocoapods.MyAwesomeLib', 'SOME_VAR' => 'SOME_VALUE', - } + }) end it 'writes test type for test subspec' do @spec.test_spec {} hash = @spec.to_hash - hash['subspecs'].should == [ + expect(hash['subspecs']).to eq([ { 'name' => 'GreenBanana', 'source_files' => 'GreenBanana', @@ -252,17 +252,17 @@ module Pod 'source_files' => 'YellowBanana', 'dependencies' => { 'SDWebImage' => [] }, }, - ] - hash['testspecs'].should == [{ + ]) + expect(hash['testspecs']).to eq([{ 'name' => 'Tests', 'test_type' => :unit, - }] + }]) end it 'writes test type for test subspec in json' do @spec.test_spec {} hash = @spec.to_json - hash.should.include '"name":"Tests","test_type":"unit"' + expect(hash).to include('"name":"Tests","test_type":"unit"') end it 'writes ui test type for test subspec in json' do @@ -270,44 +270,44 @@ module Pod test.test_type = :ui end hash = @spec.to_json - hash.should.include '"name":"Tests","test_type":"ui"' + expect(hash).to include('"name":"Tests","test_type":"ui"') end describe 'Dependency Configuration Support' do it 'does not write the configuration whitelist for a pod if unspecified' do @spec.dependency 'AFNetworking' hash = @spec.to_hash - hash['configuration_pod_whitelist'].should.be.nil + expect(hash['configuration_pod_whitelist']).to be_nil end it 'writes the array string configuration whitelist for a given pod' do @spec.dependency 'AFNetworking', :configurations => ['Debug'] hash = @spec.to_hash - hash['configuration_pod_whitelist'].should == { + expect(hash['configuration_pod_whitelist']).to eq({ 'AFNetworking' => [ 'debug', ], - } + }) end it 'writes the array symbol configuration whitelist for a given pod' do @spec.dependency 'AFNetworking', :configurations => [:debug] hash = @spec.to_hash - hash['configuration_pod_whitelist'].should == { + expect(hash['configuration_pod_whitelist']).to eq({ 'AFNetworking' => [ 'debug', ], - } + }) end it 'writes the symbol configuration whitelist for a given pod' do @spec.dependency 'AFNetworking', :configurations => :debug hash = @spec.to_hash - hash['configuration_pod_whitelist'].should == { + expect(hash['configuration_pod_whitelist']).to eq({ 'AFNetworking' => [ 'debug', ], - } + }) end it 'loads the configuration whitelist for a pod' do @@ -318,7 +318,7 @@ module Pod 'configuration_pod_whitelist' => { 'AFNetworking' => ['debug'] }, } result = Specification.from_hash(hash) - result.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'debug').should.be.true + expect(result.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'debug')).to be(true) end end @@ -328,8 +328,8 @@ module Pod 'version' => '1.0', } result = Specification.from_hash(hash) - result.name.should == 'BananaLib' - result.version.to_s.should == '1.0' + expect(result.name).to eq('BananaLib') + expect(result.version.to_s).to eq('1.0') end it 'can load test specification from hash' do @@ -340,10 +340,10 @@ module Pod 'testspecs' => [{ 'name' => 'Tests', 'test_type' => :unit }], } result = Specification.from_hash(hash) - result.subspecs.count.should.equal 2 - result.test_specs.count.should.equal 1 - result.test_specs.first.test_specification?.should.be.true - result.test_specs.first.test_type.should.equal :unit + expect(result.subspecs.count).to eq(2) + expect(result.test_specs.count).to eq(1) + expect(result.test_specs.first.test_specification?).to be(true) + expect(result.test_specs.first.test_type).to eq(:unit) end it 'can load app specification from hash' do @@ -354,10 +354,10 @@ module Pod 'appspecs' => [{ 'name' => 'App' }], } result = Specification.from_hash(hash) - result.subspecs.count.should.equal 2 - result.app_specs.count.should.equal 1 - result.app_specs.first.name.should == 'BananaLib/App' - result.app_specs.first.app_specification?.should.be.true + expect(result.subspecs.count).to eq(2) + expect(result.app_specs.count).to eq(1) + expect(result.app_specs.first.name).to eq('BananaLib/App') + expect(result.app_specs.first.app_specification?).to be(true) end it 'can load scheme configuration from hash' do @@ -367,7 +367,7 @@ module Pod 'scheme' => { 'launch_arguments' => ['Arg1'] }, } result = Specification.from_hash(hash) - result.scheme.should == { :launch_arguments => ['Arg1'] } + expect(result.scheme).to eq({ :launch_arguments => ['Arg1'] }) end it 'can load script phases from hash' do @@ -380,11 +380,11 @@ module Pod ], } result = Specification.from_hash(hash) - result.script_phases.count.should.equal 2 - result.script_phases.should == [ + expect(result.script_phases.count).to eq(2) + expect(result.script_phases).to eq([ { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :any }, { :name => 'Hello Ruby World', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby', :execution_position => :any }, - ] + ]) end it 'can load on demand resources from a hash' do @@ -398,12 +398,12 @@ module Pod }, } result = Specification.from_hash(hash) - result.on_demand_resources.count.should.equal 3 - result.on_demand_resources.should == { + expect(result.on_demand_resources.count).to eq(3) + expect(result.on_demand_resources).to eq({ 'Tag1' => { :paths => 'Tag1Resources/*', :category => :download_on_demand }, 'Tag2' => ['Tag2Resources/*'], 'Tag3' => 'Tag3Resources/bear.png*', - } + }) end it 'can load default subspecs from hash' do @@ -418,7 +418,7 @@ module Pod ], } result = Specification.from_hash(hash) - result.default_subspecs.should == ['BananaLibSubSpec'] + expect(result.default_subspecs).to eq(['BananaLibSubSpec']) end it 'can load no default subspecs from hash' do @@ -433,7 +433,7 @@ module Pod ], } result = Specification.from_hash(hash) - result.default_subspecs.should == :none + expect(result.default_subspecs).to eq(:none) end it 'can load test specification from 1.3.0 hash format' do @@ -443,129 +443,129 @@ module Pod 'subspecs' => [{ 'name' => 'GreenBanana', 'source_files' => 'GreenBanana' }, { 'name' => 'Tests', 'test_type' => :unit }], } result = Specification.from_hash(hash) - result.subspecs.count.should.equal 2 - result.test_specs.count.should.equal 1 - result.non_library_specs.count.should.equal 1 - result.app_specs.count.should.equal 0 - result.test_specs.first.test_specification?.should.be.true - result.test_specs.first.app_specification?.should.be.false - result.test_specs.first.test_type.should.equal :unit + expect(result.subspecs.count).to eq(2) + expect(result.test_specs.count).to eq(1) + expect(result.non_library_specs.count).to eq(1) + expect(result.app_specs.count).to eq(0) + expect(result.test_specs.first.test_specification?).to be(true) + expect(result.test_specs.first.app_specification?).to be(false) + expect(result.test_specs.first.test_type).to eq(:unit) end it 'can throws with the path for malformed json' do json = '{"script_phases": [{name": "Hello World", "script": "echo \"Hello World\""}]}' - should.raise JSON::ParserError do + expect do result = Specification.from_json(json, "path/to/spec.json") - end.message.should.include 'path/to/spec.json' + end.to raise_error(JSON::ParserError, a_string_including('path/to/spec.json')) end it 'can load test specification from 1.3.0 JSON format' do json = '{"subspecs": [{"name": "Tests","test_type": "unit","source_files": "Tests/**/*.{h,m}"}]}' result = Specification.from_json(json) - result.test_specs.count.should.equal 1 - result.non_library_specs.count.should.equal 1 - result.app_specs.count.should.equal 0 - result.test_specs.first.test_specification?.should.be.true - result.test_specs.first.app_specification?.should.be.false - result.test_specs.first.test_type.should.equal :unit + expect(result.test_specs.count).to eq(1) + expect(result.non_library_specs.count).to eq(1) + expect(result.app_specs.count).to eq(0) + expect(result.test_specs.first.test_specification?).to be(true) + expect(result.test_specs.first.app_specification?).to be(false) + expect(result.test_specs.first.test_type).to eq(:unit) end it 'can load test specification from json' do json = '{"testspecs": [{"name": "Tests","test_type": "unit","source_files": "Tests/**/*.{h,m}"}]}' result = Specification.from_json(json) - result.non_library_specs.count.should.equal 1 - result.test_specs.count.should.equal 1 - result.app_specs.count.should.equal 0 - result.test_specs.first.test_specification?.should.be.true - result.test_specs.first.app_specification?.should.be.false - result.test_specs.first.test_type.should.equal :unit + expect(result.non_library_specs.count).to eq(1) + expect(result.test_specs.count).to eq(1) + expect(result.app_specs.count).to eq(0) + expect(result.test_specs.first.test_specification?).to be(true) + expect(result.test_specs.first.app_specification?).to be(false) + expect(result.test_specs.first.test_type).to eq(:unit) end it 'can load ui test specification from json' do json = '{"testspecs": [{"name": "Tests","test_type": "ui","source_files": "Tests/**/*.{h,m}"}]}' result = Specification.from_json(json) - result.non_library_specs.count.should.equal 1 - result.test_specs.count.should.equal 1 - result.app_specs.count.should.equal 0 - result.test_specs.first.test_specification?.should.be.true - result.test_specs.first.app_specification?.should.be.false - result.test_specs.first.test_type.should.equal :ui + expect(result.non_library_specs.count).to eq(1) + expect(result.test_specs.count).to eq(1) + expect(result.app_specs.count).to eq(0) + expect(result.test_specs.first.test_specification?).to be(true) + expect(result.test_specs.first.app_specification?).to be(false) + expect(result.test_specs.first.test_type).to eq(:ui) end it 'can load app specification from json' do json = '{"appspecs": [{"name": "App","source_files": "App/**/*.{h,m}"}]}' result = Specification.from_json(json) - result.app_specs.count.should.equal 1 - result.test_specs.count.should.equal 0 - result.non_library_specs.count.should.equal 1 - result.app_specs.first.app_specification?.should.be.true - result.app_specs.first.test_specification?.should.be.false + expect(result.app_specs.count).to eq(1) + expect(result.test_specs.count).to eq(0) + expect(result.non_library_specs.count).to eq(1) + expect(result.app_specs.first.app_specification?).to be(true) + expect(result.app_specs.first.test_specification?).to be(false) end it 'can load script phases from json' do json = '{"script_phases": [{"name": "Hello World", "script": "echo \"Hello World\""}]}' result = Specification.from_json(json) - result.script_phases.count.should.equal 1 - result.script_phases.should == [ + expect(result.script_phases.count).to eq(1) + expect(result.script_phases).to eq([ { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :any }, - ] + ]) end it 'can load on demand resources from json' do json = '{"on_demand_resources":{"tag1":{"paths":"Tag1Resources/*","category":"download_on_demand"},"tag2":"Tag2Resources/*","tag3":["Tag3Resources/*"]}}' result = Specification.from_json(json) - result.on_demand_resources.count.should.equal 3 - result.on_demand_resources.should == { + expect(result.on_demand_resources.count).to eq(3) + expect(result.on_demand_resources).to eq({ 'tag1' => { 'paths' => 'Tag1Resources/*', 'category' => 'download_on_demand' }, 'tag2' => 'Tag2Resources/*', 'tag3' => ['Tag3Resources/*'], - } + }) end it 'loads script phase execution position from json' do json = '{"script_phases": [{"name": "Hello World", "script": "echo \"Hello World\"", "execution_position": "before_compile"}]}' result = Specification.from_json(json) - result.script_phases.count.should.equal 1 - result.script_phases.should == [ + expect(result.script_phases.count).to eq(1) + expect(result.script_phases).to eq([ { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :before_compile }, - ] + ]) end it 'can load Info.plist configuration from json' do json = '{"info_plist": {"CFBundleIdentifier": "org.mycompany.MyLib"}}' result = Specification.from_json(json) - result.info_plist.should == { 'CFBundleIdentifier' => 'org.mycompany.MyLib' } + expect(result.info_plist).to eq({ 'CFBundleIdentifier' => 'org.mycompany.MyLib' }) end it 'can be safely converted back and forth to a hash' do result = Specification.from_hash(@spec.to_hash) - result.should == @spec + expect(result).to eq(@spec) end describe 'Swift Version Support' do it 'writes swift version in singular form' do @spec.swift_version = '1.0' hash = @spec.to_hash - hash['swift_versions'].should == '1.0' - hash['swift_version'].should == '1.0' + expect(hash['swift_versions']).to eq('1.0') + expect(hash['swift_version']).to eq('1.0') end it 'writes swift version pluralized' do @spec.swift_versions = ['1.0'] hash = @spec.to_hash - hash['swift_versions'].should == ['1.0'] - hash['swift_version'].should == '1.0' + expect(hash['swift_versions']).to eq(['1.0']) + expect(hash['swift_version']).to eq('1.0') end it 'does not alter the attribute hash when loading swift versions' do @spec.swift_versions = ['4.2', '5.0'] first_hash = @spec.to_hash - first_hash['swift_versions'].should == ['4.2', '5.0'] - first_hash['swift_version'].should == '5.0' + expect(first_hash['swift_versions']).to eq(['4.2', '5.0']) + expect(first_hash['swift_version']).to eq('5.0') spec_from_hash = Specification.from_hash(first_hash) second_hash = spec_from_hash.to_hash - second_hash['swift_versions'].should == ['4.2', '5.0'] - second_hash['swift_version'].should == '5.0' + expect(second_hash['swift_versions']).to eq(['4.2', '5.0']) + expect(second_hash['swift_version']).to eq('5.0') end it 'reads swift version from a string' do @@ -575,7 +575,7 @@ module Pod 'swift_versions' => '3.2', } result = Specification.from_hash(hash) - result.swift_versions.map(&:to_s).should == ['3.2'] + expect(result.swift_versions.map(&:to_s)).to eq(['3.2']) end it 'reads swift version from an array' do @@ -585,7 +585,7 @@ module Pod 'swift_versions' => %w(3.2 4.0), } result = Specification.from_hash(hash) - result.swift_versions.map(&:to_s).should == %w(3.2 4.0) + expect(result.swift_versions.map(&:to_s)).to eq(%w(3.2 4.0)) end it 'is backwards compatible with pre 1.7.0 swift version' do @@ -595,8 +595,8 @@ module Pod 'swift_version' => '3.2', } result = Specification.from_hash(hash) - result.swift_versions.map(&:to_s).should == %w(3.2) - result.swift_version.to_s.should == '3.2' + expect(result.swift_versions.map(&:to_s)).to eq(%w(3.2)) + expect(result.swift_version.to_s).to eq('3.2') end it 'combines old and new swift version declarations' do @@ -607,8 +607,8 @@ module Pod 'swift_versions' => %w(4.0 4.1), } result = Specification.from_hash(hash) - result.swift_versions.map(&:to_s).should == %w(3.2 4.0 4.1) - result.swift_version.to_s.should == '4.1' + expect(result.swift_versions.map(&:to_s)).to eq(%w(3.2 4.0 4.1)) + expect(result.swift_version.to_s).to eq('4.1') end end end diff --git a/spec/specification/linter/analyzer_spec.rb b/spec/specification/linter/analyzer_spec.rb index f07e411c4..06e55fe85 100644 --- a/spec/specification/linter/analyzer_spec.rb +++ b/spec/specification/linter/analyzer_spec.rb @@ -18,10 +18,10 @@ module Pod it 'fails a spec with an attribute of the wrong type' do @spec.summary = ['Summary in an array'] results = @analyzer.analyze - results.count.should.be.equal(2) + expect(results.count).to eq(2) expected = 'Unacceptable type `Array`' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('attribute') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('attribute') end end @@ -35,10 +35,10 @@ module Pod results = Specification::Linter::Results.new @analyzer = Specification::Linter::Analyzer.new(subspec.consumer(:ios), results) results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Can\'t set `homepage` attribute for subspecs (in `BananaLib/subspec`).' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('attribute') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('attribute') end end @@ -52,20 +52,20 @@ module Pod results = Specification::Linter::Results.new @analyzer = Specification::Linter::Analyzer.new(subspec.consumer(:ios), results) results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = "Can't set `version` attribute for subspecs (in `BananaLib/subspec`)." - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('attribute') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('attribute') end it 'disallows test only attributes into non test specs' do @spec.test_spec {} @spec.requires_app_host = true results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Attribute `requires_app_host` can only be set within test specs (in `BananaLib`).' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('attribute') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('attribute') end it 'allows test only attributes into test specs' do @@ -75,7 +75,7 @@ module Pod results = Specification::Linter::Results.new @analyzer = Specification::Linter::Analyzer.new(test_spec.consumer(:ios), results) results = @analyzer.analyze - results.should.be.empty? + expect(results).to be_empty end end @@ -84,88 +84,88 @@ module Pod describe 'Unknown keys check' do it 'validates a spec with valid keys' do results = @analyzer.analyze - results.should.be.empty? + expect(results).to be_empty end it 'validates a spec with multi-platform attributes' do @spec.ios.requires_arc = true results = @analyzer.analyze - results.should.be.empty? + expect(results).to be_empty end it 'fails a spec with unknown keys' do @spec.attributes_hash['unknown_key'] = true results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Unrecognized `unknown_key` key' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('attributes') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('attributes') end it 'fails a spec with unknown multi-platform key' do @spec.attributes_hash['ios'] = { 'unknown_key' => true } results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Unrecognized `unknown_key` key' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('attributes') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('attributes') end it 'validates a spec with valid sub-keys' do @spec.license = { :type => 'MIT' } results = @analyzer.analyze - results.should.be.empty? + expect(results).to be_empty end it 'fails a spec with unknown sub-keys' do @spec.license = { :is_safe_for_work => true } results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Unrecognized `is_safe_for_work` key' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('keys') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('keys') end it 'validates a spec with valid minor sub-keys' do @spec.source = { :git => 'example.com', :branch => 'master' } results = @analyzer.analyze - results.should.be.empty? + expect(results).to be_empty end it 'fails a spec with a missing primary sub-keys' do @spec.source = { :branch => 'example.com', :commit => 'MyLib' } results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Missing primary key for `source` attribute.' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('keys') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('keys') end it 'fails a spec with invalid secondary sub-keys' do @spec.source = { :git => 'example.com', :folder => 'MyLib' } results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Incompatible `folder` key(s) with `git`' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('keys') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('keys') end it 'fails a spec with multiple primary keys' do @spec.source = { :git => 'example.com', :http => 'example.com' } results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Incompatible `git, http` keys' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('keys') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('keys') end it 'fails a spec invalid secondary sub-keys when no sub-keys are supported' do @spec.source = { :http => 'example.com', :unsupported => true } results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'Incompatible `unsupported` key(s) with `http`' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('keys') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('keys') end end @@ -175,10 +175,10 @@ module Pod it 'checks if any file patterns is absolute' do @spec.source_files = '/Classes' results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'patterns must be relative' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('File Patterns') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('File Patterns') end it 'checks if any file patterns are absolute for on demand resources' do @@ -187,10 +187,10 @@ module Pod 'Tag2' => '/MyResources', } results = @analyzer.analyze - results.count.should.be.equal(1) + expect(results.count).to eq(1) expected = 'patterns must be relative' - results.first.message.should.include?(expected) - results.first.attribute_name.should.include?('File Patterns') + expect(results.first.message).to include(expected) + expect(results.first.attribute_name).to include('File Patterns') end it 'checks if a specification is empty' do @@ -205,9 +205,9 @@ module Pod consumer.any_instance.stubs(:vendored_frameworks).returns([]) results = @analyzer.analyze - results.count.should.be.equal(1) - results.first.message.should.include?('spec is empty') - results.first.attribute_name.should.include?('File Patterns') + expect(results.count).to eq(1) + expect(results.first.message).to include('spec is empty') + expect(results.first.attribute_name).to include('File Patterns') end end @@ -216,7 +216,7 @@ module Pod describe 'Requires ARC' do it 'supports the declaration of the attribute per platform' do results = @analyzer.analyze - results.should.be.empty? + expect(results).to be_empty end it 'supports the declaration of the attribute in the parent' do @@ -228,7 +228,7 @@ module Pod results = Specification::Linter::Results.new @analyzer = Specification::Linter::Analyzer.new(consumer, results) results = @analyzer.analyze - results.should.be.empty? + expect(results).to be_empty end end end diff --git a/spec/specification/linter/result_spec.rb b/spec/specification/linter/result_spec.rb index 98326a03e..7a7dc6044 100644 --- a/spec/specification/linter/result_spec.rb +++ b/spec/specification/linter/result_spec.rb @@ -9,26 +9,26 @@ module Pod end it 'returns the type' do - @result.type.should == :error + expect(@result.type).to eq(:error) end it 'returns the attribute name' do - @result.attribute_name.should == 'test_attribute' + expect(@result.attribute_name).to eq('test_attribute') end it 'returns the message' do - @result.message.should == 'This is an error' + expect(@result.message).to eq('This is an error') end it 'can store the platforms that generated the result' do @result.platforms << :ios - @result.platforms.should == [:ios] + expect(@result.platforms).to eq([:ios]) end it 'returns a string representation suitable for UI' do - @result.to_s.should == '[ERROR] [test_attribute] This is an error' + expect(@result.to_s).to eq('[ERROR] [test_attribute] This is an error') @result.platforms << :ios - @result.to_s.should == '[ERROR] [test_attribute] This is an error [iOS]' + expect(@result.to_s).to eq('[ERROR] [test_attribute] This is an error [iOS]') end end @@ -39,26 +39,26 @@ module Pod it 'creates an error result' do @results.add_error('attribute', 'This is an error') - @results.count.should == 1 - @results.first.type.should == :error + expect(@results.count).to eq(1) + expect(@results.first.type).to eq(:error) end it 'creates a warning result' do @results.add_warning('attribute', 'This is a warning') - @results.count.should == 1 - @results.first.type.should == :warning + expect(@results.count).to eq(1) + expect(@results.first.type).to eq(:warning) end it 'prevents duplicate results with the same attribute' do @results.add_warning('attribute', 'I have duplicate warnings') @results.add_warning('attribute', 'I have duplicate warnings') - @results.count.should == 1 + expect(@results.count).to eq(1) end it 'does not prevent duplicate results with different attributes' do @results.add_warning('attribute1', 'I have duplicate warnings') @results.add_warning('attribute2', 'I have duplicate warnings') - @results.count.should == 2 + expect(@results.count).to eq(2) end it 'specifies the platform on the result when there is a consumer' do @@ -67,13 +67,13 @@ module Pod linter = Specification::Linter.new(podspec_path) @results.consumer = Specification::Consumer.new(linter.spec, :ios) @results.add_warning('attribute', 'bad') - @results.first.platforms.first.should == :ios + expect(@results.first.platforms.first).to eq(:ios) end it 'specifies no platform when there is no consumer' do @results.consumer = nil @results.add_warning('attribute', 'bad') - @results.first.platforms.should == [] + expect(@results.first.platforms).to eq([]) end end end diff --git a/spec/specification/linter_spec.rb b/spec/specification/linter_spec.rb index 3e819bcb1..6acc6ca55 100644 --- a/spec/specification/linter_spec.rb +++ b/spec/specification/linter_spec.rb @@ -2,6 +2,8 @@ module Pod describe Specification::Linter do + extend SpecHelper::TemporaryDirectory + before do WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200) end @@ -12,27 +14,25 @@ module Pod @podspec_path = fixture(fixture_path) end - extend SpecHelper::TemporaryDirectory - it 'can be initialized with a specification' do spec = Specification.from_file(@podspec_path) @linter = Specification::Linter.new(spec) - @linter.spec.name.should == 'BananaLib' - @linter.file.should == @podspec_path + expect(@linter.spec.name).to eq('BananaLib') + expect(@linter.file).to eq(@podspec_path) end it 'can be initialized with a path' do @linter = Specification::Linter.new(@podspec_path) - @linter.spec.name.should == 'BananaLib' - @linter.file.should == @podspec_path + expect(@linter.spec.name).to eq('BananaLib') + expect(@linter.file).to eq(@podspec_path) end it 'catches specification load errors' do podspec = 'Pod::Spec.new do |s|; error; end' path = SpecHelper.temporary_directory + 'BananaLib.podspec' File.open(path, 'w') { |f| f.write(podspec) } - lambda { Specification.from_file(path) }.should.raise Pod::DSLError - lambda { Specification::Linter.new(path) }.should.not.raise + expect { Specification.from_file(path) }.to raise_error(Pod::DSLError) + expect { Specification::Linter.new(path) }.not_to raise_error end it 'includes an error indicating that the specification could not be loaded' do @@ -42,9 +42,9 @@ module Pod linter = Specification::Linter.new(path) linter.lint results = linter.results - results.count.should == 1 - results.first.message.should.match /spec.*could not be loaded/ - results.first.attribute_name.should.include?('spec') + expect(results.count).to eq(1) + expect(results.first.message).to match(/spec.*could not be loaded/) + expect(results.first.attribute_name).to include('spec') end describe 'with a valid podspec' do @@ -56,8 +56,8 @@ module Pod it 'accepts a valid podspec' do valid = @linter.lint - @linter.results.should.be.empty? - valid.should.be.true + expect(@linter.results).to be_empty + expect(valid).to be(true) end describe 'with a spec loaded from json' do @@ -72,8 +72,8 @@ module Pod it 'accepts a valid podspec' do valid = @linter.lint - @linter.results.should.be.empty? - valid.should.be.true + expect(@linter.results).to be_empty + expect(valid).to be(true) end end @@ -81,9 +81,8 @@ module Pod @linter.spec.platform = nil @linter.spec.source_files = '/Absolute' @linter.lint - @linter.results.count.should == 1 - @linter.results.first.platforms.map(&:to_s).sort.should == - %w(ios osx tvos visionos watchos) + expect(@linter.results.count).to eq(1) + expect(@linter.results.first.platforms.map(&:to_s).sort).to eq(%w(ios osx tvos visionos watchos)) end describe 'with lint errors and warnings' do @@ -95,21 +94,21 @@ module Pod it 'returns the results of the lint' do results = @linter.results.map { |r| r.type.to_s }.sort.uniq - results.should == %w(error warning) + expect(results).to eq(%w(error warning)) end it 'returns the errors results of the lint' do - @linter.errors.map(&:type).uniq.should == [:error] + expect(@linter.errors.map(&:type).uniq).to eq([:error]) end it 'returns the warnings results of the lint' do - @linter.warnings.map(&:type).should == [:warning] + expect(@linter.warnings.map(&:type)).to eq([:warning]) end end end end - shared 'Linter' do + shared_examples 'Linter' do before do @podspec_path = fixture(@fixture_path) @linter = Specification::Linter.new(@podspec_path) @@ -137,13 +136,13 @@ def result_should_include(*values) end end - matched.should.satisfy("Expected #{values.inspect} " \ + expect(matched).to satisfy("Expected #{values.inspect} " \ "but none of those results matched:\n" \ "#{results.map(&:to_s)}") do |m| m.count > 0 end - matched.should.satisfy("Expected #{values.inspect} " \ + expect(matched).to satisfy("Expected #{values.inspect} " \ "found matches:\n" \ "#{matched.map(&:to_s)}\n" \ "but unexpected results appeared:\n" \ @@ -160,7 +159,7 @@ def result_should_include(*values) @fixture_path = 'spec-repos/test_repo/Specs/BananaLib/1.0/BananaLib.podspec' end - behaves_like 'Linter' + include_examples 'Linter' #------------------# @@ -236,7 +235,7 @@ def result_should_include(*values) it 'passes a specification whose module name is a valid C99 identifier' do @spec.stubs(:module_name).returns('_') @linter.lint - @linter.results.count.should == 0 + expect(@linter.results.count).to eq(0) end it 'fails a specification whose module name is not a valid C99 identifier' do @@ -249,7 +248,7 @@ def result_should_include(*values) it 'passes a specification with a module map' do @spec.module_map = 'module.modulemap' @linter.lint - @linter.results.count.should == 0 + expect(@linter.results.count).to eq(0) end #------------------# @@ -288,7 +287,7 @@ def result_should_include(*values) linter.lint results = linter.results test_type_error = results.find { |result| result.to_s.downcase.include?('test_type') } - test_type_error.message.should.include?('The test type `unknown` is not supported.') + expect(test_type_error.message).to include('The test type `unknown` is not supported.') end it 'checks the test type value is correct using a JSON podspec' do @@ -304,7 +303,7 @@ def result_should_include(*values) linter.lint results = linter.results test_type_error = results.find { |result| result.to_s.downcase.include?('test_type') } - test_type_error.should.be.nil + expect(test_type_error).to be_nil end it 'checks the test type value is correctly set in a subspec using 1.3.0 JSON podspec' do @@ -315,7 +314,7 @@ def result_should_include(*values) linter.lint results = linter.results test_type_error = results.find { |result| result.to_s.downcase.include?('test_type') } - test_type_error.should.be.nil + expect(test_type_error).to be_nil end #------------------# @@ -334,7 +333,7 @@ def result_should_include(*values) @spec.app_host_name = 'BananaLib/App' @spec.dependency 'BananaLib/App' @linter.lint - @linter.results.should.be.empty? + expect(@linter.results).to be_empty end it 'fails a test spec requiring an app host from a pod that isn\'t required' do @@ -350,7 +349,7 @@ def result_should_include(*values) @spec.requires_app_host = true @spec.app_host_name = 'Foo/App' @linter.lint - @linter.results.should.be.empty? + expect(@linter.results).to be_empty end #------------------# @@ -373,7 +372,7 @@ def result_should_include(*values) it 'does not crash when there is a description but no summary' do @spec.stubs(:description).returns('sample.') @spec.stubs(:summary).returns(nil) - lambda { @linter.lint }.should.not.raise + expect { @linter.lint }.not_to raise_error end #------------------# @@ -403,7 +402,7 @@ def result_should_include(*values) it 'checks whether the license file has an allowed extension' do @spec.stubs(:license).returns(:type => 'MIT', :file => 'MIT.txt') @linter.lint - @linter.results.should.be.empty + expect(@linter.results).to be_empty end it 'checks whether the license file has a disallowed extension' do @@ -414,7 +413,7 @@ def result_should_include(*values) it 'allows license files without a file extension' do @spec.stubs(:license).returns(:type => 'MIT', :file => 'LICENSE') @linter.lint - @linter.results.should.be.empty + expect(@linter.results).to be_empty end #------------------# @@ -422,7 +421,7 @@ def result_should_include(*values) it 'allows a local git URL as source' do @spec.stubs(:source).returns(:git => 'file:///tmp/d20131009-82757-1tztajd', :tag => '1.0') @linter.lint - @linter.results.should.be.empty + expect(@linter.results).to be_empty end it 'checks for the example source' do @@ -472,19 +471,19 @@ def result_should_include(*values) it 'checks that Github repositories end in .git (for compatibility)' do @spec.stubs(:source).returns(:git => 'https://github.com/repo', :tag => '1.0') result_should_include('Github', '.git') - @linter.results.first.type.should == :warning + expect(@linter.results.first.type).to eq(:warning) end it 'does not warn for Github repositories with OAuth authentication' do @spec.stubs(:source).returns(:git => 'https://TOKEN:x-oauth-basic@github.com/COMPANY/REPO.git', :tag => '1.0') @linter.lint - @linter.results.should.be.empty + expect(@linter.results).to be_empty end it 'does not warn for local repositories with spaces' do @spec.stubs(:source).returns(:git => '/Users/kylef/Projects X', :tag => '1.0') @linter.lint - @linter.results.should.be.empty + expect(@linter.results).to be_empty end it 'warns for SSH repositories' do @@ -565,15 +564,15 @@ def result_should_include(*values) 'Level3' => ['File3.png'], 'Level4' => { :paths => 'File4.png', :category => :weird }, } - results.count.should == 2 - results[0].attribute_name.should == 'on_demand_resources' - results[0].type.should == :error - results[0].message.should == 'Invalid on demand resources category value `unknown`. ' \ - 'Available options are `download_on_demand, prefetched, initial_install`.' - results[1].attribute_name.should == 'on_demand_resources' - results[1].type.should == :error - results[1].message.should == 'Invalid on demand resources category value `weird`. ' \ - 'Available options are `download_on_demand, prefetched, initial_install`.' + expect(results.count).to eq(2) + expect(results[0].attribute_name).to eq('on_demand_resources') + expect(results[0].type).to eq(:error) + expect(results[0].message).to eq('Invalid on demand resources category value `unknown`. ' \ + 'Available options are `download_on_demand, prefetched, initial_install`.') + expect(results[1].attribute_name).to eq('on_demand_resources') + expect(results[1].type).to eq(:error) + expect(results[1].message).to eq('Invalid on demand resources category value `weird`. ' \ + 'Available options are `download_on_demand, prefetched, initial_install`.') end #------------------# @@ -583,7 +582,7 @@ def result_should_include(*values) :code_coverage => true, :parallelizable => true, :build_configurations => { 'Debug' => 'Debug'} } @linter.lint - @linter.results.should.be.empty + expect(@linter.results).to be_empty end it 'checks scheme launch arguments key type' do @@ -617,7 +616,7 @@ def result_should_include(*values) @spec.frameworks = %w(AddressBook Audio-Frameworks) @linter.lint results = @linter.results - results.should.be.empty + expect(results).to be_empty end it 'checks that frameworks do not end with a .framework extension' do @@ -652,7 +651,7 @@ def result_should_include(*values) ) @linter.lint results = @linter.results - results.should.be.empty + expect(results).to be_empty end it 'checks that libraries do not end with a .a extension' do @@ -688,7 +687,7 @@ def result_should_include(*values) @spec.deprecated_in_favor_of = @spec.name + '_other' @linter.lint results = @linter.results - results.should.be.empty + expect(results).to be_empty end #------------------# @@ -706,7 +705,7 @@ def result_should_include(*values) @fixture_path = 'lint_podspec/RestKit.podspec' end - behaves_like 'Linter' + include_examples 'Linter' before do @subspec = @spec.subspecs.first diff --git a/spec/specification/root_attribute_accessors_spec.rb b/spec/specification/root_attribute_accessors_spec.rb index 3cd25d942..910179381 100644 --- a/spec/specification/root_attribute_accessors_spec.rb +++ b/spec/specification/root_attribute_accessors_spec.rb @@ -13,101 +13,101 @@ module Pod end it 'returns the name of the specification' do - @spec.name.should == 'Pod' - @spec.subspecs.first.name.should == 'Pod/Subspec' + expect(@spec.name).to eq('Pod') + expect(@spec.subspecs.first.name).to eq('Pod/Subspec') end it 'returns the base name of the specification' do - @spec.base_name.should == 'Pod' - @spec.subspecs.first.base_name.should == 'Subspec' + expect(@spec.base_name).to eq('Pod') + expect(@spec.subspecs.first.base_name).to eq('Subspec') end it 'returns the version of the specification' do - @spec.version.should == Version.new('1.0') + expect(@spec.version).to eq(Version.new('1.0')) end it 'return the single swift version of the specification' do @spec.swift_versions = '3.2' - @spec.swift_versions.map(&:to_s).should == ['3.2'] + expect(@spec.swift_versions.map(&:to_s)).to eq(['3.2']) end it 'return multiple swift versions of the specification' do @spec.swift_versions = %w(4.0 3.2 3.2) - @spec.swift_versions.map(&:to_s).should == %w(3.2 4.0) + expect(@spec.swift_versions.map(&:to_s)).to eq(%w(3.2 4.0)) end it 'return uniq and sorted swift versions of the specification' do @spec.swift_versions = %w(4.0 3.2 3.2) - @spec.swift_versions.map(&:to_s).should == %w(3.2 4.0) + expect(@spec.swift_versions.map(&:to_s)).to eq(%w(3.2 4.0)) end it 'return swift version of the specification' do @spec.swift_versions = %w(3.2 4.0) - @spec.swift_version.should == Version.new('4.0') + expect(@spec.swift_version).to eq(Version.new('4.0')) end it 'returns the cocoapods version requirement of the specification' do @spec.cocoapods_version = '>= 0.36' - @spec.cocoapods_version.should == Requirement.new('>= 0.36') + expect(@spec.cocoapods_version).to eq(Requirement.new('>= 0.36')) end it 'memoizes the version to allow to set it to head' do - @spec.version.should.equal? @spec.version + expect(@spec.version).to be(@spec.version) end it 'returns the version version of the root specification for subspecs' do - @spec.subspecs.first.version.should == Version.new('1.0') + expect(@spec.subspecs.first.version).to eq(Version.new('1.0')) end it 'returns the authors' do hash = { 'Darth Vader' => 'darthvader@darkside.com', 'Wookiee' => 'wookiee@aggrrttaaggrrt.com' } @spec.authors = hash - @spec.authors.should == hash + expect(@spec.authors).to eq(hash) end it 'supports the author attribute specified as an array' do @spec.authors = 'Darth Vader', 'Wookiee' - @spec.authors.should == { 'Darth Vader' => nil, 'Wookiee' => nil } + expect(@spec.authors).to eq({ 'Darth Vader' => nil, 'Wookiee' => nil }) end it 'supports the author attribute specified as a string' do @spec.authors = 'Darth Vader' - @spec.authors.should == { 'Darth Vader' => nil } + expect(@spec.authors).to eq({ 'Darth Vader' => nil }) end it 'supports the author attribute specified as an array of strings and hashes' do @spec.authors = ['Darth Vader', { 'Wookiee' => 'wookiee@aggrrttaaggrrt.com' }] - @spec.authors.should == { + expect(@spec.authors).to eq({ 'Darth Vader' => nil, 'Wookiee' => 'wookiee@aggrrttaaggrrt.com', - } + }) end it 'returns the social media url' do @spec.social_media_url = 'www.example.com' - @spec.social_media_url.should == 'www.example.com' + expect(@spec.social_media_url).to eq('www.example.com') end it 'returns the readme' do @spec.readme = 'www.example.com' - @spec.readme.should == 'www.example.com' + expect(@spec.readme).to eq('www.example.com') end it 'returns the changelog' do @spec.changelog = 'www.example.com' - @spec.changelog.should == 'www.example.com' + expect(@spec.changelog).to eq('www.example.com') end it 'supports the license attribute specified as a string' do @spec.license = 'MIT' - @spec.license.should == { :type => 'MIT' } + expect(@spec.license).to eq({ :type => 'MIT' }) end it 'supports the license attribute specified as a hash' do @spec.license = { 'type' => 'MIT', 'file' => 'MIT-LICENSE' } - @spec.license.should == { :type => 'MIT', :file => 'MIT-LICENSE' } + expect(@spec.license).to eq({ :type => 'MIT', :file => 'MIT-LICENSE' }) end it 'strips indentation from the license text' do @@ -116,26 +116,26 @@ module Pod Line2 DOC @spec.license = { 'type' => 'MIT', 'text' => text } - @spec.license[:text].should == "Line1\nLine2\n" + expect(@spec.license[:text]).to eq("Line1\nLine2\n") end it 'returns the empty hash if not license information has been specified' do - @spec.license.should == {} + expect(@spec.license).to eq({}) end it 'returns the homepage' do @spec.homepage = 'www.example.com' - @spec.homepage.should == 'www.example.com' + expect(@spec.homepage).to eq('www.example.com') end it 'returns the source' do @spec.source = { :git => 'www.example.com/repo.git' } - @spec.source.should == { :git => 'www.example.com/repo.git' } + expect(@spec.source).to eq({ :git => 'www.example.com/repo.git' }) end it 'returns the summary' do @spec.summary = 'A library that describes the meaning of life.' - @spec.summary.should == 'A library that describes the meaning of life.' + expect(@spec.summary).to eq('A library that describes the meaning of life.') end it 'returns the summary stripping indentation' do @@ -143,7 +143,7 @@ module Pod A quick brown fox. DESC @spec.summary = summary - @spec.summary.should == 'A quick brown fox.' + expect(@spec.summary).to eq('A quick brown fox.') end it 'returns the description stripping indentation' do @@ -152,17 +152,17 @@ module Pod Line2 DESC @spec.description = desc - @spec.description.should == "Line1\nLine2" + expect(@spec.description).to eq("Line1\nLine2") end it 'returns the screenshots' do @spec.screenshots = ['www.example.com/img1.png', 'www.example.com/img2.png'] - @spec.screenshots.should == ['www.example.com/img1.png', 'www.example.com/img2.png'] + expect(@spec.screenshots).to eq(['www.example.com/img1.png', 'www.example.com/img2.png']) end it 'support the specification of the attribute as a string' do @spec.screenshot = 'www.example.com/img1.png' - @spec.screenshots.should == ['www.example.com/img1.png'] + expect(@spec.screenshots).to eq(['www.example.com/img1.png']) end it 'returns the prepare command stripping the indentation' do @@ -170,43 +170,43 @@ module Pod ruby prepare_script.rb DESC @spec.prepare_command = command - @spec.prepare_command.should == 'ruby prepare_script.rb' + expect(@spec.prepare_command).to eq('ruby prepare_script.rb') end it 'returns whether the Pod should build a static framework' do @spec.static_framework = true - @spec.static_framework.should == true + expect(@spec.static_framework).to eq(true) end it 'returns whether the Pod has been deprecated' do @spec.deprecated = true - @spec.deprecated.should == true + expect(@spec.deprecated).to eq(true) end it 'returns the name of the Pod that this one has been deprecated in favor of' do @spec.deprecated_in_favor_of = 'NewMoreAwesomePod' - @spec.deprecated_in_favor_of.should == 'NewMoreAwesomePod' + expect(@spec.deprecated_in_favor_of).to eq('NewMoreAwesomePod') end it 'it returns wether it is deprecated either by deprecated or deprecated_in_favor_of' do @spec.deprecated = true - @spec.deprecated?.should == true + expect(@spec.deprecated?).to eq(true) @spec.deprecated = false @spec.deprecated_in_favor_of = 'NewMoreAwesomePod' - @spec.deprecated?.should == true + expect(@spec.deprecated?).to eq(true) @spec.deprecated_in_favor_of = nil - @spec.deprecated?.should == false + expect(@spec.deprecated?).to eq(false) end it 'returns the custom module map file, if specified' do @spec.module_map = 'module.modulemap' - @spec.module_map.should == 'module.modulemap' + expect(@spec.module_map).to eq('module.modulemap') end it 'returns the correct requires_arc value, if specified' do - @spec.requires_arc.should == true + expect(@spec.requires_arc).to eq(true) end end end diff --git a/spec/specification/set/presenter_spec.rb b/spec/specification/set/presenter_spec.rb index 6d86a32d7..5e53c4a0c 100644 --- a/spec/specification/set/presenter_spec.rb +++ b/spec/specification/set/presenter_spec.rb @@ -11,37 +11,37 @@ module Pod end it 'returns the set used to initialize it' do - @presenter.set.class.should == Specification::Set - @presenter.set.name.should == 'JSONKit' + expect(@presenter.set.class).to eq(Specification::Set) + expect(@presenter.set.name).to eq('JSONKit') end it 'returns the name' do - @presenter.name.should == 'JSONKit' + expect(@presenter.name).to eq('JSONKit') end it 'returns the version' do - @presenter.version.should == Version.new('999.999.999') + expect(@presenter.version).to eq(Version.new('999.999.999')) end it 'returns all the version sorted from the highest to the lowest' do - @presenter.versions.map(&:to_s).should == ['999.999.999', '1.13', '1.5pre', '1.4'] - @presenter.versions.last.class.should == Version + expect(@presenter.versions.map(&:to_s)).to eq(['999.999.999', '1.13', '1.5pre', '1.4']) + expect(@presenter.versions.last.class).to eq(Version) end it 'returns the versions by source' do - @presenter.versions_by_source.should == '999.999.999, 1.13, 1.4 [test_repo repo] - 1.5pre, 1.4 [trunk repo]' + expect(@presenter.versions_by_source).to eq('999.999.999, 1.13, 1.4 [test_repo repo] - 1.5pre, 1.4 [trunk repo]') end it 'returns the sources' do - @presenter.sources.should == %w(test_repo trunk) + expect(@presenter.sources).to eq(%w(test_repo trunk)) end it 'returns the correct deprecation description' do - @presenter.deprecation_description.should.nil? + expect(@presenter.deprecation_description).to be_nil @presenter.spec.deprecated = true - @presenter.deprecation_description.should == '[DEPRECATED]' + expect(@presenter.deprecation_description).to eq('[DEPRECATED]') @presenter.spec.deprecated_in_favor_of = 'NewMoreAwesomePod' - @presenter.deprecation_description.should == '[DEPRECATED in favor of NewMoreAwesomePod]' + expect(@presenter.deprecation_description).to eq('[DEPRECATED in favor of NewMoreAwesomePod]') end end @@ -53,55 +53,55 @@ module Pod end it 'returns the specification' do - @presenter.spec.class.should == Specification - @presenter.spec.name.should == 'CocoaLumberjack' + expect(@presenter.spec.class).to eq(Specification) + expect(@presenter.spec.name).to eq('CocoaLumberjack') end it 'returns the specification authors' do - @presenter.authors.should == 'Robbie Hanson' + expect(@presenter.authors).to eq('Robbie Hanson') @presenter.spec.authors = ['Author 1', 'Author 2'] - @presenter.authors.should == 'Author 1 and Author 2' + expect(@presenter.authors).to eq('Author 1 and Author 2') @presenter.spec.authors = ['Author 1', 'Author 2', 'Author 3'] - @presenter.authors.should == 'Author 1, Author 2, and Author 3' + expect(@presenter.authors).to eq('Author 1, Author 2, and Author 3') end it 'returns the homepage' do - @presenter.homepage.should == 'https://github.com/CocoaLumberjack/CocoaLumberjack' + expect(@presenter.homepage).to eq('https://github.com/CocoaLumberjack/CocoaLumberjack') end it 'returns the description' do - @presenter.description.should == 'It is similar in concept to other popular ' \ + expect(@presenter.description).to eq('It is similar in concept to other popular ' \ 'logging frameworks such as log4j, yet is designed specifically for ' \ 'objective-c, and takes advantage of features such as multi-threading, ' \ 'grand central dispatch (if available), lockless atomic operations, and ' \ - 'the dynamic nature of the objective-c runtime.' + 'the dynamic nature of the objective-c runtime.') end it 'returns the summary' do - @presenter.summary.should == 'A fast & simple, yet powerful & flexible logging framework for Mac and iOS.' + expect(@presenter.summary).to eq('A fast & simple, yet powerful & flexible logging framework for Mac and iOS.') end it 'returns the source_url' do - @presenter.source_url.should == 'https://github.com/CocoaLumberjack/CocoaLumberjack.git' + expect(@presenter.source_url).to eq('https://github.com/CocoaLumberjack/CocoaLumberjack.git') end it 'returns the platform' do - @presenter.platform.should == 'iOS 8.0 - macOS 10.10 - tvOS 9.0 - watchOS 3.0' + expect(@presenter.platform).to eq('iOS 8.0 - macOS 10.10 - tvOS 9.0 - watchOS 3.0') end it 'returns the license' do - @presenter.license.should == 'BSD' + expect(@presenter.license).to eq('BSD') end it 'returns the subspecs' do - @presenter.subspecs.map(&:name).should == ['CocoaLumberjack/Core', 'CocoaLumberjack/Swift'] + expect(@presenter.subspecs.map(&:name)).to eq(['CocoaLumberjack/Core', 'CocoaLumberjack/Swift']) set = Spec::Set.new('RestKit', @source) @presenter = Spec::Set::Presenter.new(set) subspecs = @presenter.subspecs - subspecs.last.class.should == Specification - subspecs.map(&:name).should == ['RestKit/Core', 'RestKit/ObjectMapping', 'RestKit/Network', 'RestKit/CoreData', 'RestKit/Testing', - 'RestKit/Search', 'RestKit/Support', 'RestKit/CocoaLumberjack'] + expect(subspecs.last.class).to eq(Specification) + expect(subspecs.map(&:name)).to eq(['RestKit/Core', 'RestKit/ObjectMapping', 'RestKit/Network', 'RestKit/CoreData', 'RestKit/Testing', + 'RestKit/Search', 'RestKit/Support', 'RestKit/CocoaLumberjack']) end end @@ -126,11 +126,11 @@ module Pod end it 'returns the GitHub stars' do - @presenter.github_stargazers.should == 7188 + expect(@presenter.github_stargazers).to eq(7188) end it 'returns the GitHub forks' do - @presenter.github_forks.should == 1726 + expect(@presenter.github_forks).to eq(1726) end end end diff --git a/spec/specification/set_spec.rb b/spec/specification/set_spec.rb index 7f0da0cb4..041522cf9 100644 --- a/spec/specification/set_spec.rb +++ b/spec/specification/set_spec.rb @@ -9,37 +9,37 @@ module Pod end it 'returns the name of the pod' do - @set.name.should == 'ReactiveObjC' + expect(@set.name).to eq('ReactiveObjC') end it 'returns the versions available for the pod ordered from highest to lowest' do - @set.versions.should.all { |v| v.is_a?(Version) } - @set.versions.map(&:to_s).should == %w(3.1.1 3.1.0 3.0.0 2.1.2 2.1.1 2.1.0 2.0.0 1.0.2 1.0.1) + expect(@set.versions).to all(be_a(Version)) + expect(@set.versions.map(&:to_s)).to eq(%w(3.1.1 3.1.0 3.0.0 2.1.2 2.1.1 2.1.0 2.0.0 1.0.2 1.0.1)) end it 'returns the highest version available for the pod' do - @set.highest_version.should == Version.new('3.1.1') + expect(@set.highest_version).to eq(Version.new('3.1.1')) end it 'returns the path of the spec with the highest version' do - @set.highest_version_spec_path.should == @source.repo + 'Specs/d/b/4/ReactiveObjC/3.1.1/ReactiveObjC.podspec.json' + expect(@set.highest_version_spec_path).to eq(@source.repo + 'Specs/d/b/4/ReactiveObjC/3.1.1/ReactiveObjC.podspec.json') end it 'can test if it is equal to another set' do - @set.should == Spec::Set.new('ReactiveObjC', @source) - @set.should.not == Spec::Set.new('RestKit', @source) + expect(@set).to eq(Spec::Set.new('ReactiveObjC', @source)) + expect(@set).not_to eq(Spec::Set.new('RestKit', @source)) end it 'returns a hash representation' do spec_path = @source.repo + 'Specs/d/b/4/ReactiveObjC/3.1.1/ReactiveObjC.podspec.json' - @set.to_hash.should == { + expect(@set.to_hash).to eq({ 'name' => 'ReactiveObjC', 'versions' => { 'trunk' => %w(3.1.1 3.1.0 3.0.0 2.1.2 2.1.1 2.1.0 2.0.0 1.0.2 1.0.1), }, 'highest_version' => '3.1.1', 'highest_version_spec' => spec_path.to_s, - } + }) end #--------------------------------------# @@ -47,9 +47,9 @@ module Pod it 'ignores dot files when getting the version directories' do @set.versions `touch #{fixture('spec-repos/trunk/2/2/2/DfPodTest/.DS_Store')}` - should.not.raise do + expect do @set.versions - end + end.not_to raise_error end end @@ -63,19 +63,19 @@ module Pod end it 'returns the sources where a podspec is available' do - @set.sources.map(&:name).should == %w(test_repo trunk) + expect(@set.sources.map(&:name)).to eq(%w(test_repo trunk)) end it 'returns all the available versions sorted from biggest to lowest' do - @set.versions.map(&:to_s).should == %w(999.999.999 1.13 1.5pre 1.4) + expect(@set.versions.map(&:to_s)).to eq(%w(999.999.999 1.13 1.5pre 1.4)) end it 'returns all the available versions by source sorted from biggest to lowest' do hash = {} @set.versions_by_source.each { |source, versions| hash[source.name] = versions.map(&:to_s) } - hash['trunk'].should == %w(1.5pre 1.4) - hash['test_repo'].should == %w(999.999.999 1.13 1.4) - hash.keys.sort.should == %w(test_repo trunk) + expect(hash['trunk']).to eq(%w(1.5pre 1.4)) + expect(hash['test_repo']).to eq(%w(999.999.999 1.13 1.4)) + expect(hash.keys.sort).to eq(%w(test_repo trunk)) end end end @@ -89,19 +89,19 @@ module Pod end it 'returns the specification' do - @set.specification.should == @spec + expect(@set.specification).to eq(@spec) end it 'returns the name' do - @set.name.should == 'BananaLib' + expect(@set.name).to eq('BananaLib') end it 'returns whether it is equal to another set' do - @set.should == Spec::Set::External.new(@spec) + expect(@set).to eq(Spec::Set::External.new(@spec)) end it 'returns the version of the specification' do - @set.versions.map(&:to_s).should == ['1.0'] + expect(@set.versions.map(&:to_s)).to eq(['1.0']) end end @@ -114,9 +114,8 @@ module Pod end it 'raises when encountering empty directories' do - @set.name.should == 'EmptyDir_spec' - exception = lambda { @set.specification }.should.raise Informative - exception.message.should.include 'Could not find the highest version for `EmptyDir_spec`.' + expect(@set.name).to eq('EmptyDir_spec') + expect { @set.specification }.to raise_error(Informative, a_string_including('Could not find the highest version for `EmptyDir_spec`.')) end end end diff --git a/spec/specification_spec.rb b/spec/specification_spec.rb index 2ba3cb5dc..52a314938 100644 --- a/spec/specification_spec.rb +++ b/spec/specification_spec.rb @@ -14,47 +14,47 @@ module Pod end it 'returns the parent' do - @subspec.parent.should == @spec + expect(@subspec.parent).to eq(@spec) end it 'returns the attributes hash' do - @spec.attributes_hash.should == { 'name' => 'Pod', 'version' => '1.0' } - @subspec.attributes_hash.should == { 'name' => 'Subspec' } + expect(@spec.attributes_hash).to eq({ 'name' => 'Pod', 'version' => '1.0' }) + expect(@subspec.attributes_hash).to eq({ 'name' => 'Subspec' }) end it 'returns the subspecs' do - @spec.subspecs.should == [@subspec] + expect(@spec.subspecs).to eq([@subspec]) end it 'allows dup-ing' do dup = @spec.dup - dup.subspecs.first.parent.should.equal? dup + expect(dup.subspecs.first.parent).to be(dup) end it 'returns whether it is equal to another specification' do - @spec.should == @spec + expect(@spec).to eq(@spec) end it 'is not equal to another specification if the name is different' do - @spec.should.not == Spec.new do |s| + expect(@spec).not_to eq(Spec.new do |s| s.name = 'Seed' s.version = '1.0' - end + end) end it 'is not equal to another specification if the version if different' do - @spec.should.not == Spec.new do |s| + expect(@spec).not_to eq(Spec.new do |s| s.name = 'Pod' s.version = '2.0' - end + end) end it 'is equal to another if the name and the version match regardless of the attributes' do - @spec.should == Spec.new do |s| + expect(@spec).to eq(Spec.new do |s| s.name = 'Pod' s.version = '1.0' s.source_files = 'Classes' - end + end) end it 'provides support for Array#uniq' do @@ -66,7 +66,7 @@ module Pod s.name = 'Pod' s.version = '1.0' end - [spec_1, spec_2].uniq.count.should == 1 + expect([spec_1, spec_2].uniq.count).to eq(1) end it 'provides support for being used as a the key of a Hash' do @@ -81,7 +81,7 @@ module Pod hash = {} hash[spec_1] = 'VALUE_1' hash[spec_2] = 'VALUE_2' - hash[spec_1].should == 'VALUE_2' + expect(hash[spec_1]).to eq('VALUE_2') end it 'strips newlines from versions' do @@ -90,153 +90,152 @@ module Pod s.version = "1.2.0\n" end - spec.to_hash['version'].should == '1.2.0' + expect(spec.to_hash['version']).to eq('1.2.0') end it 'resets hash value when name changes' do - @spec.hash_value.should.be.nil? + expect(@spec.hash_value).to be_nil original_hash = @spec.hash - @spec.hash_value.should.not.be.nil? + expect(@spec.hash_value).not_to be_nil @spec.name = 'NewPodName' - @spec.hash_value.should.be.nil? + expect(@spec.hash_value).to be_nil new_hash = @spec.hash - original_hash.should != new_hash + expect(original_hash).not_to eq(new_hash) end it 'resets hash value when version changes' do - @spec.hash_value.should.be.nil? + expect(@spec.hash_value).to be_nil original_hash = @spec.hash - @spec.hash_value.should.not.be.nil? + expect(@spec.hash_value).not_to be_nil @spec.version = '1.1' - @spec.hash_value.should.be.nil? + expect(@spec.hash_value).to be_nil new_hash = @spec.hash - original_hash.should != new_hash + expect(original_hash).not_to eq(new_hash) end describe '#to_s' do it 'produces a string representation suitable for UI output.' do - @spec.to_s.should == 'Pod (1.0)' + expect(@spec.to_s).to eq('Pod (1.0)') end it 'handles invalid version strings' do @spec.version = '{SOME_VERSION}' - @spec.to_s.should == 'Pod ({SOME_VERSION})' + expect(@spec.to_s).to eq('Pod ({SOME_VERSION})') end it 'includes the version in subspecs' do - @subspec.to_s.should == 'Pod/Subspec (1.0)' + expect(@subspec.to_s).to eq('Pod/Subspec (1.0)') end it 'includes malformed versions in subspecs' do @spec.version = '{SOME_VERSION}' - @subspec.to_s.should == 'Pod/Subspec ({SOME_VERSION})' + expect(@subspec.to_s).to eq('Pod/Subspec ({SOME_VERSION})') end end it 'handles the case where no version is available in the string representation' do spec_1 = Spec.new { |s| s.name = 'Pod' } - spec_1.to_s.should == 'Pod' + expect(spec_1.to_s).to eq('Pod') end it 'handles the case where no name is available in the string representation' do spec_1 = Spec.new - spec_1.to_s.should == 'No-name' + expect(spec_1.to_s).to eq('No-name') end it 'returns any empty array without any script phases' do spec = @spec.dup - spec.script_phases.should == [] + expect(spec.script_phases).to eq([]) end it 'returns the script phases with keys converted to symbols' do spec = @spec.dup spec.script_phase = [{ 'name' => 'Hello World', 'script' => 'echo "Hello World"', 'execution_position' => :before_compile }] - spec.script_phases.should == [{ :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :before_compile }] + expect(spec.script_phases).to eq([{ :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :before_compile }]) end it 'returns the script phases with default execution position' do spec = @spec.dup spec.script_phase = [{ 'name' => 'Hello World', 'script' => 'echo "Hello World"' }] - spec.script_phases.should == [{ :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :any }] + expect(spec.script_phases).to eq([{ :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :any }]) end describe '#validate_cocoapods_version' do it 'passes when none is specified' do spec_1 = Specification.new - should.not.raise { spec_1.validate_cocoapods_version } + expect { spec_1.validate_cocoapods_version }.not_to raise_error end it 'passes when the requirement is satisfied' do spec_1 = Specification.new { |s| s.cocoapods_version = '>= 0.1.0' } - should.not.raise { spec_1.validate_cocoapods_version } + expect { spec_1.validate_cocoapods_version }.not_to raise_error end it 'fails when the requirement is not satisfied' do spec_1 = Specification.new { |s| s.cocoapods_version = '= 999999.0.0' } - should.raise(Informative) { spec_1.validate_cocoapods_version }.message. - should.match /CocoaPods version/ + expect { spec_1.validate_cocoapods_version }.to raise_error(Informative, /CocoaPods version/) end end describe '::name_and_version_from_string' do it 'returns the name and the version of a Specification from its #to_s output' do name, version = Specification.name_and_version_from_string('libPusher (1.0)') - name.should == 'libPusher' - version.should == Version.new('1.0') + expect(name).to eq('libPusher') + expect(version).to eq(Version.new('1.0')) end it 'takes into account the full name of the subspec returning the name and the version' do string = 'RestKit/JSON (1.0)' name = Specification.name_and_version_from_string(string).first - name.should == 'RestKit/JSON' + expect(name).to eq('RestKit/JSON') end it 'handles names without version' do string = 'RestKit/JSON' name, version = Specification.name_and_version_from_string(string) - name.should == 'RestKit/JSON' - version.version.should.be.empty? + expect(name).to eq('RestKit/JSON') + expect(version.version).to be_empty end it 'handles names with a space without version' do string = 'RestKit/Subspec JSON' name, version = Specification.name_and_version_from_string(string) - name.should == 'RestKit/Subspec JSON' - version.version.should.be.empty? + expect(name).to eq('RestKit/Subspec JSON') + expect(version.version).to be_empty end it 'handles names with special characters without version' do string = 'RestKit_-+JSON' name, version = Specification.name_and_version_from_string(string) - name.should == 'RestKit_-+JSON' - version.version.should.be.empty? + expect(name).to eq('RestKit_-+JSON') + expect(version.version).to be_empty end it 'handles names with a space with version' do string = 'RestKit/Subspec JSON (1.0)' name, version = Specification.name_and_version_from_string(string) - name.should == 'RestKit/Subspec JSON' - version.version.should == '1.0' + expect(name).to eq('RestKit/Subspec JSON') + expect(version.version).to eq('1.0') end it 'handles names with special characters with version' do string = 'RestKit_-+JSON (1.0)' name, version = Specification.name_and_version_from_string(string) - name.should == 'RestKit_-+JSON' - version.version.should == '1.0' + expect(name).to eq('RestKit_-+JSON') + expect(version.version).to eq('1.0') end it 'raises if an invalid string representation is provided' do - should.raise Informative do + expect do Specification.name_and_version_from_string('missing_version ()') - end.message.should.match /Invalid string representation/ + end.to raise_error(Informative, /Invalid string representation/) end end describe '::root_name' do it 'returns the root name of a given specification name' do - Specification.root_name('Pod').should == 'Pod' - Specification.root_name('Pod/Subspec').should == 'Pod' + expect(Specification.root_name('Pod')).to eq('Pod') + expect(Specification.root_name('Pod/Subspec')).to eq('Pod') end end end @@ -260,59 +259,59 @@ module Pod end it 'returns the root spec' do - @spec.root.should == @spec - @subspec.root.should == @spec - @test_subspec.root.should == @spec - @app_subspec.root.should == @spec + expect(@spec.root).to eq(@spec) + expect(@subspec.root).to eq(@spec) + expect(@test_subspec.root).to eq(@spec) + expect(@app_subspec.root).to eq(@spec) end it 'returns whether it is a root spec' do - @spec.root?.should.be.true - @subspec.root?.should.be.false - @test_subspec.root?.should.be.false - @app_subspec.root?.should.be.false + expect(@spec.root?).to be(true) + expect(@subspec.root?).to be(false) + expect(@test_subspec.root?).to be(false) + expect(@app_subspec.root?).to be(false) end it 'returns whether it is a subspec' do - @spec.subspec?.should.be.false - @subspec.subspec?.should.be.true - @test_subspec.subspec?.should.be.true - @app_subspec.subspec?.should.be.true + expect(@spec.subspec?).to be(false) + expect(@subspec.subspec?).to be(true) + expect(@test_subspec.subspec?).to be(true) + expect(@app_subspec.subspec?).to be(true) end it 'returns whether it is a library_specification' do - @spec.library_specification?.should.be.true - @subspec.library_specification?.should.be.true - @test_subspec.library_specification?.should.be.false - @app_subspec.library_specification?.should.be.false + expect(@spec.library_specification?).to be(true) + expect(@subspec.library_specification?).to be(true) + expect(@test_subspec.library_specification?).to be(false) + expect(@app_subspec.library_specification?).to be(false) end it 'returns whether it is a non_library_specification' do - @spec.non_library_specification?.should.be.false - @subspec.non_library_specification?.should.be.false - @test_subspec.non_library_specification?.should.be.true - @app_subspec.non_library_specification?.should.be.true + expect(@spec.non_library_specification?).to be(false) + expect(@subspec.non_library_specification?).to be(false) + expect(@test_subspec.non_library_specification?).to be(true) + expect(@app_subspec.non_library_specification?).to be(true) end it 'returns whether it is a test_specification' do - @spec.test_specification?.should.be.false - @subspec.test_specification?.should.be.false - @test_subspec.test_specification?.should.be.true - @app_subspec.test_specification?.should.be.false + expect(@spec.test_specification?).to be(false) + expect(@subspec.test_specification?).to be(false) + expect(@test_subspec.test_specification?).to be(true) + expect(@app_subspec.test_specification?).to be(false) end it 'returns whether it is a app_specification' do - @spec.app_specification?.should.be.false - @subspec.app_specification?.should.be.false - @test_subspec.app_specification?.should.be.false - @app_subspec.app_specification?.should.be.true + expect(@spec.app_specification?).to be(false) + expect(@subspec.app_specification?).to be(false) + expect(@test_subspec.app_specification?).to be(false) + expect(@app_subspec.app_specification?).to be(true) end it 'returns the correct spec_type' do - @spec.spec_type.should == :library - @subspec.spec_type.should == :library - @test_subspec.spec_type.should == :test - @app_subspec.spec_type.should == :app + expect(@spec.spec_type).to eq(:library) + expect(@subspec.spec_type).to eq(:library) + expect(@test_subspec.spec_type).to eq(:test) + expect(@app_subspec.spec_type).to eq(:app) end end @@ -344,12 +343,12 @@ module Pod end it 'returns the recursive subspecs' do - @spec.recursive_subspecs.sort_by(&:name).should == [@subspec, @subsubspec, @subspec_osx, @subspec_ios] + expect(@spec.recursive_subspecs.sort_by(&:name)).to eq([@subspec, @subsubspec, @subspec_osx, @subspec_ios]) end it 'returns a subspec given the absolute name' do - @spec.subspec_by_name('Pod/Subspec').should == @subspec - @spec.subspec_by_name('Pod/Subspec/Subsubspec').should == @subsubspec + expect(@spec.subspec_by_name('Pod/Subspec')).to eq(@subspec) + expect(@spec.subspec_by_name('Pod/Subspec/Subsubspec')).to eq(@subsubspec) end it "doesn't return the test subspec given its name" do @@ -360,7 +359,7 @@ module Pod s.osx.dependency 'MagicalRecord' s.test_spec {} end - @spec.subspec_by_name('Pod/Tests', false).should. nil? + expect(@spec.subspec_by_name('Pod/Tests', false)).to be_nil end it "does return the test subspec given it's name when including test subspecs" do @@ -372,7 +371,7 @@ module Pod s.test_spec {} end test_spec = @spec.test_specs.first - @spec.subspec_by_name('Pod/Tests', false, true).should == test_spec + expect(@spec.subspec_by_name('Pod/Tests', false, true)).to eq(test_spec) end it "doesn't return the app subspec given its name" do @@ -383,7 +382,7 @@ module Pod s.osx.dependency 'MagicalRecord' s.app_spec {} end - @spec.subspec_by_name('Pod/App', false).should. nil? + expect(@spec.subspec_by_name('Pod/App', false)).to be_nil end it "does return the app subspec given it's name when including app subspecs" do @@ -395,27 +394,27 @@ module Pod s.app_spec {} end app_spec = @spec.app_specs.first - @spec.subspec_by_name('Pod/App', false, true).should == app_spec + expect(@spec.subspec_by_name('Pod/App', false, true)).to eq(app_spec) end it 'returns a subspec given the relative name' do - @subspec.subspec_by_name('Subspec/Subsubspec').should == @subsubspec + expect(@subspec.subspec_by_name('Subspec/Subsubspec')).to eq(@subsubspec) end it "raises if it can't find a subspec with the given name" do - lambda { @spec.subspec_by_name('Pod/Nonexistent') }.should.raise Informative + expect { @spec.subspec_by_name('Pod/Nonexistent') }.to raise_error(Informative) end it 'raises if there is a base name case mis-match' do - lambda { @spec.subspec_by_name('pod') }.should.raise Informative + expect { @spec.subspec_by_name('pod') }.to raise_error(Informative) end it "returns if it can't find a subspec with the given name and raise_if_missing is false" do - @spec.subspec_by_name('Pod/Nonexistent', false).should.be.nil? + expect(@spec.subspec_by_name('Pod/Nonexistent', false)).to be_nil end it "returns if it can't find a deeply nested subspec with the given name and raise_if_missing is false" do - @spec.subspec_by_name('Pod/Subspec/Subsubspec/Missing', false).should.be.nil? + expect(@spec.subspec_by_name('Pod/Subspec/Subsubspec/Missing', false)).to be_nil end describe 'deprecated podspec' do @@ -423,117 +422,117 @@ module Pod @spec = Spec.new do |s| s.deprecated_in_favor_of = 'SomeOtherSpec' end - @spec.subspec_by_name('subspec', false).should.be.nil? + expect(@spec.subspec_by_name('subspec', false)).to be_nil end end it 'returns the default subspecs' do spec = @spec.dup spec.default_subspecs = 'Subspec1', 'Subspec2' - spec.default_subspecs.should == %w(Subspec1 Subspec2) + expect(spec.default_subspecs).to eq(%w(Subspec1 Subspec2)) end it 'supports the specification of the default subspecs as a string' do spec = @spec.dup spec.default_subspecs = 'Subspec1' - spec.default_subspecs.should == %w(Subspec1) + expect(spec.default_subspecs).to eq(%w(Subspec1)) end it 'supports the specification of the default subspecs as a symbol' do spec = @spec.dup spec.default_subspecs = :none - spec.default_subspecs.should == :none + expect(spec.default_subspecs).to eq(:none) end it 'returns the dependencies on its subspecs' do - @spec.subspec_dependencies.sort.should == [ + expect(@spec.subspec_dependencies.sort).to eq([ Dependency.new('Pod/Subspec', '1.0'), Dependency.new('Pod/SubspecOSX', '1.0'), - Dependency.new('Pod/SubspeciOS', '1.0')] + Dependency.new('Pod/SubspeciOS', '1.0')]) end it 'returns the dependencies on its subspecs for a given platform' do - @spec.subspec_dependencies(:ios).should == [ + expect(@spec.subspec_dependencies(:ios)).to eq([ Dependency.new('Pod/Subspec', '1.0'), Dependency.new('Pod/SubspeciOS', '1.0'), - ] + ]) end it 'returns no default subspecs if none is specified' do @spec.default_subspecs = :none - @spec.subspec_dependencies.should.be.empty + expect(@spec.subspec_dependencies).to be_empty end it 'returns a dependency on a default subspecs if it is specified' do @spec.default_subspecs = 'Subspec', 'SubspeciOS' - @spec.subspec_dependencies.should == [ + expect(@spec.subspec_dependencies).to eq([ Dependency.new('Pod/Subspec', '1.0'), Dependency.new('Pod/SubspeciOS', '1.0'), - ] + ]) end it 'excludes the test subspec from the subspec dependencies' do @spec.test_spec {} - @spec.subspec_dependencies.sort.should == [ + expect(@spec.subspec_dependencies.sort).to eq([ Dependency.new('Pod/Subspec', '1.0'), Dependency.new('Pod/SubspecOSX', '1.0'), - Dependency.new('Pod/SubspeciOS', '1.0')] + Dependency.new('Pod/SubspeciOS', '1.0')]) end it 'excludes the app subspec from the subspec dependencies' do @spec.app_spec {} - @spec.subspec_dependencies.sort.should == [ + expect(@spec.subspec_dependencies.sort).to eq([ Dependency.new('Pod/Subspec', '1.0'), Dependency.new('Pod/SubspecOSX', '1.0'), - Dependency.new('Pod/SubspeciOS', '1.0')] + Dependency.new('Pod/SubspeciOS', '1.0')]) end it 'returns all the dependencies' do - @spec.dependencies.sort.should == [ + expect(@spec.dependencies.sort).to eq([ Dependency.new('AFNetworking'), - Dependency.new('MagicalRecord')] + Dependency.new('MagicalRecord')]) end it 'returns the test spec dependencies' do test_spec = @spec.test_spec { |s| s.dependency 'OCMock' } - test_spec.dependencies.sort.should == [ + expect(test_spec.dependencies.sort).to eq([ Dependency.new('AFNetworking'), Dependency.new('MagicalRecord'), Dependency.new('OCMock'), - ] + ]) end it 'returns the app spec dependencies' do app_spec = @spec.app_spec { |s| s.dependency 'OCMock' } - app_spec.dependencies.sort.should == [ + expect(app_spec.dependencies.sort).to eq([ Dependency.new('AFNetworking'), Dependency.new('MagicalRecord'), Dependency.new('OCMock'), - ] + ]) end it 'returns the dependencies given the platform' do - @spec.dependencies(:ios).sort.should == [Dependency.new('AFNetworking')] + expect(@spec.dependencies(:ios).sort).to eq([Dependency.new('AFNetworking')]) end it 'inherits the dependencies of the parent' do - @subsubspec.dependencies(:ios).sort.should == [Dependency.new('AFNetworking'), Dependency.new('libPusher')] + expect(@subsubspec.dependencies(:ios).sort).to eq([Dependency.new('AFNetworking'), Dependency.new('libPusher')]) end it 'returns all the dependencies including the ones on subspecs given a platform' do - @spec.all_dependencies.sort.should == [ + expect(@spec.all_dependencies.sort).to eq([ Dependency.new('AFNetworking'), Dependency.new('MagicalRecord'), Dependency.new('Pod/Subspec', '1.0'), Dependency.new('Pod/SubspecOSX', '1.0'), - Dependency.new('Pod/SubspeciOS', '1.0')] + Dependency.new('Pod/SubspeciOS', '1.0')]) end it 'returns all the dependencies for a given platform' do - @spec.all_dependencies(:ios).sort.should == [ + expect(@spec.all_dependencies(:ios).sort).to eq([ Dependency.new('AFNetworking'), Dependency.new('Pod/Subspec', '1.0'), - Dependency.new('Pod/SubspeciOS', '1.0')] + Dependency.new('Pod/SubspeciOS', '1.0')]) end it 'returns always true that a dependency is whitelisted if no configurations are specified' do @@ -542,12 +541,12 @@ module Pod s.version = '1.0' s.dependency 'AFNetworking' end - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :debug).should.be.true - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'debug').should.be.true - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Debug').should.be.true - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :release).should.be.true - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'release').should.be.true - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Release').should.be.true + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :debug)).to be(true) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'debug')).to be(true) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Debug')).to be(true) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :release)).to be(true) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'release')).to be(true) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Release')).to be(true) end it 'returns correctly whether a dependency is whitelisted for a given config' do @@ -556,12 +555,12 @@ module Pod s.version = '1.0' s.dependency 'AFNetworking', :configurations => ['Debug'] end - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :debug).should.be.true - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'debug').should.be.true - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Debug').should.be.true - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :release).should.be.false - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'release').should.be.false - @spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Release').should.be.false + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :debug)).to be(true) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'debug')).to be(true) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Debug')).to be(true) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :release)).to be(false) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'release')).to be(false) + expect(@spec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Release')).to be(false) end it 'returns correctly whether a dependency is whitelisted for a given config in a subspec' do @@ -573,12 +572,12 @@ module Pod end end @subspec = @spec.subspecs.first - @subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :debug).should.be.true - @subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'debug').should.be.true - @subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Debug').should.be.true - @subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :release).should.be.false - @subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'release').should.be.false - @subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Release').should.be.false + expect(@subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :debug)).to be(true) + expect(@subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'debug')).to be(true) + expect(@subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Debug')).to be(true) + expect(@subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), :release)).to be(false) + expect(@subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'release')).to be(false) + expect(@subspec.dependency_whitelisted_for_configuration?(Dependency.new('AFNetworking'), 'Release')).to be(false) end end @@ -597,72 +596,72 @@ module Pod it 'reports if it is locally sourced' do @spec.source = { 'path' => '/tmp/local/path' } - @spec.local?.should.be.true + expect(@spec.local?).to be(true) end it 'returns whether it is supported on a given platform' do @spec.platform = :ios, '4.0' - @spec.supported_on_platform?(:ios).should.be.true - @spec.supported_on_platform?(:ios, '4.0').should.be.true - @spec.supported_on_platform?(:ios, '3.0').should.be.false - @spec.supported_on_platform?(:osx).should.be.false - @spec.supported_on_platform?(:osx, '10.5').should.be.false + expect(@spec.supported_on_platform?(:ios)).to be(true) + expect(@spec.supported_on_platform?(:ios, '4.0')).to be(true) + expect(@spec.supported_on_platform?(:ios, '3.0')).to be(false) + expect(@spec.supported_on_platform?(:osx)).to be(false) + expect(@spec.supported_on_platform?(:osx, '10.5')).to be(false) end it 'returns the available platforms for which the pod is supported' do @spec.platform = :ios, '4.0' - @spec.available_platforms.should == [Platform.new(:ios, '4.0')] + expect(@spec.available_platforms).to eq([Platform.new(:ios, '4.0')]) end it 'inherits the name of the supported platforms from the parent' do @spec.platform = :ios, '4.0' - @subspec.available_platforms.should == [Platform.new(:ios, '4.0')] + expect(@subspec.available_platforms).to eq([Platform.new(:ios, '4.0')]) end it 'returns the deployment target for the given platform' do @spec.platform = :ios, '4.0' - @spec.deployment_target(:ios).should == '4.0' + expect(@spec.deployment_target(:ios)).to eq('4.0') end it 'allows a subspec to override the deployment target of the parent' do @spec.platform = :ios, '4.0' @subspec.ios.deployment_target = '5.0' - @subspec.deployment_target(:ios).should == '5.0' + expect(@subspec.deployment_target(:ios)).to eq('5.0') end it 'inherits the deployment target from the parent' do @spec.platform = :ios, '4.0' - @subspec.deployment_target(:ios).should == '4.0' + expect(@subspec.deployment_target(:ios)).to eq('4.0') end it 'returns the names of the supported platforms as specified by the user' do @spec.platform = :ios, '4.0' - @spec.send(:supported_platform_names).should == ['ios'] + expect(@spec.send(:supported_platform_names)).to eq(['ios']) end it 'inherits the supported platform from the parent' do @spec.platform = :ios - @subspec.send(:supported_platform_names).should == ['ios'] + expect(@subspec.send(:supported_platform_names)).to eq(['ios']) end it 'returns the consumer for the given symbolic name of a platform' do @spec.ios.source_files = 'ios-files' consumer = @spec.consumer(:ios) - consumer.spec.should == @spec - consumer.platform_name.should == :ios - consumer.source_files.should == ['ios-files'] + expect(consumer.spec).to eq(@spec) + expect(consumer.platform_name).to eq(:ios) + expect(consumer.source_files).to eq(['ios-files']) end it 'returns the consumer of a given platform' do consumer = @spec.consumer(Platform.new :ios) - consumer.spec.should == @spec - consumer.platform_name.should == :ios + expect(consumer.spec).to eq(@spec) + expect(consumer.platform_name).to eq(:ios) end it 'caches the consumers per platform' do - @spec.consumer(:ios).should.equal @spec.consumer(:ios) - @spec.consumer(:ios).platform_name.should == :ios - @spec.consumer(:osx).platform_name.should == :osx + expect(@spec.consumer(:ios)).to eq(@spec.consumer(:ios)) + expect(@spec.consumer(:ios).platform_name).to eq(:ios) + expect(@spec.consumer(:osx).platform_name).to eq(:osx) end end @@ -675,26 +674,26 @@ module Pod it 'stores the value of an attribute' do @spec.store_attribute(:attribute, 'value') - @spec.attributes_hash.should == { + expect(@spec.attributes_hash).to eq({ 'name' => nil, 'attribute' => 'value', - } + }) end it 'stores the value of an attribute for a given platform' do @spec.store_attribute(:attribute, 'value', :ios) - @spec.attributes_hash.should == { + expect(@spec.attributes_hash).to eq({ 'name' => nil, 'ios' => { 'attribute' => 'value' }, - } + }) end it 'converts the keys of the hashes to a string' do @spec.store_attribute(:attribute, :key => 'value') - @spec.attributes_hash.should == { + expect(@spec.attributes_hash).to eq({ 'name' => nil, 'attribute' => { 'key' => 'value' }, - } + }) end it 'strips heredoc leading space from strings' do @@ -703,19 +702,19 @@ module Pod bar EOS @spec.store_attribute(:attribute, value) - @spec.attributes_hash.should == { + expect(@spec.attributes_hash).to eq({ 'name' => nil, 'attribute' => "foo\n bar", - } + }) end it 'strips trailing space from strings' do value = "foo\n" @spec.store_attribute(:attribute, value) - @spec.attributes_hash.should == { + expect(@spec.attributes_hash).to eq({ 'name' => nil, 'attribute' => 'foo', - } + }) end it 'declares attribute writer methods' do @@ -729,7 +728,7 @@ module Pod end @spec.send(attr.writer_name, value) - @spec.attributes_hash[attr.name.to_s].should == value + expect(@spec.attributes_hash[attr.name.to_s]).to eq(value) end end @@ -737,7 +736,7 @@ module Pod singular_attrs = Specification::DSL.attributes.values.select(&:writer_singular_form) singular_attrs.each do |attr| @spec.send(attr.writer_name, 'a_value') - @spec.attributes_hash[attr.name.to_s].should == 'a_value' + expect(@spec.attributes_hash[attr.name.to_s]).to eq('a_value') end end end @@ -747,29 +746,29 @@ module Pod describe 'Initialization from a file' do it 'can be initialized from a file' do spec = Spec.from_file(fixture('BananaLib.podspec')) - spec.class.should == Spec - spec.name.should == 'BananaLib' + expect(spec.class).to eq(Spec) + expect(spec.name).to eq('BananaLib') end it 'can be initialized from a JSON file' do Dir.expects(:chdir).never spec = Spec.from_file(fixture('BananaLib.podspec.json')) - spec.class.should == Spec - spec.name.should == 'BananaLib' + expect(spec.class).to eq(Spec) + expect(spec.name).to eq('BananaLib') end it "presents an informative if the given file file doesn't exits" do - should.raise Informative do + expect do Spec.from_file('Missing.podspec') - end.message.should.match /No podspec exists/ + end.to raise_error(Informative, /No podspec exists/) end it "presents an informative if it can't handle the specification format" do Pathname.any_instance.stubs(:exist?).returns(true) File.stubs(:open).returns('') - should.raise Informative do + expect do Spec.from_file('Missing.podspec.csv') - end.message.should.match /Unsupported specification format/ + end.to raise_error(Informative, /Unsupported specification format/) end it "is initialized in the context of the file's directory" do @@ -778,12 +777,12 @@ module Pod File.any_instance.stubs(:read).returns(contents) spec = Spec.from_file(fixture('BananaLib.podspec')) - spec.class.should == Spec - spec.name.should == 'fixtures' + fixture('BananaLib.podspec').to_s + expect(spec.class).to eq(Spec) + expect(spec.name).to eq('fixtures' + fixture('BananaLib.podspec').to_s) spec = Spec.from_file(fixture('BananaLib.podspec').relative_path_from(Pathname.pwd)) - spec.class.should == Spec - spec.name.should == 'fixtures' + fixture('BananaLib.podspec').to_s + expect(spec.class).to eq(Spec) + expect(spec.name).to eq('fixtures' + fixture('BananaLib.podspec').to_s) end #--------------------------------------# @@ -794,16 +793,16 @@ module Pod end it 'returns the checksum of the file in which it is defined' do - @spec.checksum.should == '4fb39cb6f34f694ab489d39df699c5b7c7f9ac79' + expect(@spec.checksum).to eq('4fb39cb6f34f694ab489d39df699c5b7c7f9ac79') end it 'returns a nil checksum if the specification is not defined in a file' do spec = Spec.new - spec.checksum.should.be.nil + expect(spec.checksum).to be_nil end it 'reports the file from which it was initialized' do - @spec.defined_in_file.should == @path + expect(@spec.defined_in_file).to eq(@path) end it 'raises if there is an attempt to set the file in which the spec is defined for a subspec' do @@ -813,9 +812,9 @@ module Pod s.subspec 'Subspec' do |_sp| end end - should.raise StandardError do + expect do spec.subspecs.first.defined_in_file = 'Some-file' - end.message.should.match /can be set only for root specs/ + end.to raise_error(StandardError, /can be set only for root specs/) end end @@ -824,31 +823,31 @@ module Pod describe 'module name' do it 'uses the specification name as module name by default' do spec = Specification.new(nil, 'Three20') - spec.module_name.should == 'Three20' + expect(spec.module_name).to eq('Three20') end it 'converts the name to a C99 identifier if required' do spec = Specification.new(nil, '500px') - spec.module_name.should == '_500px' + expect(spec.module_name).to eq('_500px') end it 'uses the header_dir as module name if specified' do spec = Specification.new(nil, 'Three20.swift') spec.header_dir = 'Three20' - spec.module_name.should == 'Three20' + expect(spec.module_name).to eq('Three20') end it 'converts the header_dir to a C99 identifier if required' do spec = Specification.new(nil, 'Three20.swift') spec.header_dir = 'Three-20' - spec.module_name.should == 'Three_20' + expect(spec.module_name).to eq('Three_20') end it 'uses the defined module name if specified' do spec = Specification.new(nil, 'Three20.swift') spec.header_dir = 'Three20Core' spec.module_name = 'Three20' - spec.module_name.should == 'Three20' + expect(spec.module_name).to eq('Three20') end end @@ -860,15 +859,15 @@ module Pod end it 'should mask, but keep leading numbers' do - @spec.send(:c99ext_identifier, '123BananaLib').should == '_123BananaLib' + expect(@spec.send(:c99ext_identifier, '123BananaLib')).to eq('_123BananaLib') end it 'should mask invalid chars' do - @spec.send(:c99ext_identifier, 'iOS-App BânánàLïb').should == 'iOS_App_BananaLib' + expect(@spec.send(:c99ext_identifier, 'iOS-App BânánàLïb')).to eq('iOS_App_BananaLib') end it 'should flatten multiple underscores to a single one' do - @spec.send(:c99ext_identifier, '$.swift').should == '_swift' + expect(@spec.send(:c99ext_identifier, '$.swift')).to eq('_swift') end end diff --git a/spec/standard_error_spec.rb b/spec/standard_error_spec.rb index bd0b9a2e9..09a97334c 100644 --- a/spec/standard_error_spec.rb +++ b/spec/standard_error_spec.rb @@ -18,7 +18,7 @@ module Pod end it 'returns a properly formed message' do - @err.message.should == <<-MSG.strip_heredoc + expect(@err.message).to eq(<<-MSG.strip_heredoc) [!] Invalid podspec. @@ -34,7 +34,8 @@ module Pod it 'parses syntax error messages for well-formed messages' do code = "puts 'hi'\nputs())\nputs 'bye'" # rubocop:disable Security/Eval - syntax_error = should.raise(SyntaxError) { eval(code, nil, @dsl_path.to_s) } + syntax_error = nil + expect { eval(code, nil, @dsl_path.to_s) }.to raise_error(SyntaxError) { |e| syntax_error = e } # rubocop:enable Security/Eval @err.stubs(:description).returns("Invalid `Three20.podspec` file: #{syntax_error.message}") @err.stubs(:underlying_exception).returns(syntax_error) @@ -86,13 +87,13 @@ module Pod end # Ruby colorizes the syntax error snippet when running in a TTY, so # strip ANSI escape sequences to keep the comparison TTY-agnostic. - @err.message.gsub(/\e\[[0-9;]*m/, '').should == expected + expect(@err.message.gsub(/\e\[[0-9;]*m/, '')).to eq(expected) end it 'uses the passed-in contents' do @err.stubs(:contents).returns("puts 'hi'\nputs 'there'\nputs 'bye'") File.expects(:exist?).never - @err.message.should == <<-MSG.strip_heredoc + expect(@err.message).to eq(<<-MSG.strip_heredoc) [!] Invalid podspec. @@ -106,56 +107,56 @@ module Pod end it 'includes the given description in the message' do - @err.message.should.include?('Invalid podspec.') + expect(@err.message).to include('Invalid podspec.') end it 'includes the path of the dsl file in the message' do - @err.message.should.include?("from #{@dsl_path}") + expect(@err.message).to include("from #{@dsl_path}") end it 'includes in the message the contents of the line that raised the exception' do - @err.message.should.include?('error line') + expect(@err.message).to include('error line') end it 'is robust against a nil backtrace' do @err.underlying_exception.stubs(:backtrace => nil) - lambda { @err.message }.should.not.raise + expect { @err.message }.not_to raise_error end it 'is robust against a backtrace non including the path of the dsl file' do @err.underlying_exception.stubs(:backtrace).returns [ "lib/cocoapods-core/specification.rb:41:in `initialize'", ] - lambda { @err.message }.should.not.raise + expect { @err.message }.not_to raise_error end it "is robust against a backtrace that doesn't include the line number of the dsl file that originated the error" do @err.underlying_exception.stubs(:backtrace).returns [@dsl_path.to_s] - lambda { @err.message }.should.not.raise + expect { @err.message }.not_to raise_error end it 'is against a nil path of the dsl file' do @err.stubs(:dsl_path => nil) - lambda { @err.message }.should.not.raise + expect { @err.message }.not_to raise_error end it 'is robust against non existing paths' do @err.stubs(:dsl_path => 'find_me_baby') - lambda { @err.message }.should.not.raise + expect { @err.message }.not_to raise_error end it 'can handle the first line of the dsl file' do @err.underlying_exception.stubs(:backtrace).returns ["#{@dsl_path}:1"] - lambda { @err.message }.should.not.raise - @err.message.should.include?('first line') - @err.message.should.not.include?('last line') + expect { @err.message }.not_to raise_error + expect(@err.message).to include('first line') + expect(@err.message).not_to include('last line') end it 'can handle the last line of the dsl file' do @err.underlying_exception.stubs(:backtrace).returns ["#{@dsl_path}:3"] - lambda { @err.message }.should.not.raise - @err.message.should.not.include?('first line') - @err.message.should.include?('last line') + expect { @err.message }.not_to raise_error + expect(@err.message).not_to include('first line') + expect(@err.message).to include('last line') end end end diff --git a/spec/trunk_source_spec.rb b/spec/trunk_source_spec.rb index b27bde45e..3c6f2483d 100644 --- a/spec/trunk_source_spec.rb +++ b/spec/trunk_source_spec.rb @@ -10,11 +10,11 @@ module Pod #-------------------------------------------------------------------------# it 'uses the correct repo name' do - @source.name.should == 'trunk' + expect(@source.name).to eq('trunk') end it 'uses the correct repo URL' do - @source.url.should == 'https://cdn.cocoapods.org/' + expect(@source.url).to eq('https://cdn.cocoapods.org/') end #-------------------------------------------------------------------------# diff --git a/spec/version_spec.rb b/spec/version_spec.rb index 451033187..bdd54e051 100644 --- a/spec/version_spec.rb +++ b/spec/version_spec.rb @@ -5,43 +5,43 @@ module Pod describe 'In general' do it 'initializes from a string' do version = Version.new('1.2.3') - version.version.should == '1.2.3' + expect(version.version).to eq('1.2.3') end it 'initializes from a frozen string' do version = Version.new('1.2.3'.freeze) - version.version.should == '1.2.3' + expect(version.version).to eq('1.2.3') end it 'serializes to a string' do version = Version.new('1.2.3') - version.to_s.should == '1.2.3' + expect(version.to_s).to eq('1.2.3') end it 'does not accept negative versions' do - should.raise ArgumentError do + expect do Version.new('-1') - end + end.to raise_error(ArgumentError) end it 'identifies release versions' do version = Version.new('1.0.0') - version.should.not.be.prerelease + expect(version).not_to be_prerelease version = Version.new('1.0.0+exp.sha1.77cb5a') - version.should.not.be.prerelease + expect(version).not_to be_prerelease end it 'matches Semantic Version pre-release versions' do version = Version.new('1.0.0a1') - version.should.be.prerelease + expect(version).to be_prerelease version = Version.new('1.0.0-alpha') - version.should.be.prerelease + expect(version).to be_prerelease version = Version.new('1.0.0-alpha.1') - version.should.be.prerelease + expect(version).to be_prerelease version = Version.new('1.0.0-0.3.7') - version.should.be.prerelease + expect(version).to be_prerelease version = Version.new('1.0.0-x.7.z.92') - version.should.be.prerelease + expect(version).to be_prerelease end end @@ -49,105 +49,105 @@ module Pod describe 'Semantic Versioning' do it 'reports a version as semantic' do - Version.new('1.9.0').should.be.semantic - Version.new('1.10.0').should.be.semantic + expect(Version.new('1.9.0')).to be_semantic + expect(Version.new('1.10.0')).to be_semantic end it 'leniently reports version with two segments version a semantic' do - Version.new('1.0').should.be.semantic + expect(Version.new('1.0')).to be_semantic end it 'leniently reports version with one segment version a semantic' do - Version.new('1').should.be.semantic + expect(Version.new('1')).to be_semantic end it 'reports a pre-release version as semantic' do - Version.new('1.0.0-alpha').should.be.semantic - Version.new('1.0.0-alpha.1').should.be.semantic - Version.new('1.0.0-0.3.7').should.be.semantic - Version.new('1.0.0-x.7.z.92').should.be.semantic + expect(Version.new('1.0.0-alpha')).to be_semantic + expect(Version.new('1.0.0-alpha.1')).to be_semantic + expect(Version.new('1.0.0-0.3.7')).to be_semantic + expect(Version.new('1.0.0-x.7.z.92')).to be_semantic end it 'reports a version with metadata as semantic' do # Examples from http://semver.org/#spec-item-10 - Version.new('1.0.0+5').should.be.semantic - Version.new('1.0.0+5114f85').should.be.semantic - Version.new('1.0.0-alpha+exp.sha.5114f85').should.be.semantic + expect(Version.new('1.0.0+5')).to be_semantic + expect(Version.new('1.0.0+5114f85')).to be_semantic + expect(Version.new('1.0.0-alpha+exp.sha.5114f85')).to be_semantic end it 'reports version with more than 3 segments not separated by a dash as non semantic' do - Version.new('1.0.2.3').should.not.be.semantic + expect(Version.new('1.0.2.3')).not_to be_semantic end it 'reports version with a dash without the X.Y.Z format as non semantic' do - Version.new('1.0-alpha').should.not.be.semantic + expect(Version.new('1.0-alpha')).not_to be_semantic end it 'returns the major identifier' do - Version.new('1.9.0').major.should == 1 - Version.new('1.0.0-alpha').major.should == 1 - Version.new('1.alpha').major.should == 1 + expect(Version.new('1.9.0').major).to eq(1) + expect(Version.new('1.0.0-alpha').major).to eq(1) + expect(Version.new('1.alpha').major).to eq(1) end it 'returns the minor identifier' do - Version.new('1.9.0').minor.should == 9 - Version.new('1.0.0-alpha').minor.should == 0 - Version.new('1').minor.should == 0 - Version.new('1.alpha').minor.should == 0 + expect(Version.new('1.9.0').minor).to eq(9) + expect(Version.new('1.0.0-alpha').minor).to eq(0) + expect(Version.new('1').minor).to eq(0) + expect(Version.new('1.alpha').minor).to eq(0) end it 'returns the patch identifier' do - Version.new('1.9.0').patch.should == 0 - Version.new('1.0.1-alpha').patch.should == 1 - Version.new('1').patch.should == 0 - Version.new('1.alpha').patch.should == 0 - Version.new('1.alpha.2').patch.should == 0 + expect(Version.new('1.9.0').patch).to eq(0) + expect(Version.new('1.0.1-alpha').patch).to eq(1) + expect(Version.new('1').patch).to eq(0) + expect(Version.new('1.alpha').patch).to eq(0) + expect(Version.new('1.alpha.2').patch).to eq(0) end it 'correctly makes basic version comparisons' do - Version.new('1.0.0').should.be < Version.new('2.0.0') - Version.new('1.0.0').should.be < Version.new('1.0.1') - Version.new('1.0.0').should.be < Version.new('1.1.0') - Version.new('1.1.0').should.be < Version.new('1.1.1') + expect(Version.new('1.0.0')).to be < Version.new('2.0.0') + expect(Version.new('1.0.0')).to be < Version.new('1.0.1') + expect(Version.new('1.0.0')).to be < Version.new('1.1.0') + expect(Version.new('1.1.0')).to be < Version.new('1.1.1') end it 'correctly ignores metadata in comparisons' do - Version.new('1.0.0+fff').should == Version.new('1.0.0') - Version.new('1.0.0+fff').should == Version.new('1.0.0+000') - Version.new('1.0.0-beta.1+fff').should == Version.new('1.0.0-beta.1+000') - Version.new('1.1.0+fff').should.be < Version.new('1.1.1+fff') + expect(Version.new('1.0.0+fff')).to eq(Version.new('1.0.0')) + expect(Version.new('1.0.0+fff')).to eq(Version.new('1.0.0+000')) + expect(Version.new('1.0.0-beta.1+fff')).to eq(Version.new('1.0.0-beta.1+000')) + expect(Version.new('1.1.0+fff')).to be < Version.new('1.1.1+fff') end it 'ignores missing numeric identifiers while comparing' do - Version.new('1.9.0-alpha').should.be < Version.new('1.9-beta') - Version.new('2.0.0-beta').should.be < Version.new('2.0-rc') - Version.new('2.0.0.0.0.0.1-beta').should.be > Version.new('2.0-rc') + expect(Version.new('1.9.0-alpha')).to be < Version.new('1.9-beta') + expect(Version.new('2.0.0-beta')).to be < Version.new('2.0-rc') + expect(Version.new('2.0.0.0.0.0.1-beta')).to be > Version.new('2.0-rc') end it 'tie-breaks between semantically equal versions' do - Version.new('1').should.be < Version.new('1.0') - Version.new('1.0').should.be < Version.new('1.0.0') - Version.new('1.0-alpha').should.be < Version.new('1.0.0-alpha') - Version.new('1.1.1.1-alpha').should.be < Version.new('1.1.1.1.0-alpha') + expect(Version.new('1')).to be < Version.new('1.0') + expect(Version.new('1.0')).to be < Version.new('1.0.0') + expect(Version.new('1.0-alpha')).to be < Version.new('1.0.0-alpha') + expect(Version.new('1.1.1.1-alpha')).to be < Version.new('1.1.1.1.0-alpha') end it 'Follows semver when comparing between pre-release versions' do # Example from section 11 on semver.org - Version.new('1.0.0-alpha').should.be < Version.new('1.0.0-alpha.1') - Version.new('1.0.0-alpha.1').should.be < Version.new('1.0.0-alpha.beta') - Version.new('1.0.0-alpha.beta').should.be < Version.new('1.0.0-beta') - Version.new('1.0.0-beta').should.be < Version.new('1.0.0-beta.2') - Version.new('1.0.0-beta.2').should.be < Version.new('1.0.0-beta.11') - Version.new('1.0.0-beta.11').should.be < Version.new('1.0.0-rc.1') - Version.new('1.0.0-rc.1').should.be < Version.new('1.0.0') + expect(Version.new('1.0.0-alpha')).to be < Version.new('1.0.0-alpha.1') + expect(Version.new('1.0.0-alpha.1')).to be < Version.new('1.0.0-alpha.beta') + expect(Version.new('1.0.0-alpha.beta')).to be < Version.new('1.0.0-beta') + expect(Version.new('1.0.0-beta')).to be < Version.new('1.0.0-beta.2') + expect(Version.new('1.0.0-beta.2')).to be < Version.new('1.0.0-beta.11') + expect(Version.new('1.0.0-beta.11')).to be < Version.new('1.0.0-rc.1') + expect(Version.new('1.0.0-rc.1')).to be < Version.new('1.0.0') - Version.new('1.0.0-beta+fff').should == Version.new('1.0.0-beta+000') + expect(Version.new('1.0.0-beta+fff')).to eq(Version.new('1.0.0-beta+000')) # Example from CocoaPods/CocoaPods#5718 - Version.new('1.0-beta.8').should.be < Version.new('1.0-beta.8a') + expect(Version.new('1.0-beta.8')).to be < Version.new('1.0-beta.8a') # Example from section 11.4.3 on semver.org - Version.new('1.0.0-beta.3rd.1').should.not.be >= Version.new('1.0.0-beta.ios17.1') + expect(Version.new('1.0.0-beta.3rd.1')).not_to be >= Version.new('1.0.0-beta.ios17.1') end end diff --git a/spec/yaml_helper_spec.rb b/spec/yaml_helper_spec.rb index 76a3772de..c416b45c5 100644 --- a/spec/yaml_helper_spec.rb +++ b/spec/yaml_helper_spec.rb @@ -23,20 +23,20 @@ module Pod it 'converts a string' do value = 'Value' result = YAMLHelper.convert(value) - result.should == "Value\n" + expect(result).to eq("Value\n") end it 'converts a long string without adding line breaks' do value = 'a b' * 2000 result = YAMLHelper.convert(value) - result.should == "#{value}\n" + expect(result).to eq("#{value}\n") end it 'coverts a string that looks like a float' do value = '1.2' result = YAMLHelper.convert(value) - result.should == "'1.2'\n" - YAMLHelper.load_string(result).should == value + expect(result).to eq("'1.2'\n") + expect(YAMLHelper.load_string(result)).to eq(value) end it 'converts strings that look like YAML timestamps' do @@ -49,8 +49,8 @@ module Pod '2002-12-14' => "'2002-12-14'", }.each do |given, expected| converted = YAMLHelper.convert(given) - converted[0..-2].should == expected - YAMLHelper.load_string("---\n#{converted}").should == given + expect(converted[0..-2]).to eq(expected) + expect(YAMLHelper.load_string("---\n#{converted}")).to eq(given) end end @@ -82,49 +82,49 @@ module Pod 'monkey (< 1.0.9, ~> 1.0.1)' => 'monkey (< 1.0.9, ~> 1.0.1)', }.each do |given, expected| converted = YAMLHelper.convert(given) - converted[0..-2].should == expected - YAMLHelper.load_string("---\n#{converted}").should == given + expect(converted[0..-2]).to eq(expected) + expect(YAMLHelper.load_string("---\n#{converted}")).to eq(given) end end it 'converts a symbol' do value = :value result = YAMLHelper.convert(value) - result.should == ":value\n" + expect(result).to eq(":value\n") end it 'converts the true class' do result = YAMLHelper.convert(true) - result.should == "true\n" + expect(result).to eq("true\n") end it 'converts the false class' do result = YAMLHelper.convert(false) - result.should == "false\n" + expect(result).to eq("false\n") end it 'converts an array' do value = %w(Value_1 Value_2) result = YAMLHelper.convert(value) - result.should == "- Value_1\n- Value_2\n" + expect(result).to eq("- Value_1\n- Value_2\n") end it 'converts an array that contains an array' do value = [%w(Value_1 Value_2), %w(Value_3 Value_4)] result = YAMLHelper.convert(value) - result.should == "- - Value_1\n - Value_2\n- - Value_3\n - Value_4\n" + expect(result).to eq("- - Value_1\n - Value_2\n- - Value_3\n - Value_4\n") end it 'converts an hash' do value = { 'Key' => 'Value' } result = YAMLHelper.convert(value) - result.should == "Key: Value\n" + expect(result).to eq("Key: Value\n") end it 'converts an hash which contains an array as one of the values' do value = { 'Key' => %w(Value_1 Value_2) } result = YAMLHelper.convert(value) - result.should == <<-EOT.strip_heredoc + expect(result).to eq(<<-EOT.strip_heredoc) Key: - Value_1 - Value_2 @@ -134,7 +134,7 @@ module Pod it 'converts an hash which contains an empty array as one of the values' do value = { 'Key' => [] } result = YAMLHelper.convert(value) - result.should == <<-YAML.strip_heredoc + expect(result).to eq(<<-YAML.strip_heredoc) Key: [] YAML @@ -143,7 +143,7 @@ module Pod it 'converts an array with contains an empty hash' do value = { 'Key' => [{}] } result = YAMLHelper.convert(value) - result.should == <<-YAML.strip_heredoc + expect(result).to eq(<<-YAML.strip_heredoc) Key: - {} YAML @@ -152,7 +152,7 @@ module Pod it 'converts an hash which contains an array as one of the values' do value = { 'Key' => { 'Subkey' => %w(Value_1 Value_2) } } result = YAMLHelper.convert(value) - result.should == <<-EOT.strip_heredoc + expect(result).to eq(<<-EOT.strip_heredoc) Key: Subkey: - Value_1 @@ -170,7 +170,7 @@ module Pod %q('"' lotsa '"""'''" quotes) => %q('"' lotsa '"""'''" quotes), } } result = YAMLHelper.convert(value) - result.should == <<-EOT.strip_heredoc + expect(result).to eq(<<-EOT.strip_heredoc) Key: "\\n\\t \\r\\t\\b\\r\\n ": spaces galore "!abc": abc @@ -179,28 +179,28 @@ module Pod '123': '123' "a # 'comment'?": "a # 'comment'?" EOT - YAMLHelper.load_string(result).should == value + expect(YAMLHelper.load_string(result)).to eq(value) end it 'handles nil' do value = { 'foo' => nil } result = YAMLHelper.convert(value) - result.should == <<-EOT.strip_heredoc + expect(result).to eq(<<-EOT.strip_heredoc) foo: EOT - YAMLHelper.load_string(result).should == value + expect(YAMLHelper.load_string(result)).to eq(value) end it 'raises an Informative error when it encounters a disallowed class' do value = Pathname.new('a-path') result = YAMLHelper.convert(value) - result.should == <<-EOT.strip_heredoc + expect(result).to eq(<<-EOT.strip_heredoc) !ruby/object:Pathname path: a-path EOT - should.raise Informative do + expect do YAMLHelper.load_string(result) - end + end.to raise_error(Informative) end end @@ -208,41 +208,41 @@ module Pod describe 'Loading Strings' do it 'raises an Informative error when it encounters a merge conflict' do - should.raise Informative do + expect do YAMLHelper.load_string(@conflict_podfile_lock.read) - end.message.should.match /unable to continue due to merge conflicts/ + end.to raise_error(Informative, /unable to continue due to merge conflicts/) end it 'raises error when encountering a non-merge conflict error' do - should.raise Exception do + expect do YAMLHelper.load_string(@bad_yaml_podfile_lock.read) - end + end.to raise_error(Exception) end it 'should not raise when there is no merge conflict' do - should.not.raise do + expect do YAMLHelper.load_string(@good_podfile_lock.read) - end + end.not_to raise_error end end describe 'Loading Files' do it 'raises an Informative error when it encounters a merge conflict' do - should.raise Informative do + expect do YAMLHelper.load_file(Pathname.new(@conflict_podfile_lock.path)) - end.message.should.match /unable to continue due to merge conflicts/ + end.to raise_error(Informative, /unable to continue due to merge conflicts/) end it 'raises error when it encounters a non-merge conflict error' do - should.raise Exception do + expect do YAMLHelper.load_file(Pathname.new(@bad_yaml_podfile_lock.path)) - end + end.to raise_error(Exception) end it 'should not raise when there is no merge conflict' do - should.not.raise do + expect do YAMLHelper.load_file(Pathname.new(@good_podfile_lock.path)) - end + end.not_to raise_error end end @@ -253,27 +253,27 @@ module Pod it 'sorts an array according to its string representation' do values = %w(JSONKit BananaLib) result = YAMLHelper.send(:sorted_array, values) - result.should == %w(BananaLib JSONKit) + expect(result).to eq(%w(BananaLib JSONKit)) end it 'sorts an array containing strings and hashes according to its string representation' do values = ['JSONKit', 'BananaLib', { 'c_hash_key' => 'a_value' }] result = YAMLHelper.send(:sorted_array, values) - result.should == ['BananaLib', { 'c_hash_key' => 'a_value' }, 'JSONKit'] + expect(result).to eq(['BananaLib', { 'c_hash_key' => 'a_value' }, 'JSONKit']) end it 'sorts an array with a given hint' do values = %w(non-hinted second first) hint = %w(first second hinted-missing) result = YAMLHelper.send(:sorted_array_with_hint, values, hint) - result.should == %w(first second non-hinted) + expect(result).to eq(%w(first second non-hinted)) end it 'sorts an array with a given nil hint' do values = %w(JSONKit BananaLib) hint = nil result = YAMLHelper.send(:sorted_array_with_hint, values, hint) - result.should == %w(BananaLib JSONKit) + expect(result).to eq(%w(BananaLib JSONKit)) end end @@ -281,25 +281,25 @@ module Pod it 'returns the empty string if a nil value is passed' do value = nil result = YAMLHelper.send(:sorting_string, value) - result.should == '' + expect(result).to eq('') end it 'sorts strings ignoring case' do value = 'String' result = YAMLHelper.send(:sorting_string, value) - result.should == 'string' + expect(result).to eq('string') end it 'sorts symbols ignoring case' do value = :Symbol result = YAMLHelper.send(:sorting_string, value) - result.should == 'symbol' + expect(result).to eq('symbol') end it 'sorts arrays using the first element ignoring case' do value = %w(String_2 String_1) result = YAMLHelper.send(:sorting_string, value) - result.should == 'string_2' + expect(result).to eq('string_2') end it 'sorts a hash using first key in alphabetical order' do @@ -308,7 +308,7 @@ module Pod :key_1 => 'a_value', } result = YAMLHelper.send(:sorting_string, value) - result.should == 'key_1' + expect(result).to eq('key_1') end end end @@ -321,8 +321,8 @@ module Pod value = YAMLHelper.load_string(podfile_str) sorted_keys = ['PODS', 'DEPENDENCIES', 'SPEC CHECKSUMS', 'COCOAPODS'] result = YAMLHelper.convert_hash(value, sorted_keys, "\n\n") - YAMLHelper.load_string(result).should == value - result.should == podfile_str + expect(YAMLHelper.load_string(result)).to eq(value) + expect(result).to eq(podfile_str) end end