Sha256: 0f98870885c4e4ed021a69e4fa4d639c88b8ee20349097ddbfad75eb5ec1500f

Contents?: true

Size: 1.17 KB

Versions: 27

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

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 & 1 rubygems

Version Path
mongoid-8.1.9 spec/support/shared/time.rb
mongoid-8.0.9 spec/support/shared/time.rb
mongoid-8.1.8 spec/support/shared/time.rb
mongoid-8.1.7 spec/support/shared/time.rb
mongoid-8.1.6 spec/support/shared/time.rb
mongoid-8.0.8 spec/support/shared/time.rb
mongoid-8.1.5 spec/support/shared/time.rb
mongoid-8.1.4 spec/support/shared/time.rb
mongoid-8.0.7 spec/support/shared/time.rb
mongoid-8.1.3 spec/support/shared/time.rb
mongoid-8.1.2 spec/support/shared/time.rb
mongoid-8.0.6 spec/support/shared/time.rb
mongoid-7.5.4 spec/support/shared/time.rb
mongoid-8.1.1 spec/support/shared/time.rb
mongoid-8.0.5 spec/support/shared/time.rb
mongoid-8.1.0 spec/support/shared/time.rb
mongoid-7.5.3 spec/support/shared/time.rb
mongoid-8.0.4 spec/support/shared/time.rb
mongoid-8.0.3 spec/support/shared/time.rb
mongoid-7.5.2 spec/support/shared/time.rb