下面的测试比较了两个日期。由于日期格式不同,测试失败。我怎样才能使这个测试工作?
expiration = Time.zone.now - 50.days
# some lines to update @organization with a new expiration
assert_equal @organization.exp, expiration
# puts @organization.exp => Mon, 16 Nov 2015
# puts expiration => Mon, 16 Nov 2015 14:22:39 CET +01:00
答案 0 :(得分:2)
使用.*/.*/^my-text$
方法,例如
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
答案 1 :(得分:0)
@organization.exp
似乎是Date
,但expiration
不是:
expiration = Time.zone.now - 50.days
#=> Mon, 16 Nov 2015 14:36:06 CET +01:00
expiration.class
#=> ActiveSupport::TimeWithZone
要获取时区感知Date
实例,您可以使用Date#current
并使用DateAndTime::Calculations#days_ago
进行更改:
expiration = Date.current.days_ago(50)
#=> Mon, 16 Nov 2015
expiration.class
#=> Date