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

InputHasContent.java:43-47: All the matchers should... #20

Closed
0pdd opened this issue Jun 1, 2018 · 30 comments
Closed

InputHasContent.java:43-47: All the matchers should... #20

0pdd opened this issue Jun 1, 2018 · 30 comments
Labels
bug Something isn't working scope
Milestone

Comments

@0pdd
Copy link
Collaborator

0pdd commented Jun 1, 2018

The puzzle 7-0cc4122b from #7 has to be resolved:

* @todo #7:30min All the matchers should implement describeMismatchSafely and
* their tests must verify that the implementation of the descriptions
* are satisfactory. The matchers should not expose publicly the xxxSafely
* method and the tests should rely on actual real use with assertThat.
* See ScalarHasValueTest for an example of a satisfactory result.

The puzzle was created by Victor Noël on 19-May-18.

Estimate: 30 minutes,

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

@0pdd
Copy link
Collaborator Author

0pdd commented Jun 1, 2018

I can't create GitHub labels pdd. Most likely I don't have necessary permissions to llorllale/cactoos-matchers repository. Please, make sure @0pdd user is in the list of collaborators:

POST https://api.github.com/repos/llorllale/cactoos-matchers/labels: 404 - Not Found // See: https://developer.github.com/v3/issues/labels/#create-a-label
/app/vendor/bundle/ruby/2.3.0/gems/octokit-4.9.0/lib/octokit/response/raise_error.rb:16:in `on_complete'
/app/vendor/bundle/ruby/2.3.0/gems/faraday-0.15.2/lib/faraday/response.rb:9:in `block in call'
/app/vendor/bundle/ruby/2.3.0/gems/faraday-0.15.2/lib/faraday/response.rb:61:in `on_complete'
/app/vendor/bundle/ruby/2.3.0/gems/faraday-0.15.2/lib/faraday/response.rb:8:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/octokit-4.9.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
/app/vendor/bundle/ruby/2.3.0/gems/octokit-4.9.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/faraday-0.15.2/lib/faraday/rack_builder.rb:143:in `build_response'
/app/vendor/bundle/ruby/2.3.0/gems/faraday-0.15.2/lib/faraday/connection.rb:387:in `run_request'
/app/vendor/bundle/ruby/2.3.0/gems/faraday-0.15.2/lib/faraday/connection.rb:175:in `post'
/app/vendor/bundle/ruby/2.3.0/gems/sawyer-0.8.1/lib/sawyer/agent.rb:94:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/octokit-4.9.0/lib/octokit/connection.rb:156:in `request'
/app/vendor/bundle/ruby/2.3.0/gems/octokit-4.9.0/lib/octokit/connection.rb:28:in `post'
/app/vendor/bundle/ruby/2.3.0/gems/octokit-4.9.0/lib/octokit/client/labels.rb:44:in `add_label'
/app/objects/github_tagged_tickets.rb:50:in `block in submit'
/app/objects/github_tagged_tickets.rb:50:in `each'
/app/objects/github_tagged_tickets.rb:50:in `submit'
/app/objects/commit_tickets.rb:38:in `submit'
/app/objects/emailed_tickets.rb:35:in `submit'
/app/objects/sentry_tickets.rb:46:in `submit'
/app/objects/puzzles.rb:91:in `block in expose'
/app/objects/puzzles.rb:82:in `loop'
/app/objects/puzzles.rb:82:in `expose'
/app/objects/puzzles.rb:33:in `deploy'
/app/objects/job.rb:38:in `proceed'
/app/objects/job_starred.rb:33:in `proceed'
/app/objects/job_recorded.rb:32:in `proceed'
/app/objects/job_emailed.rb:35:in `proceed'
/app/objects/job_commiterrors.rb:36:in `proceed'
/app/objects/job_detached.rb:48:in `exclusive'
/app/objects/job_detached.rb:36:in `block in proceed'
/app/objects/job_detached.rb:36:in `fork'
/app/objects/job_detached.rb:36:in `proceed'
/app/0pdd.rb:342:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1634:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1634:in `block in compile!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:992:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1011:in `route_eval'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:992:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1039:in `block in process_route'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1037:in `catch'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1037:in `process_route'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:990:in `block in route!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:989:in `each'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:989:in `route!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1096:in `block in dispatch!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `block in invoke'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `catch'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `invoke'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1093:in `dispatch!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:924:in `block in call!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `block in invoke'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `catch'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `invoke'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:924:in `call!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:913:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/xss_header.rb:18:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/path_traversal.rb:16:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/json_csrf.rb:26:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/frame_options.rb:31:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/logger.rb:15:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/common_logger.rb:33:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:231:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:224:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:194:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1957:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1501:in `block in call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1728:in `synchronize'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1501:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/handler/webrick.rb:86:in `service'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'

