Meridian case

Hi,

Here’s the spec:

‘absolute_time_in_words should say ‘Today 08:00 PM’’ FAILED
expected: “Today 08:00 PM”,
got: “Today 08:00 pm” (using ==)

absolute_time_in_words(Time.now.utc.change({
:hour => 20,
:minute => 0,
:second => 0
}), TZInfo::Timezone.get(‘Europe/Dublin’)).should == “Today 08:00
PM”

Here’s the offending code:

def absolute_time_in_words(local_time, timezone)
today = timezone.utc_to_local(Time.now.utc).to_date
local_date = local_time.to_date
local_time.strftime(
case
when local_date == today; “Today %I:%M %p”
when local_date == today + 1; “Tomorrow %I:%M %p”
when local_date == today - 1; “Yesterday %I:%M %p”
when local_date.year == today.year
“%A, %d %b %I:%M %p”
else
“%A, %d %b %Y %I:%M %p”
end
)
end

Thanks,

Keith

On Jan 24, 2008 5:40 AM, Keith McDonnell
wrote:

Hi there,

I have a really weird issue with rspec on rails:

Given a time meridian formatted using %p

When I run rake spec the time meridian is converted to lower case:

expected: “Today 08:00 PM”,
got: “Today 08:00 pm”

Yet when I run rake spec:models and spec -cfs app/models the
specs
pass, ie the the time meridian is in upper case.

Anyone got any ideas how I can troubleshoot this one ? I’m using
rails
1.2.3, ruby 1.8.6, i686-darwin8.10.1, RSpec-1.0.6 (r2183)

Can we see the code for the example and the method that is returning
this value?

Thanks in advance.

Keith


rspec-users mailing list
rspec-users at rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users