is there a way to set to timezone capybara webkit runs in?

1,405 views
Skip to first unread message

Drew Batshaw

unread,
Nov 29, 2012, 3:58:04 PM11/29/12
to capybar...@googlegroups.com
I have been running into issue with my tests where I need to check a date displayed to the user which is always displayed in their local time zone.  Since the time is stored in UTC on the rails side the tests will periodically fail.  Is there a way to have capybara webkit run is a specific timezone?  For now I have resorted to doing script_evaluate("moment(#{date}") to get the date in the browsers local time but that is not very clean.

Anyone have any suggestions?

Joe Ferris

unread,
Nov 30, 2012, 10:16:42 AM11/30/12
to capybar...@googlegroups.com
Hey Drew,

I looked into this quickly and didn't see a way that we could do it. If you're on Linux, you can try setting the TZ environment variable to UTC; I haven't tried this myself.

-Joe

Drew Batshaw

unread,
Nov 30, 2012, 12:20:52 PM11/30/12
to capybar...@googlegroups.com
Thanks for the suggestion.  I will try that.

Drew Batshaw

unread,
Nov 30, 2012, 6:40:08 PM11/30/12
to capybara-webkit
I tried putting ENV['TZ'] = 'UTC' in spec_helper.rb but it didn't seem to do the job (although it definitely does when I try it in the console).

Łukasz Bandzarewicz

unread,
Jun 19, 2013, 5:40:46 AM6/19/13
to capybar...@googlegroups.com
Actually it works for me. I was running integration specs for testing parsing time with moment.js and I found this issue.
On the build server I had UTC timezone. Putting ENV['TZ'] = 'UTC' in my spec_helper.rb forced the same timezone on my local machine.
Reply all
Reply to author
Forward
0 new messages