Not a huge deal, but is there a better way to handle timezone issues in unit tests? in activerecord/test/base_test.rb, I''m finding that 2003-07-16t15:28:00.00+01:00 is presumed to be 2003-07-16 09:28:00 which it is, in Chicago. But out in sunny California, that''s 7:28am, so test_to_xml is failing. Is there an easy way to rewrite the assertion so it works for folks not in the Windy City?
> Is there an easy way to rewrite the assertion so it works for folks not > in the Windy City?I live in another windy city, so I noticed this too. I believe this is now fixed as of [3870]. to_xml uses the xmlschema format (so timezones are included) and the test now checks for the string in the local timezone. -- Cheers Koz
Michael Koziarski wrote:>> Is there an easy way to rewrite the assertion so it works for folks not >> in the Windy City? > > I live in another windy city, so I noticed this too. I believe this > is now fixed as of [3870]. to_xml uses the xmlschema format (so > timezones are included) and the test now checks for the string in the > local timezone.Hmm, now the tests fail for lack of #xmlschema. For example: test_to_xml(BasicsTest): NoMethodError: undefined method `xmlschema'' for Sun Jan 30 06:28:00 PST 2005:Time ./test/../lib/../../activesupport/lib/active_support/core_ext/hash/conversions.rb:15 ./test/../lib/../../activesupport/lib/active_support/core_ext/hash/conversions.rb:36:in `to_xml'' ./test/../lib/../../activesupport/lib/active_support/core_ext/hash/conversions.rb:24:in `to_xml'' ./test/../lib/../../activesupport/lib/active_support/vendor/builder/xmlbase.rb:138:in `_nested_structures'' ./test/../lib/../../activesupport/lib/active_support/vendor/builder/xmlbase.rb:60:in `method_missing'' ./test/../lib/../../activesupport/lib/active_support/core_ext/hash/conversions.rb:23:in `to_xml'' ./test/../lib/active_record/base.rb:1560:in `to_xml'' ./test/base_test.rb:1163:in `test_to_xml''
worksforme. What other components do you have checked out? I must have to move something into activesupport? On 3/15/06, Michael Schoen <schoenm@earthlink.net> wrote:> Michael Koziarski wrote: > >> Is there an easy way to rewrite the assertion so it works for folks not > >> in the Windy City? > > > > I live in another windy city, so I noticed this too. I believe this > > is now fixed as of [3870]. to_xml uses the xmlschema format (so > > timezones are included) and the test now checks for the string in the > > local timezone. > > Hmm, now the tests fail for lack of #xmlschema. > > For example: > > test_to_xml(BasicsTest): > NoMethodError: undefined method `xmlschema'' for Sun Jan 30 06:28:00 PST > 2005:Time > > ./test/../lib/../../activesupport/lib/active_support/core_ext/hash/conversions.rb:15 > > ./test/../lib/../../activesupport/lib/active_support/core_ext/hash/conversions.rb:36:in > `to_xml'' > > ./test/../lib/../../activesupport/lib/active_support/core_ext/hash/conversions.rb:24:in > `to_xml'' > > ./test/../lib/../../activesupport/lib/active_support/vendor/builder/xmlbase.rb:138:in > `_nested_structures'' > > ./test/../lib/../../activesupport/lib/active_support/vendor/builder/xmlbase.rb:60:in > `method_missing'' > > ./test/../lib/../../activesupport/lib/active_support/core_ext/hash/conversions.rb:23:in > `to_xml'' > ./test/../lib/active_record/base.rb:1560:in `to_xml'' > ./test/base_test.rb:1163:in `test_to_xml'' > _______________________________________________ > Rails-core mailing list > Rails-core@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-core >-- Cheers Koz
> Hmm, now the tests fail for lack of #xmlschema.irb(main):001:0> Time.now.xmlschema NoMethodError: undefined method `xmlschema'' for Wed Mar 15 20:37:38 NZDT 2006:Time from (irb):1 irb(main):002:0> require ''time'' => true irb(main):003:0> Time.now.xmlschema => "2006-03-15T20:37:43+13:00" It doesn''t explain why it works for me, but not for you though. What ruby version are you using, windows or unix? Anything else I should look for while testing? -- Cheers Koz
Michael Koziarski wrote:>> Hmm, now the tests fail for lack of #xmlschema. > > > irb(main):001:0> Time.now.xmlschema > NoMethodError: undefined method `xmlschema'' for Wed Mar 15 20:37:38 > NZDT 2006:Time > from (irb):1 > irb(main):002:0> require ''time'' > => true > irb(main):003:0> Time.now.xmlschema > => "2006-03-15T20:37:43+13:00" > > It doesn''t explain why it works for me, but not for you though. What > ruby version are you using, windows or unix? Anything else I should > look for while testing?Ruby 1.8.4, on Debian. I''ll play around a bit later this morning, see if I can find anything.
Michael Schoen wrote:> Michael Koziarski wrote: >> It doesn''t explain why it works for me, but not for you though. What >> ruby version are you using, windows or unix? Anything else I should >> look for while testing? > > Ruby 1.8.4, on Debian. > > I''ll play around a bit later this morning, see if I can find anything.So I''m not sure why it works for you. The issue seems to be that ''time'' isn''t required as part of the test, so #xmlschema isn''t defined. If I add require ''time'' to the top of base_test.rb, it works fine. Could it be that whichever db driver you''re testing happens to require ''time'', either directly or indirectly, and the oracle driver doesn''t? Can we add require ''time'' someplace within AR explicitly?
On 3/16/06, Michael Schoen <schoenm@earthlink.net> wrote:> Michael Schoen wrote: > > Michael Koziarski wrote: > >> It doesn''t explain why it works for me, but not for you though. What > >> ruby version are you using, windows or unix? Anything else I should > >> look for while testing? > > > > Ruby 1.8.4, on Debian. > > > > I''ll play around a bit later this morning, see if I can find anything. > > So I''m not sure why it works for you. The issue seems to be that ''time'' > isn''t required as part of the test, so #xmlschema isn''t defined. > > If I add > > require ''time'' > > to the top of base_test.rb, it works fine. > > Could it be that whichever db driver you''re testing happens to require > ''time'', either directly or indirectly, and the oracle driver doesn''t? > > Can we add require ''time'' someplace within AR explicitly?How about the top of core_ext/time/conversions.rb? If that fixes it, I''ll commit it. -- Cheers Koz