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

shortcut for LocalDate(Time) and ZonedDateTime.year #174

Closed
robstoll opened this issue Oct 3, 2019 · 1 comment · Fixed by #182
Closed

shortcut for LocalDate(Time) and ZonedDateTime.year #174

robstoll opened this issue Oct 3, 2019 · 1 comment · Fixed by #182
Assignees
Milestone

Comments

@robstoll
Copy link
Owner

robstoll commented Oct 3, 2019

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

Code related feature

expect(LocalDate.now).year.toBe(2019)
expect(LocalDate.now).year {
  isLessThan(2020)
  ...
}

expect(LocalDateTime.now).year.toBe(2019)
expect(LocalDateTime.now).year {
  isLessThan(2020)
  ...
}

expect(ZonedDateTime.now).year.toBe(2019)
expect(ZonedDateTime.now).year {
  isLessThan(2020)
  ...
}

//instead of

expect(LocaleDate.now).feature { f(it::year) }.toBe(2019)
expect(LocaleDate.now).feature({ f(it::year) }) {
  isLessThan(2020)
  ...
}

...

Following the things you need to do (same same but different for LocaleDateTime and ZonedDateTime):

domain

  • extend LocalDateAssertions with a function year (see CollectionAssertions.size as a guideline)
  • modify LocalDateAssertionsBuilder, delegate to LocalDateAssertions (see CollectionAssertionsBuilder as a guideline)
  • delegate implementation to robstoll-lib in LocalDateAssertionsImpl (see CollectionAssertionsImpl as a guideline)

lib

  • implement _year in localDateAssertions by using the ExpectImpl.feature.manual (see collectionsAssertions -> size as a guideline)
    • add YEAR("year") to DescriptionDateTimeLikeAssertion for en_GB
    • add YEAR("Jahr") to DescriptionDateTimeLikeAssertion for de_CH

api (fluent-en_GB/extensions/jdk8)

  • provide a val which returns Expect (see collectionAssertions.kt as a guideline)
  • provide a fun which expects an assertionCreator-lambda and returns Expect (see collectionAssertions.kt as a guideline)
  • extend or write a separate Spec named LocalDateFeatureAssertionsSpec 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).
@robstoll robstoll changed the title LocalDate(Time) and ZonedDateTime.year shortcut for LocalDate(Time) and ZonedDateTime.year Oct 3, 2019
@lpicanco
Copy link
Contributor

lpicanco commented Oct 5, 2019

Hi @robstoll,

I'll work on this

lpicanco added a commit to lpicanco/atrium that referenced this issue Oct 6, 2019
robstoll added a commit that referenced this issue Oct 6, 2019
#174: Adding shortcut for LocalDate.year, LocalDateTime.year and ZonedDateTime.year
@robstoll robstoll added this to the 0.9.0 milestone Oct 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants