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

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

merged 4 commits into from
Nov 28, 2013

Conversation

joshkalpin
Copy link
Member

If we want to go ahead with CocoaPods/CocoaPods#1610 this will add the correct validation for it. The test probably could be a bit cleaner but I was fighting with it to avoid the name mismatch error too.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.24%) when pulling 2f06d53 on Kapin:whitespace-fix into 5212432 on CocoaPods:master.

it "fails a specification whose name contains whitespace" do
@spec.stubs(:name).returns('bad name')
@linter.lint
@linter.results.count.should == 2
Copy link
Member

Choose a reason for hiding this comment

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

Why is it important to verify that there are 2 errors?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I see where the second error comes from, namely the name not matching the file name? I see two alternative solutions:

  • Stub the basename attribute of the file object, e.g. @linter.file.stubs(:basename).returns('ValidName'), which is used here.
  • Modify the message_should_include test helper to find any matching message among the results, making it index independent.

I think I hinge towards the latter.

Copy link
Member Author

Choose a reason for hiding this comment

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

@alloy I definitely agree with the latter.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.24%) when pulling 5d9dbb2 on Kapin:whitespace-fix into 5212432 on CocoaPods:master.


results.each do |result|
results.map(&:message).should.include(result.message)
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

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) when pulling 3a21f32 on Kapin:whitespace-fix into 5212432 on CocoaPods:master.

end

matched.size.should >= 1
Copy link
Member

Choose a reason for hiding this comment

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

Should the matched size not simply match the values size? With the current condition, you can’t know for sure that the values you expected are all there.

Copy link
Member

Choose a reason for hiding this comment

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

I think @alloy's point makes a lot of sense. Do the other tests still pass with this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Two things I saw. When just checking for 1 I had two errors generated (when they should be) and it caused an overlap. Using all? instead resulted in other tests failing. I'm going to look back into the all option because it made more sense and see why those other tests were having issues.

@fabiopelosin
Copy link
Member

👍

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.24%) when pulling 957fedb on Kapin:whitespace-fix into 5212432 on CocoaPods:master.

@fabiopelosin
Copy link
Member

@kapin you commented that using all? would make tests failing, however they passed without any other change. am I missing something? Otherwise can we merge this patch?

Finally once merged could you add an entry to the CocoaPods changelog? Although is a minor change I would prefer to document it.

@joshkalpin
Copy link
Member Author

@irrationalfab I had a complete brainfart and forgot to downcase the message I was comparing. Therefore it was failing when Example was in the string but not example.

joshkalpin pushed a commit that referenced this pull request Nov 28, 2013
Add validation to check that a podspec's name doesn't contain whitespace
@joshkalpin joshkalpin merged commit 187b28b into CocoaPods:master Nov 28, 2013
Ashton-W pushed a commit to Ashton-W/Core that referenced this pull request Nov 2, 2015
Add validation to check that a podspec's name doesn't contain whitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants