Sha256: b4874ff71f2e20afc5ac32a6614b4079c9b2619159e539874273fceb42a906a8

Contents?: true

Size: 1.18 KB

Versions: 27

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

shared_context 'using AS time zone' do
  before do
    Mongoid.use_activesupport_time_zone = true
    Time.zone = "Tokyo"
  end

  after do
    Time.zone = nil
  end
end

shared_context 'not using AS time zone' do
  before do
    Mongoid.use_activesupport_time_zone = false
    Time.zone = 'Tokyo'
  end

  after do
    Mongoid.use_activesupport_time_zone = true
    Time.zone = nil
  end
end

shared_examples_for 'mongoizes to AS::TimeWithZone' do
  it 'is an AS::TimeWithZone' do
    expect(mongoized.class).to eq(ActiveSupport::TimeWithZone)
  end

  it 'is equal to expected time' do
    expect(expected_time).to be_a(ActiveSupport::TimeWithZone)
    expect(mongoized).to eq(expected_time)
  end
end

shared_examples_for 'mongoizes to Time' do
  it 'is a Time' do
    expect(mongoized.class).to eq(Time)
  end

  it 'is equal to expected time' do
    expect(expected_time).to be_a(Time)
    expect(mongoized).to eq(expected_time)
  end
end

shared_examples_for 'maintains precision when mongoized' do
  it 'maintains precision' do
    # 123457 happens to be consistently obtained by various tests
    expect(mongoized.to_f.to_s).to match(/\.123457/)
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mongoid-7.3.5 spec/support/shared/time.rb
mongoid-7.3.4 spec/support/shared/time.rb
mongoid-7.1.11 spec/support/shared/time.rb
mongoid-7.2.6 spec/support/shared/time.rb
mongoid-7.3.3 spec/support/shared/time.rb
mongoid-7.3.2 spec/support/shared/time.rb
mongoid-7.2.5 spec/support/shared/time.rb
mongoid-7.1.10 spec/support/shared/time.rb
mongoid-7.1.9 spec/support/shared/time.rb
mongoid-7.2.4 spec/support/shared/time.rb
mongoid-7.3.1 spec/support/shared/time.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/spec/support/shared/time.rb
mongoid-7.3.0 spec/support/shared/time.rb
mongoid-7.2.3 spec/support/shared/time.rb
mongoid-7.1.8 spec/support/shared/time.rb
mongoid-7.2.2 spec/support/shared/time.rb
mongoid-7.2.1 spec/support/shared/time.rb
mongoid-7.1.7 spec/support/shared/time.rb
mongoid-7.2.0 spec/support/shared/time.rb
mongoid-7.1.6 spec/support/shared/time.rb