Skip to content

Commit

Permalink
Merge pull request #39 from Kapin/whitespace-fix
Browse files Browse the repository at this point in the history
Add validation to check that a podspec's name doesn't contain whitespace
  • Loading branch information
kapin committed Nov 28, 2013
2 parents a5f0afd + 957fedb commit 187b28b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions lib/cocoapods-core/specification/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ def _validate_name(n)
unless names_match
error "The name of the spec should match the name of the file."
end

if spec.root.name =~ /\s/
error "The name of a spec should not contain whitespace."
end
end
end

Expand Down
22 changes: 15 additions & 7 deletions spec/specification/linter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module Pod

before do
fixture_path = 'spec-repos/test_repo/Specs/BananaLib/1.0/BananaLib.podspec'
podspec_path = fixture(fixture_path)
@podspec_path = fixture(fixture_path)
@linter = Specification::Linter.new(@podspec_path)
end

Expand Down Expand Up @@ -95,13 +95,16 @@ module Pod

def message_should_include(*values)
@linter.lint
result = @linter.results.first
result.should.not.be.nil
@linter.results.map(&:message).should == [result.message]
message = result.message.downcase
values.each do |value|
message.should.include(value.downcase)
results = @linter.results
results.should.not.be.nil

matched = results.select do |result|
values.all? do |value|
result.message.downcase.include?(value.downcase)
end
end

matched.size.should == 1
end

#------------------#
Expand Down Expand Up @@ -135,6 +138,11 @@ def message_should_include(*values)
message_should_include('name', 'match')
end

it "fails a specification whose name contains whitespace" do
@spec.stubs(:name).returns('bad name')
message_should_include('name', 'whitespace')
end

#------------------#

it "checks that the version has been specified" do
Expand Down

0 comments on commit 187b28b

Please sign in to comment.