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

Converting from Predicate<str> into Predicate<[u8]> #32

Closed
mssun opened this issue Jul 27, 2018 · 2 comments
Closed

Converting from Predicate<str> into Predicate<[u8]> #32

mssun opened this issue Jul 27, 2018 · 2 comments
Labels
enhancement Improve the expected
Milestone

Comments

@mssun
Copy link
Contributor

mssun commented Jul 27, 2018

As discussed in this PR mesalock-linux/mesabox#24. We should use predicate::str::contains(str).from_utf8() to convert Predicate<str> to Predicate<[u8]> for stdout() and stderr() comparison.

It's difficult to find answer in the documentation. There are several reasons:

  1. assert_cmd and predicate's documentation are separated, you should look it back and forth.
  2. The from_utf8() is in the PredicateStrExt trait, and it's difficult to find.

For example, my intuition is that stdout() accept a str like this: stdout("Hello, World!"). But what if I want to check if it contains this str? Then I found that stdout() accept a IntoOutputPredicate<P> actually. Then I switch to read the doc of IntoOutputPredicate and understand str implement this trait. But still, how to check contains? I read the doc of predicate and find out str::contains. The doc doesn't tell me how to use it in assert_cmd, then I'm confused. contains() gives me a ContainsPredicate. However, ContainsPredicate only implements Predicate<str>. At this point, I begin to be impatient and spent a lot of time reading the doc. Finally I find the PredicateStrExt.

This is my first experience of using assert_cmd and predicate. I don't know how to improve the APIs. I think it worth to improve the docs, like giving more examples combining assert_cmd and predicate.

@mssun
Copy link
Contributor Author

mssun commented Jul 27, 2018

Oh, sorry, do I have to put this issue under the predicate project?

@epage
Copy link
Contributor

epage commented Jul 27, 2018

This is the right place since any improvement will need to be made here.

  • convert more predicate types
  • find ways to make the role of predicates clearer
  • try to find some way to make relevant predicates more visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

3 participants