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

Rename contains matcher #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

povilasb
Copy link
Contributor

@povilasb povilasb commented Jan 18, 2018

Addresses #45
As discussed this PR

  • adds contains_all_of
  • deprecates contains
  • adds an alias contain_all_of so that does_not(contain_all_of()) reads nice

Then, I guess, in the next future PR I'll make changes to contains/contain matchers to test only if a single element is in the list.

@povilasb
Copy link
Contributor Author

mmm, doc-tests are failing:

---- src/matchers/vecs.rs - matchers::vecs::contains_all_of (line 130) stdout ----
        error: cannot find macro `assert_that!` in this scope
 --> src/matchers/vecs.rs:8:1
  |
8 | assert_that!(&vec![1, 2, 3], does_not(contain_all_of(vec![1, 2, 4])));
  | ^^^^^^^^^^^

error: cannot find macro `assert_that!` in this scope
 --> src/matchers/vecs.rs:7:1
  |
7 | assert_that!(&vec![1, 2, 3, 4], contains_all_of(vec![1, 2, 3]));
  | ^^^^^^^^^^^

error: aborting due to 2 previous errors

not sure how to fix that yet :/

It fails to locate assert_that! macro:

/// Creates a matcher that checks if actual vector has all items of the given vector.
///
/// # Examples
///
/// ```
/// #[macro_use]
/// use hamcrest::prelude::*;
///
/// assert_that!(&vec![1, 2, 3, 4], contains_all_of(vec![1, 2, 3]));
/// assert_that!(&vec![1, 2, 3], does_not(contain_all_of(vec![1, 2, 4])));
/// ```

any ideas?

@povilasb povilasb force-pushed the feature/rename-contains-matcher branch from ca77e01 to 332cab6 Compare January 18, 2018 16:23
@povilasb
Copy link
Contributor Author

Fixed it, but example looks verbose right now:

/// Creates a matcher that checks if actual vector has all items of the given vector.
///
/// # Examples
///
/// ```
/// #[macro_use] extern crate hamcrest;
/// use hamcrest::prelude::*;
///
/// fn main() {
///     assert_that!(&vec![1, 2, 3, 4], contains_all_of(vec![1, 2, 3]));
///     assert_that!(&vec![1, 2, 3], does_not(contain_all_of(vec![1, 2, 4])));
/// }
/// ```

Another alias 'contain_all_of' is also added so that it would better fit does_not(contain_all_of()) expression.
@povilasb povilasb force-pushed the feature/rename-contains-matcher branch from 332cab6 to 75bb683 Compare January 18, 2018 17:24
@povilasb
Copy link
Contributor Author

ping :)

@povilasb
Copy link
Contributor Author

Note that build fails because of travis issues:

error: toolchain 'beta-x86_64-unknown-linux-gnu' does not have the binary `cargo-fmt`

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.

1 participant