Atrium: shortcut for LocalDate(Time) and ZonedDateTime.month

Created on 3 Oct 2019  路  7Comments  路  Source: robstoll/atrium

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).
good first issue hacktoberfest help wanted

All 7 comments

Hi @robstoll I'll work on this

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

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 Yeah I am able to run spek tests now. Thanks :)

@robstoll Raised PR . Please have a look.

implemented via d80bb63

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robstoll picture robstoll  路  4Comments

robstoll picture robstoll  路  3Comments

robstoll picture robstoll  路  5Comments

robstoll picture robstoll  路  6Comments

robstoll picture robstoll  路  3Comments