Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation to check that a podspec's name doesn't contain whitespace #39

Merged
merged 4 commits into from
Nov 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only verifies that all the mapped messages are the same as where they originated from (the result).

You probably want to do something like:

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


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