Atrium: Path.fileNameWithoutExtension

Created on 2 Oct 2019  ยท  6Comments  ยท  Source: robstoll/atrium

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

Code related feature

expect(Paths.get("a/my.txt")).fileNameWithoutExtension.toBe("my")
expect(Paths.get("a/my.txt")).fileNameWithoutExtension {
    ...
}

// instead of (assuming one uses Niok, otherwise it is even more verbose)

expect(Paths.get("a/my.txt"))
  .feature("file name without extension") { fileNameWithoutExtension }
  .toBe("my")

expect(Paths.get("a/my.txt"))
    .feature("file name without extension", { fileNameWithoutExtension }) {
        ....
    }

Following the things you need to do:

domain

  • extend PathAssertions with a function fileNameWithoutExtension (see other functions as a guideline)
  • modify PathAssertionsBuilder, delegate to pathAssertions (see other functions as a guideline)
  • delegate implementation to robstoll-lib in PathAssertionsImpl (see other functions as a guideline)

lib

  • implement _fileNameWithoutExtension in pathAssertions by using the ExpectImpl.feature.manual (see collectionAssertions -> _size)
    => you can use fileNameWithoutExtension from niok

    • you might have to introduce DescriptionPathAssertion in translations-en_GB and translations_de_CH

    • add FILE_NAME_WITHOUT_EXTENSION("file name without extension") to DescriptionPathAssertions for en_GB

    • add FILE_NAME_WITHOUT_EXTENSION("Dateiname ohne Endung") to DescriptionPathAssertions for de_CH

api

  • provide a val which returns Expect (see collectionAssertions.kt -> size as a guideline)
  • provide a fun which expects an assertionCreator-lambda and returns Expect (see collectionAssertions.kt -> size as a guideline)
  • extend or write a separate Spec named PathFeatureAssertionsSpec in specs-common (see for instance CollectionFeatureAssertionsSpec) and extend it in atrium-api-fluent-en_GB-common/src/test

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 6 comments

Hi @robstoll I'll work on this

@robstoll for this one: provide a val which returns Expect (see collectionAssertions.kt -> size as a guideline) . Is the below the right place?

โ”œโ”€โ”€ apis
โ”‚ย ย  โ””โ”€โ”€ fluent-en_GB
โ”‚ย ย      โ””โ”€โ”€ extensions
โ”‚ย ย          โ””โ”€โ”€ jdk8
โ”‚ย ย              โ””โ”€โ”€ atrium-api-fluent-en_GB-jdk8-jvm
โ”‚ย ย                  โ””โ”€โ”€ src
โ”‚ย ย                      โ””โ”€โ”€ main
โ”‚ย ย                          โ””โ”€โ”€ kotlin
โ”‚ย ย                              โ””โ”€โ”€ ch
โ”‚ย ย                                  โ””โ”€โ”€ tutteli
โ”‚ย ย                                      โ””โ”€โ”€ atrium
โ”‚ย ย                                          โ””โ”€โ”€ api
โ”‚ย ย                                              โ””โ”€โ”€ fluent
โ”‚ย ย                                                  โ””โ”€โ”€ en_GB
โ”‚ย ย                                                      โ””โ”€โ”€ jdk8
โ”‚ย ย                                                          โ””โ”€โ”€ pathAssertions.kt

and the existing function size (the one from which you can copy, serves as a guideline) can be found here: apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt

got it, was basing it on this one: apis/cc-de_CH/atrium-api-cc-de_CH-common/src/main/kotlin/ch/tutteli/atrium/api/cc/de_CH/collectionAssertions.kt which looks different

should the PathFeatureAssertionsSpec be in atrium-api-fluent-en_GB-jvm instead of atrium-api-fluent-en_GB-common? because it's only for Path objects?

As it is part of the jdk8 extension it should be next to ch.tutteli.atrium.api.fluent.en_GB.jdk8.PathAssertionsSpec
The spec as such in specs-common on the other hand needs to into the jvm module, next to ch.tutteli.atrium.specs.integration.PathAssertionsSpec

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robstoll picture robstoll  ยท  5Comments

robstoll picture robstoll  ยท  3Comments

robstoll picture robstoll  ยท  6Comments

robstoll picture robstoll  ยท  5Comments

robstoll picture robstoll  ยท  4Comments