Atrium: CharSequence.mismatches

Created on 2 Oct 2019  路  8Comments  路  Source: robstoll/atrium

Platform (jvm, jdk8, js, android): all

Code related feature

Opposite to #164

expect("hello").mismatches(Regex("([hH]ello"))

which should result in reporting

expect: "hello World"       (String<987383>)
* does not match entirely: [hH]ello     (Regex<123423>)

This assertion function checks that the given regex does not match CharSequence or at least not entirely, ergo it fails if it matches entirely.

Following the things you need to do:

domain

  • extend CharSequenceAssertions with a function mismatches which expects a Regex (see other functions as a guideline but use Expect instead of SubjectProvider)
  • modify CharSequenceAssertionsBuilder, delegate to charSequenceAssertions (see other functions as a guideline)
  • delegate implementation to robstoll-lib in CharSequenceAssertionsImpl (see other functions as a guideline)

lib

  • implement _mismatches in charSequenceAssertions

    • add MISMATCHES("does not match entirely") to DescriptionCharSequenceAssertion for en_GB

    • add MISMATCHES("stimmt nicht vollst盲ndig 眉berein mit") to DescriptionCharSequenceAssertion for de_CH

api (only fluent-en_GB)

  • provide the fun mismatches (see other assertion functions in charSequenceAssertions.kt)
  • extend CharSequenceAssertionsSpec in specs-common (see for instance YzFeatureAssertionsSpec) and extend it in atrium-api-fluent-en_GB-common/src/test

    • include a test case where there is a match within the CharSequence

Your first contribution?

  • Write a comment I'll work on this if you would like to take this issue over.
    This way we get the chance to revise the description in case things have changed in the meantime,
    we might give you additional hints and we can assign the task to you, so that others do not start as well.
  • See Your first code contribution for guidelines.
  • Do not hesitate to ask questions here or to contact us via Atrium's slack channel if you need help
    (Invite yourself in case you do not have an account yet).
good first issue hacktoberfest help wanted

All 8 comments

I'll work on this

@shardulsonar in case you already started with the implementation. I have removed the overload which expects only a String. I am not yet 100% sure if it is a good idea to add it. Let's start with Regex only

@robstoll : I am having a problem in the last step.

'extend CharSequenceAssertionsSpec in specs-common (see for instance YzFeatureAssertionsSpec) and extend it in atrium-api-fluent-en_GB-common/src/test
include a test case where there is a match within the CharSequence'

I am getting a type mismatch compilation error while trying this :
image

@shardulsonar coud you please create a WIP pull request so that I have a bit more context
Have you extended CharSequenceAssertionsSpec? Without more context it looks to me like you want to pass your Fun1 for the describePrefix argument.

@shardulsonar coud you please create a WIP pull request so that I have a bit more context
Have you extended CharSequenceAssertionsSpec? Without more context it looks to me like you want to pass your Fun1 for the describePrefix argument.

I have added the changes, please have a look.

You need to adopt ch.tutteli.atrium.specs.integration.CharSequenceAssertionsSpec:
add your new function after endsNotWithChar: Fun1<CharSequence, Char>

See also the other comments I made. Just as information, when you create a pull request, then I can actually propose changes which you can accept per click. Might be more convenient for me and you.

Does that help?

You need to adopt ch.tutteli.atrium.specs.integration.CharSequenceAssertionsSpec:
add your new function after endsNotWithChar: Fun1<CharSequence, Char>

See also the other comments I made. Just as information, when you create a pull request, then I can actually propose changes which you can accept per click. Might be more convenient for me and you.

Does that help?

Hello Thanks for the suggestions. That Helped.
After making the changes that you suggested, I ran the build and I got a compilation error :
_atrium\apis\fluent-en_GB\atrium-api-fluent-en_GB-common\src\test\kotlin\ch\tutteli\atrium\api\fluent\en_GB\CharSequenceAssertionsSpec.kt: (19, 1): No value passed for parameter 'mismatches'_

So I added fun1<CharSequence, Regex>(Expect<CharSequence>::mismatches) at the end of atrium\apis\fluent-en_GB\atrium-api-fluent-en_GB-common\src\test\kotlin\ch.tutteli.atrium.api.fluent.en_GB.CharSequenceAssertionsSpec.kt

After adding this line code I get a different compilation error :
_atrium\apis\fluent-en_GB\atrium-api-fluent-en_GB-common\src\test\kotlin\ch\tutteli\atrium\api\fluent\en_GB\CharSequenceAssertionsSpec.kt: (19, 53): Type inference failed: Not enough information to infer param
eter T in fun Expect.mismatches(expected: Regex): Expect_

image

I made a comment in your code. Could you please create a pull request (see https://help.github.com/en/articles/creating-a-pull-request-from-a-fork if you haven't done this before). You can prefix the title of the pull request with [WIP] (WIP = work in progress). It is much easier to review on a pull request.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robstoll picture robstoll  路  6Comments

robstoll picture robstoll  路  7Comments

robstoll picture robstoll  路  6Comments

robstoll picture robstoll  路  4Comments

robstoll picture robstoll  路  3Comments