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