Atrium: add Path.hasSameTextualContentAs to infix API

Created on 25 May 2020  路  7Comments  路  Source: robstoll/atrium

Platform (jvm, js, android): jvm
Extension (none, kotlin 1.3): none

Code related feature

Follow up of #375, we want the corresponding functionality in api-infix as well

expect(path) hasSameTextualContentAs path
expect(path) hasSameTextualContentAs withEncoding(path, sourceEncoding=..., targetEncoding=...)
expect(path) hasSameBinaryContentAs path

api-infix

  • [ ] copy the functions from apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pathAssertions.kt to apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pathAssertions.kt
  • [ ] adjust the functions, add infix modifier, change @since 0.12.0 to @since 0.13.0 (adapt to current milestone) and split hasSameTextualContentAs into two functions:

    • [ ] first expects only targetPath: Path

    • [ ] second expects a parameter object EncodingWithCreator which you need to create (see PathWithCreator for guidelines)

    • [ ] add the helper function withEncoding(targetPath: Path, sourceCharset: Charset = Charsets.UTF_8, targetCharset: Charset = Charsets.UTF_8) which creates an EncodingWithCreator (see helper function path in pathAssertions.kt)

  • [ ] adjust PathAssertionSpec, fix the not supported in this API and use the newly added functions instead

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 help wanted

All 7 comments

@assaflei do you fancy implementing this one?

I'll work on this

Hello
I have a question regarding splitting "hasSameTextualContentAs" function:
first one with only path parameter is unused, because in PathAssertionsSpec.kt there is only one parameter for given function. Is this normal?

there is only one parameter for given function

I am not sure what you mean by that but you are right that we have only

hasSameTextualContentAs: Fun3<Path, Path, Charset, Charset>,

Which expects 3 arguments. I.e we have not checked that the default arguments are UTF-8. Let's add this. Would you mind doing this? Otherwise I can add it for you and you can rebase afterwards.
Add hasSameTextualContentAsDefaultArgs: Fun1<Path, Path>, to misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/PathAssertionsSpec.kt
Add a test case to:

  • context("empty content") { -- should not throw
  • context("has same binary content") { -- should not throw (basically same as it("${hasSameTextualContentAs.name} - does not throw if UTF-8, UTF-8 is used")
  • context("has same textual content in UTF-8 and UTF-16") { -- should throw
  • context("has different textual content") { should throw

No prob. I'll add hasSameTextualContentAsDefaultArgs by myself. thanks for offering your help ^^

@z13z I just realised we don't have hasSameBinaryContentAs in infix either. How about you create a second PR (or include it in your first as you wish)?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robstoll picture robstoll  路  6Comments

robstoll picture robstoll  路  6Comments

dalewking picture dalewking  路  6Comments

robstoll picture robstoll  路  3Comments

robstoll picture robstoll  路  7Comments