@Test public void cache_locales() { assertThat(jRubyI18n.getLocalesByRubyKey()).isEmpty(); jRubyI18n.getLocale("fr"); assertThat(jRubyI18n.getLocalesByRubyKey()).hasSize(1); assertThat(jRubyI18n.getLocalesByRubyKey().get("fr")).isNotNull(); }
@Test public void shouldCacheLocales() { JRubyI18n i18n = new JRubyI18n(mock(I18n.class)); assertThat(i18n.getLocalesByRubyKey().size(), Is.is(0)); i18n.getLocale("fr"); assertThat(i18n.getLocalesByRubyKey().size(), Is.is(1)); assertThat(i18n.getLocalesByRubyKey().get("fr"), not(nullValue())); }
@Test public void format_long_work_duration() { jRubyI18n.formatLongDuration(10L, "SHORT"); verify(durations) .format(any(Locale.class), eq(Duration.create(10L)), eq(Durations.DurationFormat.SHORT)); }
@Test public void age_from_now() { Date date = new Date(); jRubyI18n.ageFromNow(date); verify(i18n).ageFromNow(any(Locale.class), eq(date)); }
@Test public void message() { jRubyI18n.message("en", "my.key", "default"); verify(i18n).message(any(Locale.class), eq("my.key"), eq("default")); }
@Test public void default_locale_should_be_english() { assertThat(JRubyI18n.toLocale(null)).isEqualTo(Locale.ENGLISH); }
@Test public void convert_locales() { assertThat(JRubyI18n.toLocale("fr")).isEqualTo(Locale.FRENCH); assertThat(JRubyI18n.toLocale("fr-CH")).isEqualTo(new Locale("fr", "CH")); }
@Test public void format_date_time() { Date date = new Date(); jRubyI18n.formatDateTime(date); verify(i18n).formatDateTime(any(Locale.class), eq(date)); }
@Test public void shouldConvertLocales() { assertThat(JRubyI18n.toLocale("fr"), Is.is(Locale.FRENCH)); assertThat(JRubyI18n.toLocale("fr-CH"), Is.is(new Locale("fr", "CH"))); }