-
Notifications
You must be signed in to change notification settings - Fork 351
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
Conversation
it "fails a specification whose name contains whitespace" do | ||
@spec.stubs(:name).returns('bad name') | ||
@linter.lint | ||
@linter.results.count.should == 2 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 thefile
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.
There was a problem hiding this comment.
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.
|
||
results.each do |result| | ||
results.map(&:message).should.include(result.message) | ||
end |
There was a problem hiding this comment.
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
end | ||
|
||
matched.size.should >= 1 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
👍 |
@kapin you commented that using Finally once merged could you add an entry to the CocoaPods changelog? Although is a minor change I would prefer to document it. |
@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. |
Add validation to check that a podspec's name doesn't contain whitespace
Add validation to check that a podspec's name doesn't contain whitespace
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.