Sha256: 7cc7ad587ce13e3a9a0a7390e8ed8d49bf76225e9a050a78f2deaa80124d1acb

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'rails-timeago', type: :feature, js: true do
  let(:time) { 2.days.ago }

  before do
    Application.render do |args|
      Time.zone = 'UTC'
      render.call(*args)
    end
  end

  before { visit '/' }
  subject { find 'body > time' }

  describe 'renders simple timeago tag' do
    let(:render) do
      ->(h) { h.timeago_tag(time) }
    end

    it { is_expected.to have_content '2 days ago' }
    it { expect(subject[:lang]).to eq '' }
    it { expect(subject[:title]).to eq I18n.l(time) }
    it { expect(subject[:datetime]).to eq time.iso8601 }
  end

  describe 'renders timeago tag with language' do
    let(:render) do
      ->(h) { h.timeago_tag(time, lang: :de) }
    end

    it { is_expected.to have_content 'vor 2 Tagen' }
    it { expect(subject[:lang]).to eq 'de' }
    it { expect(subject[:title]).to eq I18n.l(time) }
  end

  describe 'renders timeago tag with format' do
    let(:render) do
      ->(h) { h.timeago_tag(time, format: :short) }
    end

    it { expect(subject[:title]).to eq I18n.l(time, format: :short) }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-timeago-2.19.0 spec/rails-timeago_spec.rb
rails-timeago-2.18.0 spec/rails-timeago_spec.rb
rails-timeago-2.17.1 spec/rails-timeago_spec.rb