Gaston Ramos
2008-Jun-06 21:48 UTC
[rspec-users] Problems with view spec and mocking will_paginate
Hi all, I have some failures that not I don''t understand this the pastie with index.erb.html http://pastie.org/private/zgohh6dcts04wpfagfgz5q and this is the pastie for view''s spec: http://pastie.org/210485 and the failure: 1) ActionView::TemplateError in ''/posts/index.html.erb should render list of posts'' undefined method `count'' for [#<Comment:0x..fdb6535be @name="Comment_1001">]:Array I tried this: Array.stub!(:count).and_return(1) but didn''t work. Can somebody help me? Regards. -- "Es imposible afinar un l?piz con una cuchilla desafilada. Es igualmente in?til tratar de hacerlo con diez." (Edsger Dijkstra) +-------------------------------------+ Gast?n Ramos http://gastonramos.wordpress.com/ GNU/Linux Counter user #450312
Matthias Hennemeyer
2008-Jun-07 07:28 UTC
[rspec-users] Problems with view spec and mocking will_paginate
You have to stub that count method for the Array object and not for class Array: comments = [comment] comments.stub!(:count).and_return(1) post_98.stub!(:comments).and_return(comments) post_99.stub!(:comments).and_return(comments) Matthias Am 06.06.2008 um 23:48 schrieb Gaston Ramos:> Hi all, I have some failures that not I don''t understand > > this the pastie with index.erb.html > http://pastie.org/private/zgohh6dcts04wpfagfgz5q > > and this is the pastie for view''s spec: > http://pastie.org/210485 > > and the failure: > > 1) > ActionView::TemplateError in ''/posts/index.html.erb should render list > of posts'' > undefined method `count'' for [#<Comment:0x..fdb6535be > @name="Comment_1001">]:Array > > I tried this: Array.stub!(:count).and_return(1) > but didn''t work. > > Can somebody help me? > > Regards. > > -- > "Es imposible afinar un l?piz con una cuchilla desafilada. Es > igualmente in?til tratar de hacerlo con diez." > (Edsger Dijkstra) > > > +-------------------------------------+ > Gast?n Ramos > http://gastonramos.wordpress.com/ > GNU/Linux Counter user #450312 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Gaston Ramos
2008-Jun-09 12:02 UTC
[rspec-users] Problems with view spec and mocking will_paginate
Thanks! El s?b, 07 de jun de 2008, a las 09:28:23 +0200, Matthias Hennemeyer dijo:> You have to stub that count method for the Array object and not for > class Array: > > comments = [comment] > comments.stub!(:count).and_return(1) > post_98.stub!(:comments).and_return(comments) > post_99.stub!(:comments).and_return(comments) > > Matthias > > Am 06.06.2008 um 23:48 schrieb Gaston Ramos: > >> Hi all, I have some failures that not I don''t understand >> >> this the pastie with index.erb.html >> http://pastie.org/private/zgohh6dcts04wpfagfgz5q >> >> and this is the pastie for view''s spec: >> http://pastie.org/210485 >> >> and the failure: >> >> 1) >> ActionView::TemplateError in ''/posts/index.html.erb should render list >> of posts'' >> undefined method `count'' for [#<Comment:0x..fdb6535be >> @name="Comment_1001">]:Array >> >> I tried this: Array.stub!(:count).and_return(1) >> but didn''t work. >> >> Can somebody help me? >> >> Regards. >> >> >> >> +-------------------------------------+ >> Gast?n Ramos >> http://gastonramos.wordpress.com/ >> GNU/Linux Counter user #450312 >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users-- "Premature optimization is the root of all evil (or at least most of it) in programming." (Donald Knuth) +-------------------------------------+ Gast?n Ramos http://gastonramos.wordpress.com/ GNU/Linux Counter user #450312