Example #1
0
  @Test
  public void cache_locales() {
    assertThat(jRubyI18n.getLocalesByRubyKey()).isEmpty();

    jRubyI18n.getLocale("fr");

    assertThat(jRubyI18n.getLocalesByRubyKey()).hasSize(1);
    assertThat(jRubyI18n.getLocalesByRubyKey().get("fr")).isNotNull();
  }
Example #2
0
  @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()));
  }
Example #3
0
 @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));
 }
Example #4
0
 @Test
 public void age_from_now() {
   Date date = new Date();
   jRubyI18n.ageFromNow(date);
   verify(i18n).ageFromNow(any(Locale.class), eq(date));
 }
Example #5
0
 @Test
 public void message() {
   jRubyI18n.message("en", "my.key", "default");
   verify(i18n).message(any(Locale.class), eq("my.key"), eq("default"));
 }
Example #6
0
 @Test
 public void default_locale_should_be_english() {
   assertThat(JRubyI18n.toLocale(null)).isEqualTo(Locale.ENGLISH);
 }
Example #7
0
 @Test
 public void convert_locales() {
   assertThat(JRubyI18n.toLocale("fr")).isEqualTo(Locale.FRENCH);
   assertThat(JRubyI18n.toLocale("fr-CH")).isEqualTo(new Locale("fr", "CH"));
 }
Example #8
0
 @Test
 public void format_date_time() {
   Date date = new Date();
   jRubyI18n.formatDateTime(date);
   verify(i18n).formatDateTime(any(Locale.class), eq(date));
 }
Example #9
0
 @Test
 public void shouldConvertLocales() {
   assertThat(JRubyI18n.toLocale("fr"), Is.is(Locale.FRENCH));
   assertThat(JRubyI18n.toLocale("fr-CH"), Is.is(new Locale("fr", "CH")));
 }