@0crat
Copy link
Collaborator

0crat commented Jun 1, 2018

@llorllale/z please, pay attention to this issue

@llorllale
Copy link
Owner

@0crat in

@llorllale llorllale added the bug Something isn't working label Jun 19, 2018
@0crat
Copy link
Collaborator

0crat commented Jun 19, 2018

@0crat in (here)

@llorllale Job #20 is now in scope, role is DEV

@llorllale llorllale added this to the 1.0.0 milestone Dec 8, 2018
@dgroup
Copy link
Contributor

dgroup commented Dec 9, 2018

@llorllale, The scope of the task isn't clear for me.
It is enough for each matcher:

  • Extends TypeSafeDiagnosingMatcher<X>
  • Reformat/rewrite the unit tests in a such way

?

@llorllale
Copy link
Owner

@dgroup I'm confused myself: this may not really apply.

@victornoel can you help?

@victornoel
Copy link
Collaborator

@dgroup @llorllale there are two things in the todo:

  1. Some matchers in cactoos-matchers makes the method matchesSafely public, and when testing the matcher, those methods are tested. This is incorrect: to test the matcher and ensure they work properly, they must be tested directly as an argument of assertThat as in ScalarHasValueTest#L54.
    The test for EndsWithTest is not correct because it tests the method matchesSafely directly instead of testing the real behaviour of the matcher (the one normally invoked by assertThat and that is partially implemented by the superclasses TypeSafeMatcher and BaseMatcher) (btw, this is why inheritance is hell to test sometimes ;).
  2. The matchers should report failure to match properly. Implementing describeMismatchSafely is the mean to do that when subclassing TypeSafeMatcher. You can see how this can then be tested correctly in ScalarHasValueTest#L87. I am not clear what TypeSafeDiagnosingMatcher is for, but if it allows for matcher to properly describe the mismatch, then I think it's ok to use it.

@llorllale
Copy link
Owner

@victornoel got it

@dgroup
Copy link
Contributor

dgroup commented Dec 13, 2018

@victornoel, please correct me if i'm wrong, the test from EndsWith shoud be like

 /**
     * Give the negative testing result for the invalid arguments.
     */
    @Test
    public void matchNegative() {
        new Assertion<>(
            "The matcher gives negative result for the invalid arguments",
            () -> new EndsWith("!"),
            new IsNot<>(new Matches<>(new TextOf("The sentence.")))
        ).affirm();
    }

   /**
     * Matcher prints the actual value(s) properly in case of errors.
     * The actual/expected section are using only when testing is failed and
     *  we need to explain what exactly went wrong.
     */
    @Test
    public void describeActualValues() {
        new Assertion<>(
            "The matcher print the value which came for testing",
            () -> {
                final Description desc = new StringDescription();
                new EndsWith("").describeMismatch(new TextOf("ABC"), desc);
                return desc.toString();
            },
            new IsEqual<>("Text ending with \"ABC\"")
        ).affirm();
    }

If we are on the same page, I can start the implementation.

@victornoel
Copy link
Collaborator

victornoel commented Dec 14, 2018

@dgroup we are not on the same page, sorry :)

Write this but replace ScalarHasValue with EndsWith:

MatcherAssert.assertThat(
            "doesn't match end of String",
            new TextOf("The sentence!"),
            new EndsWith("!")
);

And then test the negative.

@victornoel
Copy link
Collaborator

@dgroup and then test that the errors are correct, like this and this

@dgroup
Copy link
Contributor

dgroup commented Dec 14, 2018

