atrium icon indicating copy to clipboard operation
atrium copied to clipboard

shortcut for LocalDate(Time) and ZonedDateTime.day

Open robstoll opened this issue 7 years ago • 11 comments

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

Code related feature

expect(LocalDate.now).day.toBe(3)
expect(LocalDate.now).day {
  isLessThan(20)
  ...
}

expect(LocalDateTime.now).day.toBe(2019)
expect(LocalDateTime.now).day {
  isLessThan(20)
  ...
}

expect(ZonedDateTime.now).day.toBe(2019)
expect(ZonedDateTime.now).day {
  isLessThan(20)
  ...
}

//instead of

expect(LocaleDate.now).feature { f(it::dayOfMonth) }.toBe(3)
expect(LocaleDate.now).feature({ f(it::dayOfMonth) }) {
  isLessThan(2020)
  ...
}

...

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

domain

  • extend LocalDateAssertions with a function day (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 _day in localDateAssertions by using the ExpectImpl.feature.manual (see collectionsAssertions -> size as a guideline)
    • add DAY("day") to DescriptionDateTimeLikeAssertion for en_GB
    • add DAY("Tag") 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 avatar Oct 03 '19 12:10 robstoll

Hi @robstoll I'll work on this.

ahmadrosid avatar Oct 03 '19 12:10 ahmadrosid

@ahmadrosid I forgot to merge the preparation for this task. Could you please rebase onto master (or delete the fork and fork again)

robstoll avatar Oct 03 '19 13:10 robstoll

Yes @robstoll no problem. I will fork again.

ahmadrosid avatar Oct 03 '19 13:10 ahmadrosid

@ahmadrosid please rebase on master (in case you haven't done this before: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request). The shortcut for year was added by now (you might want to have a look at the pull request #182 in case you are stuck).

robstoll avatar Oct 06 '19 09:10 robstoll

@ahmadrosid do you need any help?

robstoll avatar Oct 14 '19 12:10 robstoll

I'll work on this?

leelanakka avatar Oct 15 '19 16:10 leelanakka

@leelanakka I am not entirely sure if @ahmadrosid has given up or is still working on it. You can start as well though. In the worst case you are doing the same.

robstoll avatar Oct 15 '19 18:10 robstoll

@leelanakka do you need any help? I un-assign you again, so that others can take up if they like. Write here so that others know that you still work on it.

robstoll avatar Oct 23 '19 18:10 robstoll

I've pushed the code, can you reassign that to me? let me know in case anything needs to be done

leelanakka avatar Oct 30 '19 14:10 leelanakka

@robstoll I am working on it. Will raise PR soon.

ShradhaSangtani avatar Nov 28 '19 05:11 ShradhaSangtani

Implemented with #275

robstoll avatar Dec 03 '19 10:12 robstoll