I am having a problem testing a date in a rails view

I see June 13, 2009 on my index page when running in development.

I get this
2.
is not true.

require File.expand_path(File.dirname(FILE) + ‘/…/…/spec_helper’)

describe “/timesheets/index.html.erb” do
include TimesheetsHelper

before(:each) do
assigns[:timesheets] = [
stub_model(Timesheets,
:tsdate => Date.parse(‘2009-6-13’),
:off => false,
:vacation => 9.99,
:holiday => 9.99,
:closed => false,
:comment => “value for comment”,
:admin_comment => “value for admin_comment”,
:approved => false
),
stub_model(Timesheets,
:tsdate => Date.parse(‘2009-6-13’),
:off => false,
:vacation => 9.99,
:holiday => 9.99,
:closed => false,
:comment => “value for comment”,
:admin_comment => “value for admin_comment”,
:approved => false
)
]
end

it “renders a list of timesheets” do
render
response.should have_tag(“tr>td”, “2009-06-13”.to_s, 2) <++++++++
This
where it fails +++++>
response.should have_tag(“tr>td”, false.to_s, 2)
response.should have_tag(“tr>td”, 9.99.to_s, 2)
response.should have_tag(“tr>td”, 9.99.to_s, 2)
response.should have_tag(“tr>td”, false.to_s, 2)
response.should have_tag(“tr>td”, “value for comment”.to_s, 2)
response.should have_tag(“tr>td”, “value for admin_comment”.to_s, 2)
response.should have_tag(“tr>td”, false.to_s, 2)
end
end


View this message in context:
http://www.nabble.com/I-am-having-a-problem-testing-a-date-in-a-rails-view-tp23992350p23992350.html
Sent from the rspec-users mailing list archive at Nabble.com.

On Thu, Jun 11, 2009 at 10:36 PM, powertoaster[email protected]
wrote:

I see June 13, 2009 on my index page when running in development.

I get this
2.
is not true.

This is not an rspec failure message. What other gems do you have at
play?

Also, what versions of rspec, rspec-rails, ruby, rails, OS, etc?

http://wiki.github.com/dchelimsky/rspec/get-in-touch

I fixed this problem, I was only checking for a partial string rather
than
the full string in the element. The way I discovere dit for those who
are
interested was by printing out the response.body object so that I could
view
the actuall content I was testing against.:jumping:

View this message in context:
http://www.nabble.com/I-am-having-a-problem-testing-a-date-in-a-rails-view-tp23992350p24099603.html
Sent from the rspec-users mailing list archive at Nabble.com.

This is not an rspec failure message. What other gems do you have at
play?

Also, what versions of rspec, rspec-rails, ruby, rails, OS, etc?

http://wiki.github.com/dchelimsky/rspec/get-in-touch

Rails 2.3.2
Ruby 1.8
Rspec 1.2.6
calendar_date_select 1.15 (I am not using this on the index page)
validates_date_time plugin in the model
(agilewebdevelopment.com/plugins/validates_date_time)

Running on windows using RubyMine 1.1.

I am using the default index.html.erb_spec.rb file generated from the
rspec-scaffold generator but added the fields for the tsdate since the
generator ignored that field for all of the view specs. It is in the
model
stuff but none of the view specs. I assumed that it did not like the
date
datatype in views.

In my index page I do use a custom date formatter
timesheets.tsdate.to_s(:timesheet) which I have defined in an
initializers
time_formats.rb file.

View this message in context:
http://www.nabble.com/I-am-having-a-problem-testing-a-date-in-a-rails-view-tp23992350p24002045.html
Sent from the rspec-users mailing list archive at Nabble.com.