diff --git a/spec/dependency_spec.rb b/spec/dependency_spec.rb index 0b34b3c9d..f04542981 100644 --- a/spec/dependency_spec.rb +++ b/spec/dependency_spec.rb @@ -5,18 +5,18 @@ module Pod describe 'In general' do it 'can be initialized with no requirements' do - sut = Dependency.new('bananas') - sut.name.should == 'bananas' + subject = Dependency.new('bananas') + subject.name.should == 'bananas' end it 'can be initialized with multiple requirements' do - sut = Dependency.new('bananas', '> 1.0', '< 2.0') - sut.requirement.to_s.should == '< 2.0, > 1.0' + subject = Dependency.new('bananas', '> 1.0', '< 2.0') + subject.requirement.to_s.should == '< 2.0, > 1.0' end it 'can be initialized with a requirement on a pre-release version' do - sut = Dependency.new('bananas', '> 1.0-pre') - sut.requirement.should == '> 1.0-pre' + subject = Dependency.new('bananas', '> 1.0-pre') + subject.requirement.should == '> 1.0-pre' end it 'can be initialized with an external source' do @@ -104,15 +104,15 @@ module Pod end it 'can store a specific version which is used in place of the requirements' do - sut = Dependency.new('cocoapods', '> 1.0') - sut.specific_version = Version.new('1.23') - sut.requirement.as_list.should == ['= 1.23'] + subject = Dependency.new('cocoapods', '> 1.0') + subject.specific_version = Version.new('1.23') + subject.requirement.as_list.should == ['= 1.23'] end it 'can handle specific version with head information' do - sut = Dependency.new('cocoapods', '> 1.0') - sut.specific_version = Version.new('HEAD based on 1.23') - sut.requirement.as_list.should == ['= 1.23'] + subject = Dependency.new('cocoapods', '> 1.0') + subject.specific_version = Version.new('HEAD based on 1.23') + subject.requirement.as_list.should == ['= 1.23'] end #--------------------------------------# diff --git a/spec/requirement_spec.rb b/spec/requirement_spec.rb index 5f12ec613..8099bf715 100644 --- a/spec/requirement_spec.rb +++ b/spec/requirement_spec.rb @@ -5,23 +5,23 @@ module Pod describe 'In general' do it 'can be initialized with a string' do - sut = Requirement.new('<= 1.0') - sut.to_s.should == '<= 1.0' + subject = Requirement.new('<= 1.0') + subject.to_s.should == '<= 1.0' end it 'defaults to the equality operator on initialization' do - sut = Requirement.new('1.0') - sut.to_s.should == '= 1.0' + subject = Requirement.new('1.0') + subject.to_s.should == '= 1.0' end it 'can be initialized with an array of versions' do - sut = Requirement.new([Version.new('1.0'), Version.new('2.0')]) - sut.to_s.should == '= 1.0, = 2.0' + subject = Requirement.new([Version.new('1.0'), Version.new('2.0')]) + subject.to_s.should == '= 1.0, = 2.0' end it 'can be initialized with a pre-release version' do - sut = Requirement.new(Version.new('1.0-beta')) - sut.to_s.should == '= 1.0-beta' + subject = Requirement.new(Version.new('1.0-beta')) + subject.to_s.should == '= 1.0-beta' end it 'raises if initialized with an invalid input' do @@ -42,28 +42,28 @@ module Pod it 'can be created with a requirement' do req = Requirement.new('<= 1.0') - sut = Requirement.create(req) - sut.should == req + subject = Requirement.create(req) + subject.should == req end it 'can be created with a version' do - sut = Requirement.create(Version.new('1.0')) - sut.to_s.should == '= 1.0' + subject = Requirement.create(Version.new('1.0')) + subject.to_s.should == '= 1.0' end it 'can be created with an array of versions' do - sut = Requirement.create([Version.new('1.0'), Version.new('2.0')]) - sut.to_s.should == '= 1.0, = 2.0' + subject = Requirement.create([Version.new('1.0'), Version.new('2.0')]) + subject.to_s.should == '= 1.0, = 2.0' end it 'can be created with a string' do - sut = Requirement.create('1.0') - sut.to_s.should == '= 1.0' + subject = Requirement.create('1.0') + subject.to_s.should == '= 1.0' end it 'can be created with a nil input' do - sut = Requirement.create(nil) - sut.to_s.should == '>= 0' + subject = Requirement.create(nil) + subject.to_s.should == '>= 0' end end diff --git a/spec/source/abstract_data_provider_spec.rb b/spec/source/abstract_data_provider_spec.rb index 73bc30bc5..22d2b5288 100644 --- a/spec/source/abstract_data_provider_spec.rb +++ b/spec/source/abstract_data_provider_spec.rb @@ -4,7 +4,7 @@ module Pod describe Source::AbstractDataProvider do before do - @sut = Source::AbstractDataProvider.new + @subject = Source::AbstractDataProvider.new end #-------------------------------------------------------------------------# @@ -12,37 +12,37 @@ module Pod describe 'Optional methods' do it 'raises for the #name method' do should.raise StandardError do - @sut.name + @subject.name end.message.should.match /Abstract method/ end it 'raises for the #type method' do should.raise StandardError do - @sut.type + @subject.type end.message.should.match /Abstract method/ end it 'raises for the #pods method' do should.raise StandardError do - @sut.pods + @subject.pods end.message.should.match /Abstract method/ end it 'raises for the #versions method' do should.raise StandardError do - @sut.versions('Pod') + @subject.versions('Pod') end.message.should.match /Abstract method/ end it 'raises for the #specification method' do should.raise StandardError do - @sut.specification('Pod', '0.1.0') + @subject.specification('Pod', '0.1.0') end.message.should.match /Abstract method/ end it 'raises for the #specification_contents method' do should.raise StandardError do - @sut.specification_contents('Pod', '0.1.0') + @subject.specification_contents('Pod', '0.1.0') end.message.should.match /Abstract method/ end end diff --git a/spec/source/acceptor_spec.rb b/spec/source/acceptor_spec.rb index ad42c15e8..8ef9cb7e1 100644 --- a/spec/source/acceptor_spec.rb +++ b/spec/source/acceptor_spec.rb @@ -14,7 +14,7 @@ module Pod @spec = Specification.from_file(@spec_path) Specification.any_instance.stubs(:dependencies).returns([]) @repo = fixture('spec-repos/test_repo') - @sut = Source::Acceptor.new(@repo) + @subject = Source::Acceptor.new(@repo) end #-------------------------------------------------------------------------# @@ -22,22 +22,22 @@ module Pod describe 'In general' do it 'returns the source that should accept the podspecs' do - @sut.source.name.should == 'test_repo' + @subject.source.name.should == 'test_repo' end it 'accepts a valid specification' do - errors = @sut.analyze(@spec) + errors = @subject.analyze(@spec) errors.should == [] end it 'accepts a given path with a valid specification' do - errors = @sut.analyze_path(@spec_path) + errors = @subject.analyze_path(@spec_path) errors.should == [] end it 'handles gracefully malformed specifications' do File.any_instance.stubs(:read).returns('raise') - errors = @sut.analyze_path(@spec_path) + errors = @subject.analyze_path(@spec_path) errors.should == ['Unable to load the specification.'] end end @@ -48,25 +48,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 = @sut.analyze(@spec).join("\n") + errors = @subject.analyze(@spec).join("\n") errors.should.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 = @sut.analyze(@spec).join("\n") + errors = @subject.analyze(@spec).join("\n") errors.should.not.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 = @sut.analyze(@spec).join("\n") + errors = @subject.analyze(@spec).join("\n") errors.should.not.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 = @sut.analyze(@spec).join("\n") + errors = @subject.analyze(@spec).join("\n") errors.should.match /There is already at least one versioned specification/ end @@ -77,14 +77,14 @@ module Pod previous_spec.source = { :git => repo, :commit => 'SHA_1' } @spec.version = '0.0.1' @spec.source = { :git => repo, :commit => 'SHA_2' } - @sut.stubs(:related_specifications).returns(nil) - errors = @sut.analyze(@spec, previous_spec).join("\n") + @subject.stubs(:related_specifications).returns(nil) + errors = @subject.analyze(@spec, previous_spec).join("\n") errors.should.match /Attempt to rewrite the commit/ end it 'checks that the dependencies of the specification are available' do Specification.any_instance.unstub(:dependencies) - errors = @sut.analyze(@spec).join("\n") + errors = @subject.analyze(@spec).join("\n") errors.should.match /Unable to find a specification for the.*monkey.*dependency/ end diff --git a/spec/source/aggregate_spec.rb b/spec/source/aggregate_spec.rb index 2718e9af5..ac0f43651 100644 --- a/spec/source/aggregate_spec.rb +++ b/spec/source/aggregate_spec.rb @@ -7,7 +7,7 @@ module Pod # JSONKit is in test repo has version 1.4 (duplicated) and the 999.999.999. # before do - @sut = Source::Aggregate.new(fixture('spec-repos')) + @subject = Source::Aggregate.new(fixture('spec-repos')) end #-------------------------------------------------------------------------# @@ -15,17 +15,17 @@ module Pod describe 'In general' do it 'returns all the sources' do - @sut.all.map(&:name).should == %w(master test_repo) + @subject.all.map(&:name).should == %w(master test_repo) end it 'returns the name of all the available pods' do - root_spec_names = @sut.all_pods + root_spec_names = @subject.all_pods root_spec_names.should.include('JSONKit') root_spec_names.should.include('BananaLib') end it 'returns all the available sets with the sources configured' do - sets = @sut.all_sets + sets = @subject.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) @@ -37,26 +37,26 @@ module Pod it 'searches the sets by dependency' do dep = Dependency.new('JSONKit') - set = @sut.search(dep) + set = @subject.search(dep) set.name.should == 'JSONKit' set.sources.map(&:name).should == %w(master test_repo) end it 'searches the sets specifying a dependency on a subspec' do dep = Dependency.new('RestKit/Network') - set = @sut.search(dep) + set = @subject.search(dep) set.name.should == 'RestKit' set.sources.map(&:name).should == %w(master) end it "returns nil if a specification can't be found" do dep = Dependency.new('Does-not-exist') - set = @sut.search(dep) + set = @subject.search(dep) set.should.nil? end it 'returns the directories where the repos are defined' do - @sut.dirs.map { |d| d.basename.to_s }.sort.should == %w(master test_repo) + @subject.dirs.map { |d| d.basename.to_s }.sort.should == %w(master test_repo) end it "returns an empty list for the directories if the repos dir doesn't exists" do @@ -65,7 +65,7 @@ module Pod end it 'returns a set configured to use only the source which contains the highest version' do - set = @sut.representative_set('JSONKit') + set = @subject.representative_set('JSONKit') set.versions.map(&:to_s).should == ['999.999.999', '1.4'] end @@ -76,7 +76,7 @@ module Pod describe 'Search' do it 'searches the sets by name' do - sets = @sut.search_by_name('JSONKit') + sets = @subject.search_by_name('JSONKit') sets.count.should == 1 set = sets.first set.name.should == 'JSONKit' @@ -84,7 +84,7 @@ module Pod end it 'properly configures the sources of a set in search by name' do - sets = @sut.search_by_name('BananaLib') + sets = @subject.search_by_name('BananaLib') sets.count.should == 1 set = sets.first set.name.should == 'BananaLib' @@ -92,16 +92,16 @@ module Pod end it 'performs a full text search' do - @sut.stubs(:dirs).returns([fixture('spec-repos/test_repo')]) - sets = @sut.search_by_name('Banana Corp', true) + @subject.stubs(:dirs).returns([fixture('spec-repos/test_repo')]) + sets = @subject.search_by_name('Banana Corp', true) sets.count.should == 1 sets.first.name.should == 'BananaLib' end it 'raises an informative if unable to find a Pod with the given name' do - @sut.stubs(:dirs).returns([fixture('spec-repos/test_repo')]) + @subject.stubs(:dirs).returns([fixture('spec-repos/test_repo')]) should.raise Informative do - @sut.search_by_name('Some-funky-name', true) + @subject.search_by_name('Some-funky-name', true) end.message.should.match /Unable to find/ end @@ -113,11 +113,11 @@ module Pod before do test_source = Source.new(fixture('spec-repos/test_repo')) - @sut.stubs(:all).returns([test_source]) + @subject.stubs(:all).returns([test_source]) end it 'generates the search index from scratch' do - index = @sut.generate_search_index + index = @subject.generate_search_index index.keys.sort.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) index['BananaLib']['version'].should == '1.0' index['BananaLib']['summary'].should == 'Chunky bananas!' @@ -127,39 +127,39 @@ module Pod it 'updates a given index' do old_index = { 'Faulty_spec' => {}, 'JSONKit' => {}, 'JSONSpec' => {} } - index = @sut.update_search_index(old_index) + index = @subject.update_search_index(old_index) index.keys.sort.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) index['BananaLib']['version'].should == '1.0' end it 'updates a set in the index if a lower version was stored' do old_index = { 'BananaLib' => { 'version' => '0.8' } } - index = @sut.update_search_index(old_index) + index = @subject.update_search_index(old_index) index['BananaLib']['version'].should == '1.0' end it 'updates a set in the search index if no information was stored' do old_index = { 'BananaLib' => {} } - index = @sut.update_search_index(old_index) + index = @subject.update_search_index(old_index) index['BananaLib']['version'].should == '1.0' end it "doesn't updates a set in the index if there already information for an equal or higher version" do old_index = { 'BananaLib' => { 'version' => '1.0', 'summary' => 'custom' } } - index = @sut.update_search_index(old_index) + index = @subject.update_search_index(old_index) index['BananaLib']['summary'].should == 'custom' end it 'loads only the specifications which need to be updated' do Specification.expects(:from_file).at_least_once - index = @sut.generate_search_index + index = @subject.generate_search_index Specification.expects(:from_file).never - search_data = @sut.update_search_index(index) + search_data = @subject.update_search_index(index) end it 'deletes from the index the data of the sets which are not present in the aggregate' do old_index = { 'Deleted-Pod' => { 'version' => '1.0', 'summary' => 'custom' } } - index = @sut.update_search_index(old_index) + index = @subject.update_search_index(old_index) index['Deleted-Pod'].should.be.nil end diff --git a/spec/source/file_system_data_provider_spec.rb b/spec/source/file_system_data_provider_spec.rb index 2f805018d..0ffac9679 100644 --- a/spec/source/file_system_data_provider_spec.rb +++ b/spec/source/file_system_data_provider_spec.rb @@ -5,14 +5,14 @@ module Pod before do path = fixture('spec-repos/test_repo') - @sut = Source::FileSystemDataProvider.new(path) + @subject = Source::FileSystemDataProvider.new(path) end #-------------------------------------------------------------------------# describe 'In general' do it 'returns its name' do - @sut.name.should == 'test_repo' + @subject.name.should == 'test_repo' end end @@ -20,33 +20,33 @@ module Pod describe '#pods' do it 'returns the available Pods' do - @sut.pods.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) + @subject.pods.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) end it 'returns nil if no Pods could be found' do path = fixture('spec-repos/non_existing') - @sut = Source::FileSystemDataProvider.new(path) - @sut.pods.should.be.nil + @subject = Source::FileSystemDataProvider.new(path) + @subject.pods.should.be.nil end it "doesn't include the `.` and the `..` dir entries" do - @sut.pods.should.not.include?('.') - @sut.pods.should.not.include?('..') + @subject.pods.should.not.include?('.') + @subject.pods.should.not.include?('..') end it 'only consider directories' do File.stubs(:directory?).returns(false) - @sut.pods.should == [] + @subject.pods.should == [] end it 'uses the `Specs` dir if it is present' do - @sut.send(:specs_dir).to_s.should.end_with('test_repo/Specs') + @subject.send(:specs_dir).to_s.should.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/master') - @sut = Source::FileSystemDataProvider.new(repo) - @sut.send(:specs_dir).to_s.should.end_with('master') + @subject = Source::FileSystemDataProvider.new(repo) + @subject.send(:specs_dir).to_s.should.end_with('master') end end @@ -54,16 +54,16 @@ module Pod describe '#versions' do it 'returns the versions for the given Pod' do - @sut.versions('JSONKit').should == ['999.999.999', '1.4'] + @subject.versions('JSONKit').should == ['999.999.999', '1.4'] end it 'returns nil the Pod is unknown' do - @sut.versions('Unknown_Pod').should.be.nil + @subject.versions('Unknown_Pod').should.be.nil end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.versions(nil) + @subject.versions(nil) end.message.should.match /No name/ end end @@ -72,30 +72,30 @@ module Pod describe '#specification' do it 'returns the specification for the given version of a Pod' do - spec = @sut.specification('JSONKit', '1.4') + spec = @subject.specification('JSONKit', '1.4') spec.name.should == 'JSONKit' spec.version.to_s.should == '1.4' end it 'returns nil if the Pod is unknown' do - spec = @sut.specification('Unknown_Pod', '1.4') + spec = @subject.specification('Unknown_Pod', '1.4') spec.should.be.nil end it "returns nil if the version of the Pod doesn't exists" do - spec = @sut.specification('JSONKit', '0.99.0') + spec = @subject.specification('JSONKit', '0.99.0') spec.should.be.nil end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification(nil, '1.4') + @subject.specification(nil, '1.4') end.message.should.match /No name/ end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification('JSONKit', nil) + @subject.specification('JSONKit', nil) end.message.should.match /No version/ end end @@ -104,25 +104,25 @@ module Pod describe '#specification_path' do it 'returns the path of a specification' do - path = @sut.specification_path('JSONKit', '1.4') + path = @subject.specification_path('JSONKit', '1.4') path.to_s.should.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 = @sut.specification_path('JSONSpec', '0.9') + path = @subject.specification_path('JSONSpec', '0.9') path.to_s.should.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 - @sut.specification_path(nil, '1.4') + @subject.specification_path(nil, '1.4') end.message.should.match /No name/ end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification_path('JSONKit', nil) + @subject.specification_path('JSONKit', nil) end.message.should.match /No version/ end end @@ -131,29 +131,29 @@ module Pod describe '#specification_contents' do it 'returns the specification given the name and the version' do - spec = @sut.specification_contents('JSONKit', '1.4') + spec = @subject.specification_contents('JSONKit', '1.4') spec.should.match /s.name += 'JSONKit'\n +s.version += '1.4'/ end it 'returns nil if the Pod is unknown' do - spec = @sut.specification_contents('Unknown_Pod', '1.4') + spec = @subject.specification_contents('Unknown_Pod', '1.4') spec.should.be.nil end it "returns nil if the version of the Pod doesn't exists" do - spec = @sut.specification_contents('JSONKit', '0.99.0') + spec = @subject.specification_contents('JSONKit', '0.99.0') spec.should.be.nil end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification_contents(nil, '1.4') + @subject.specification_contents(nil, '1.4') end.message.should.match /No name/ end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification_contents('JSONKit', nil) + @subject.specification_contents('JSONKit', nil) end.message.should.match /No version/ end end diff --git a/spec/source/github_data_provider_spec.rb b/spec/source/github_data_provider_spec.rb index 38ff7d759..2d6de1ce5 100644 --- a/spec/source/github_data_provider_spec.rb +++ b/spec/source/github_data_provider_spec.rb @@ -4,18 +4,18 @@ module Pod describe Source::GitHubDataProvider do before do - @sut = Source::GitHubDataProvider.new('CocoaPods/Specs', 'json_podspecs') + @subject = Source::GitHubDataProvider.new('CocoaPods/Specs', 'json_podspecs') end #-------------------------------------------------------------------------# describe 'In general' do it 'returns the name of the source' do - @sut.name.should == 'CocoaPods/Specs' + @subject.name.should == 'CocoaPods/Specs' end it 'returns the type of the source' do - @sut.type.should == 'GitHub API' + @subject.type.should == 'GitHub API' end end @@ -24,20 +24,20 @@ module Pod describe '#pods' do it 'returns the list of all the Pods' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - @sut.pods.should.include?('ARAnalytics') + @subject.pods.should.include?('ARAnalytics') end end it 'only considers directories to compute the name of Pods' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - @sut.pods.should.not.include?('Readme.md') + @subject.pods.should.not.include?('Readme.md') end end it 'returns nil if no Pods could be found' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - @sut = Source::GitHubDataProvider.new('CocoaPods/Missing_Specs') - @sut.pods.should.be.nil + @subject = Source::GitHubDataProvider.new('CocoaPods/Missing_Specs') + @subject.pods.should.be.nil end end end @@ -47,19 +47,19 @@ module Pod describe '#versions' do it 'returns the available versions of a Pod' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - @sut.versions('A3GridTableView').should == ['0.0.1'] + @subject.versions('A3GridTableView').should == ['0.0.1'] end end it 'returns nil the Pod is unknown' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - @sut.versions('Unknown_Pod').should.be.nil + @subject.versions('Unknown_Pod').should.be.nil end end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.versions(nil) + @subject.versions(nil) end.message.should.match /No name/ end end @@ -69,7 +69,7 @@ module Pod describe '#specification' do it 'returns the specification given the name and the version' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - spec = @sut.specification('ARAnalytics', '1.3.1') + spec = @subject.specification('ARAnalytics', '1.3.1') spec.name.should == 'ARAnalytics' spec.version.to_s.should == '1.3.1' end @@ -77,27 +77,27 @@ module Pod it 'returns nil if the Pod is unknown' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - spec = @sut.specification('Unknown_Pod', '1.3.1') + spec = @subject.specification('Unknown_Pod', '1.3.1') spec.should.be.nil end end it "returns nil if the version of the Pod doesn't exists" do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - spec = @sut.specification('ARAnalytics', '0.99.0') + spec = @subject.specification('ARAnalytics', '0.99.0') spec.should.be.nil end end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification(nil, '0.99.0') + @subject.specification(nil, '0.99.0') end.message.should.match /No name/ end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification('ARAnalytics', nil) + @subject.specification('ARAnalytics', nil) end.message.should.match /No version/ end end @@ -107,34 +107,34 @@ module Pod describe '#specification_contents' do it 'returns the specification given the name and the version' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - spec = @sut.specification_contents('ARAnalytics', '1.3.1') + spec = @subject.specification_contents('ARAnalytics', '1.3.1') spec.should.include("{\n \"name\": \"ARAnalytics\",\n \"version\": \"1.3.1\"") end end it 'returns nil if the Pod is unknown' do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - spec = @sut.specification_contents('Unknown_Pod', '1.3.1') + spec = @subject.specification_contents('Unknown_Pod', '1.3.1') spec.should.be.nil end end it "returns nil if the version of the Pod doesn't exists" do VCR.use_cassette('GitHubDataProvider', :record => :new_episodes) do - spec = @sut.specification_contents('ARAnalytics', '0.99.0') + spec = @subject.specification_contents('ARAnalytics', '0.99.0') spec.should.be.nil end end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification_contents(nil, '0.99.0') + @subject.specification_contents(nil, '0.99.0') end.message.should.match /No name/ end it 'raises if the name of the Pod is not provided' do should.raise ArgumentError do - @sut.specification_contents('ARAnalytics', nil) + @subject.specification_contents('ARAnalytics', nil) end.message.should.match /No version/ end end diff --git a/spec/source/health_reporter_spec.rb b/spec/source/health_reporter_spec.rb index ab5bcfe04..843f2fe62 100644 --- a/spec/source/health_reporter_spec.rb +++ b/spec/source/health_reporter_spec.rb @@ -7,7 +7,7 @@ module Pod WebMock::API.stub_request(:head , /banana-corp.local/).to_return(:status => 200) WebMock::API.stub_request(:head , /github.com/).to_return(:status => 200) @repo = fixture('spec-repos/test_repo') - @sut = Source::HealthReporter.new(@repo) + @subject = Source::HealthReporter.new(@repo) end #-------------------------------------------------------------------------# @@ -16,39 +16,39 @@ module Pod it 'can store an option callback which is called before analyzing each specification' do names = [] - @sut.pre_check do |name, version| + @subject.pre_check do |name, version| names << name end - @sut.analyze + @subject.analyze names.should.include?('BananaLib') end it 'analyzes all the specifications of a repo' do - @sut.analyze - @sut.report.analyzed_paths.count.should == 9 + @subject.analyze + @subject.report.analyzed_paths.count.should == 9 end it 'is robust against malformed specifications' do - @sut.analyze - errors = @sut.report.pods_by_error.keys.join(' - ') + @subject.analyze + errors = @subject.report.pods_by_error.keys.join(' - ') errors.should.match /Faulty_spec.podspec.*could not be loaded/ end it 'lints the specifications' do - @sut.analyze - errors = @sut.report.pods_by_error.keys.join(' - ') + @subject.analyze + errors = @subject.report.pods_by_error.keys.join(' - ') errors.should.match /Missing required attribute/ end it 'checks the path of the specifications' do - @sut.analyze - errors = @sut.report.pods_by_error.keys.join("\n") + @subject.analyze + errors = @subject.report.pods_by_error.keys.join("\n") errors.should.match /Incorrect path/ end it 'checks for any stray specifications' do - @sut.analyze - errors = @sut.report.pods_by_error.keys.join("\n") + @subject.analyze + errors = @subject.report.pods_by_error.keys.join("\n") errors.should.match /Stray spec/ end end diff --git a/spec/source_spec.rb b/spec/source_spec.rb index 5b88fbcdd..2f7c93494 100644 --- a/spec/source_spec.rb +++ b/spec/source_spec.rb @@ -6,18 +6,18 @@ module Pod before do @path = fixture('spec-repos/test_repo') provider = Source::FileSystemDataProvider.new(@path) - @sut = Source.new(provider) + @subject = Source.new(provider) end #-------------------------------------------------------------------------# describe 'In general' do it 'return its name' do - @sut.name.should == 'test_repo' + @subject.name.should == 'test_repo' end it 'return its type' do - @sut.type.should == 'file system' + @subject.type.should == 'file system' end it 'can be ordered according to its name' do @@ -32,15 +32,15 @@ module Pod describe '#pods' do it 'returns the available Pods' do - @sut.pods.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) + @subject.pods.should == %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) end it "raises if the repo doesn't exists" do @path = fixture('spec-repos/non_existing') provider = Source::FileSystemDataProvider.new(@path) - @sut = Source.new(provider) + @subject = Source.new(provider) e = should.raise Informative do - @sut.pods + @subject.pods end e.message.should == 'Unable to find the file system source named: `non_existing`' end @@ -50,11 +50,11 @@ module Pod describe '#versions' do it 'returns the available versions of a Pod' do - @sut.versions('JSONKit').map(&:to_s).should == ['999.999.999', '1.4'] + @subject.versions('JSONKit').map(&:to_s).should == ['999.999.999', '1.4'] end it 'returns nil if the Pod could not be found' do - @sut.versions('Unknown_Pod').should.be.nil + @subject.versions('Unknown_Pod').should.be.nil end end @@ -62,7 +62,7 @@ module Pod describe '#specification' do it 'returns the specification for the given name and version' do - spec = @sut.specification('JSONKit', Version.new('1.4')) + spec = @subject.specification('JSONKit', Version.new('1.4')) spec.name.should == 'JSONKit' spec.version.should.to_s == '1.4' end @@ -73,7 +73,7 @@ module Pod describe '#all_specs' do it 'returns all the specifications' do expected = %w(BananaLib IncorrectPath JSONKit JSONSpec) - @sut.all_specs.map(&:name).sort.uniq.should == expected + @subject.all_specs.map(&:name).sort.uniq.should == expected end end @@ -81,9 +81,9 @@ module Pod describe '#set' do it 'returns the set of a given Pod' do - set = @sut.set('BananaLib') + set = @subject.set('BananaLib') set.name.should == 'BananaLib' - set.sources.should == [@sut] + set.sources.should == [@subject] end end @@ -92,7 +92,7 @@ module Pod describe '#pod_sets' do it 'returns all the pod sets' do expected = %w(BananaLib Faulty_spec IncorrectPath JSONKit JSONSpec) - @sut.pod_sets.map(&:name).sort.uniq.should == expected + @subject.pod_sets.map(&:name).sort.uniq.should == expected end end @@ -100,17 +100,17 @@ module Pod describe '#search' do it 'searches for the Pod with the given name' do - @sut.search('BananaLib').name.should == 'BananaLib' + @subject.search('BananaLib').name.should == 'BananaLib' end it 'searches for the pod with the given dependency' do dep = Dependency.new('BananaLib') - @sut.search(dep).name.should == 'BananaLib' + @subject.search(dep).name.should == 'BananaLib' end it 'supports dependencies on subspecs' do dep = Dependency.new('BananaLib/subspec') - @sut.search(dep).name.should == 'BananaLib' + @subject.search(dep).name.should == 'BananaLib' end describe '#search_by_name' do @@ -135,28 +135,28 @@ module Pod describe '#search_by_name' do it 'supports full text search' do - sets = @sut.search_by_name('monkey', true) + sets = @subject.search_by_name('monkey', true) sets.map(&:name).should == ['BananaLib'] - sets.map(&:sources).should == [[@sut]] + sets.map(&:sources).should == [[@subject]] end it 'The search is case insensitive' do - pods = @sut.search_by_name('MONKEY', true) + pods = @subject.search_by_name('MONKEY', true) pods.map(&:name).should == ['BananaLib'] end it 'supports partial matches' do - pods = @sut.search_by_name('MON', true) + pods = @subject.search_by_name('MON', true) pods.map(&:name).should == ['BananaLib'] end it "handles gracefully specification which can't be loaded" do should.raise Informative do - @sut.specification('Faulty_spec', '1.0.0') + @subject.specification('Faulty_spec', '1.0.0') end.message.should.include 'Invalid podspec' should.not.raise do - @sut.search_by_name('monkey', true) + @subject.search_by_name('monkey', true) end end end @@ -165,23 +165,23 @@ module Pod describe '#fuzzy_search' do it 'is case insensitive' do - @sut.fuzzy_search('bananalib').name.should == 'BananaLib' + @subject.fuzzy_search('bananalib').name.should == 'BananaLib' end it 'matches misspells' do - @sut.fuzzy_search('banalib').name.should == 'BananaLib' + @subject.fuzzy_search('banalib').name.should == 'BananaLib' end it 'matches suffixes' do - @sut.fuzzy_search('Lib').name.should == 'BananaLib' + @subject.fuzzy_search('Lib').name.should == 'BananaLib' end it 'returns nil if there is no match' do - @sut.fuzzy_search('12345').should.be.nil + @subject.fuzzy_search('12345').should.be.nil end it 'matches abbreviations' do - @sut.fuzzy_search('BLib').name.should == 'BananaLib' + @subject.fuzzy_search('BLib').name.should == 'BananaLib' end end @@ -189,11 +189,11 @@ module Pod describe 'Representations' do it 'returns the hash representation' do - @sut.to_hash['BananaLib']['1.0']['name'].should == 'BananaLib' + @subject.to_hash['BananaLib']['1.0']['name'].should == 'BananaLib' end it 'returns the yaml representation' do - yaml = @sut.to_yaml + yaml = @subject.to_yaml yaml.should.match /---/ yaml.should.match /BananaLib:/ end diff --git a/spec/specification/json_spec.rb b/spec/specification/json_spec.rb index 61de54f24..c09852fd6 100644 --- a/spec/specification/json_spec.rb +++ b/spec/specification/json_spec.rb @@ -6,13 +6,13 @@ module Pod describe 'JSON support' do it 'returns the json representation' do - sut = Specification.new(nil, 'BananaLib') - sut.version = '1.0' + subject = Specification.new(nil, 'BananaLib') + subject.version = '1.0' expected = { 'name' => 'BananaLib', 'version' => '1.0' } - JSON.parse(sut.to_json).should == expected + JSON.parse(subject.to_json).should == expected end it 'allows to specify multi-platform attributes' do @@ -35,17 +35,17 @@ module Pod describe 'Hash conversion' do before do path = fixture('BananaLib.podspec') - @sut = Spec.from_file(path) + @subject = Spec.from_file(path) end it 'can be converted to a hash' do - hash = @sut.to_hash + hash = @subject.to_hash hash['name'].should == 'BananaLib' hash['version'].should == '1.0' end it 'handles subspecs when converted to a hash' do - hash = @sut.to_hash + hash = @subject.to_hash hash['subspecs'].should == [{ 'name' => 'GreenBanana', 'source_files' => 'GreenBanana' @@ -63,17 +63,17 @@ module Pod end it 'can be safely converted back and forth to a hash' do - result = Specification.from_hash(@sut.to_hash) - result.should == @sut + result = Specification.from_hash(@subject.to_hash) + result.should == @subject end it 'returns whether it safe to convert a specification to hash' do - @sut.safe_to_hash?.should.be.true + @subject.safe_to_hash?.should.be.true end it 'returns that it is not safe to convert a specification to a hash if there is hook defined' do - @sut.pre_install { ; } - @sut.safe_to_hash?.should.be.false + @subject.pre_install { ; } + @subject.safe_to_hash?.should.be.false end end