atrium icon indicating copy to clipboard operation
atrium copied to clipboard

shortcut for LocalDate(Time) and ZonedDateTime.month

Open robstoll opened this issue 7 years ago • 7 comments

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

Code related feature

expect(LocalDate.now).month.toBe(10)
expect(LocalDate.now).month {
  isLessThan(11)
  ...
}

expect(LocalDateTime.now).month.toBe(10)
expect(LocalDateTime.now).month {
  isLessThan(11)
  ...
}

expect(ZonedDateTime.now).month.toBe(10)
expect(ZonedDateTime.now).month {
  isLessThan(2020)
  ...
}

//instead of

expect(LocaleDate.now).feature { f(it::month) }.toBe(10)
expect(LocaleDate.now).feature({ f(it::month) }) {
  isLessThan(11)
  ...
}

...

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

domain

  • extend LocalDateAssertions with a function month (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 _month in localDateAssertions by using the ExpectImpl.feature.manual (see collectionsAssertions -> size as a guideline)
    • add MONTH("month") to DescriptionDateTimeLikeAssertion for en_GB
    • add MONTH("Monat") 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

ShradhaSangtani avatar Oct 05 '19 17:10 ShradhaSangtani

@ShradhaSangtani 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

@robstoll Sure thanks I have rebased the project. I have few doubts though. I have setup the project on intellij. I am able to run the atrium mocha task which runs all the tests in the project. But i am unable to run the individual tests. Also tried using kotlinTest plugin to run a particular test. Can you help me with this?

ShradhaSangtani avatar Oct 07 '19 13:10 ShradhaSangtani

Mocha is only used to run the JS tests, you won't need those for your task. Have a look at Your first code contribution tests are written with Spek. And as written there, you need the Spek Framework by Spek Team plugin for intellij to run the specs. Does that already help enough? You can also run test for an individual module with gradle, e.g. ./gr :atrium-api-core-jvm:build builds the atrium-api-core-jvm module which includes running its tests.

robstoll avatar Oct 07 '19 16:10 robstoll

@robstoll Yeah I am able to run spek tests now. Thanks :)

ShradhaSangtani avatar Oct 07 '19 17:10 ShradhaSangtani

@robstoll Raised PR . Please have a look.

ShradhaSangtani avatar Oct 08 '19 12:10 ShradhaSangtani

implemented via d80bb63

robstoll avatar Oct 08 '19 13:10 robstoll