@victornoel, I understood.
The key point here is using of @Rule + .expectMessage( instead of calling the matchesSafely directly.
@llorllale, I think we need to fix the tests for all matchers in such way (with separate tasks of course). WDYT?

P.S: We are not using MatcherAssert.assertThat anymore (#52).

@victornoel
Copy link
Collaborator

victornoel commented Dec 14, 2018

@dgroup in that case, it should look like this:

new Assertion<>(
    "doesn't match end of String",
    () -> new TextOf("The sentence!"),
    new EndsWith("!")
).affirm();

Not the opposite. Also I suppose it would be good to introduce a secondary constructor for Assertion that takes a T and wraps it into a Scalar<T>. It would be easier to read…

@dgroup
Copy link
Contributor

dgroup commented Dec 14, 2018

I also thought about secondary constructor, good idea.

@llorllale
Copy link
Owner

@dgroup

@llorllale, I think we need to fix the tests for all matchers in such way (with separate tasks of course). WDYT?

Sure.

@dgroup
Copy link
Contributor

dgroup commented Dec 18, 2018

@llorllale I'm ok to implement this task.
Please assign to me.

@llorllale
Copy link
Owner

@0crat assign @dgroup

@0crat
Copy link
Collaborator

0crat commented Dec 20, 2018

@0crat assign @dgroup (here)

@llorllale The job #20 assigned to @dgroup/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this; there will be no monetary reward for this job

@0crat
Copy link
Collaborator

0crat commented Dec 20, 2018

Manual assignment of issues is discouraged, see §19: -5 point(s) just awarded to @llorllale/z

@dgroup
Copy link
Contributor

dgroup commented Dec 25, 2018

@0crat wait, as the #64 has quite huge changes, thus it will be double work without that request.

@0crat
Copy link
Collaborator

0crat commented Dec 25, 2018

@0crat wait, as the #64 has quite huge changes, thus it will be double work without that request. (here)

@dgroup Can't understand "wait,", try one of these:

  • assign Assign a performer to this issue
  • boost Set a boost for the job
  • continue Remove a job's impediment
  • hello Just say hello
  • in Register this issue in scope (WBS)
  • out Close the order and remove this job from scope
  • pay Pay a user some extra cash
  • quality Review a task
  • resign Resign from this issue
  • status Check the status of the job
  • version Print current version of the bot
  • wait Register an impediment for a job

@dgroup
Copy link
Contributor

dgroup commented Dec 26, 2018

@0crat wait

@0crat
Copy link
Collaborator

0crat commented Dec 26, 2018

@0crat wait (here)

@dgroup The impediment for #20 was registered successfully by @dgroup/z

@dgroup
Copy link
Contributor

dgroup commented Jan 20, 2019

We have to wait for the #79 - Envelope for TypeSafeMatcher which will allow passing the lambda for describeMismatchSafely.

@0pdd
Copy link
Collaborator Author

0pdd commented Jan 27, 2019

The puzzle 7-0cc4122b has disappeared from the source code, that's why I closed this issue.

@victornoel
Copy link
Collaborator

@llorllale I don't understand why removing the puzzle for this issue was accepted: this is not solved at all and the fix goes against what the puzzle was about

@0crat
Copy link
Collaborator

0crat commented Jan 27, 2019

The job #20 is now out of scope

@0crat
Copy link
Collaborator

0crat commented Jan 27, 2019

Order was finished: +30 point(s) just awarded to @dgroup/z

@llorllale
Copy link
Owner

@victornoel we messed up, sorry

victornoel added a commit to victornoel/cactoos-matchers that referenced this issue Feb 13, 2021
victornoel added a commit to victornoel/cactoos-matchers that referenced this issue Feb 13, 2021
victornoel added a commit to victornoel/cactoos-matchers that referenced this issue Feb 13, 2021
victornoel added a commit to victornoel/cactoos-matchers that referenced this issue Feb 14, 2021
victornoel added a commit to victornoel/cactoos-matchers that referenced this issue Feb 14, 2021
victornoel added a commit to victornoel/cactoos-matchers that referenced this issue Feb 14, 2021
@0pdd
Copy link
Collaborator Author

0pdd commented Feb 14, 2021

@0pdd the puzzle #230 is still not solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working scope
Projects
None yet
Development

No branches or pull requests

5 participants