[rspec-users] mock_model not stubbing model attribtues in view spec

Doug Livesey lists at ruby-forum.com
Tue May 20 06:50:41 EDT 2008

Hi -- I am just getting to grips w/ view specs, and am having an issue
with mock_model not stubbing the mocked model's attributes.
For instance, I have the following:


before do
  @input_timesheet = mock_model( InputTimesheet )
  assigns[:input_timesheet] = @input_timesheet

it "should display a table element" do
  render '/input_timesheets/edit.rhtml_spec.rb'
  response.should have_tag( 'table' )


Obviously, the view calls for a number of attributes from the
@input_timesheet, but unless I explicitly define these in the mock_model
method, I get the following kind of error:

ActionView::TemplateError in '/input_timesheets/edit.rhtml should
display expected InputTimesheet details' Mock 'InputTimesheet_1000'
received unexpected message :comments with (no args)

Can anyone offer any advice as to why this should be?
(Maybe it's supposed to be like this for views?)
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list