LoginSignup
8
8

More than 5 years have passed since last update.

sinatra + activerecord + rspecでのtimezone管理

Last updated at Posted at 2014-05-03

rspecを書いていて、

expected: "2014-05-01 23:00:00"
got: 2014-05-01 23:00:00 UTC

こんな結果が取れてきて、Timezoneの設定が必要なことに気付いた。

spec/spec_helper.rb
require 'sinatra'
require 'sinatra/activerecord'

Time.zone = "Tokyo"
ActiveRecord::Base.default_timezone = :local

この設定を追加したら、

こんな感じに変化した。

expected: "2014-05-01 23:00:00"
got: 2014-05-01 23:00:00 +0900

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8