Alexander Seidl
2009-Oct-21 10:36 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
i call current_user in the index-method, but the test fails and says: "#<User::CategoriesController:0xb7439484> expected :current_user with (any args) once, but received it 0 times" Why? Attachments: http://www.ruby-forum.com/attachment/4166/pastie-663143.rb -- Posted via http://www.ruby-forum.com/.
Alexander Seidl
2009-Oct-21 10:42 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
Alexander Seidl wrote:> i call current_user in the index-method, but the test fails and says: > "#<User::CategoriesController:0xb7439484> expected :current_user with > (any args) once, but received it 0 times" > > Why?i forgot "get :index" in test. but anyways, no impact. same result. http://pastie.org/663143 -- Posted via http://www.ruby-forum.com/.
Ben Lovell
2009-Oct-21 10:47 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
2009/10/21 Alexander Seidl <lists at ruby-forum.com>> Alexander Seidl wrote: > > i call current_user in the index-method, but the test fails and says: > > "#<User::CategoriesController:0xb7439484> expected :current_user with > > (any args) once, but received it 0 times" > > > > Why? > >Try putting line 7 before line 6. Cheers, Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091021/5198d897/attachment.html>
Alexander Seidl
2009-Oct-21 11:12 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
hi ben, no impact, same result. cheers, Alexander -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2009-Oct-21 11:54 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
On Wed, Oct 21, 2009 at 6:12 AM, Alexander Seidl <lists at ruby-forum.com>wrote:> hi ben, > no impact, same result. > > cheers, > AlexanderPlease quote at least the relevant part of the previous email when you respond. I can get the context if I''m looking at mail in a web browser. Not so much on my phone. If you reverse lines 6 and 7 on http://pastie.org/663143, the example _should_ pass, so I''m a bit mystified. That said, why are you specifying that current_user is called rather than something about the response? Or is this just an excerpt you''re using for demonstration? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091021/ea2f61c3/attachment.html>
Alexander Seidl
2009-Oct-21 12:19 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
David Chelimsky wrote:> [...] > Please quote at least the relevant part of the previous email when you > respond > [...]yes ok, i''ll keep that in mind.> If you reverse lines 6 and 7 on http://pastie.org/663143, the example > _should_ pass, so I''m a bit mystified.I changed this two lines. Please have a look at the updated pastie: http://pastie.org/663143. The test still failes. But it shouldn''t! Because current_user IS obviously called by the controller.> That said, why are you specifying > that current_user is called rather than something about the response? Or > is > this just an excerpt you''re using for demonstration?This is no real test or controller, i would write or use. But i found out that this is the root of all my problems with rspec. So i boiled it down to this simple example. -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2009-Oct-21 13:05 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
On Wed, Oct 21, 2009 at 7:19 AM, Alexander Seidl <lists at ruby-forum.com>wrote:> David Chelimsky wrote: > > [...] > > Please quote at least the relevant part of the previous email when you > > respond > > [...] > yes ok, i''ll keep that in mind. > > > If you reverse lines 6 and 7 on http://pastie.org/663143, the example > > _should_ pass, so I''m a bit mystified. > I changed this two lines. Please have a look at the updated pastie: > http://pastie.org/663143. The test still failes. But it shouldn''t! > Because current_user IS obviously called by the controller. > > > That said, why are you specifying > > that current_user is called rather than something about the response? Or > > is > > this just an excerpt you''re using for demonstration? > > This is no real test or controller, i would write or use. But i found > out that this is the root of all my problems with rspec. So i boiled it > down to this simple example. >Rails version? Ruby version? OS? etc -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091021/ad335b63/attachment-0001.html>
Alexander Seidl
2009-Oct-21 13:56 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
I started a new test: Have a look at my new code: http://pastie.org/663455 1) The categories_controller is NOT called from the test! 2) I created another example with a message_controller and associated tests. There, the controller IS called! You can see that, because the puts statement produces output in 2), but not in 1). Could the reason for this be the fact, that User::CategoriesController inherits from UserController?? Cheers, Alexander -- Posted via http://www.ruby-forum.com/.
Alexander Seidl
2009-Oct-21 13:59 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
David Chelimsky wrote:> On Wed, Oct 21, 2009 at 7:19 AM, Alexander Seidl > <lists at ruby-forum.com>wrote: > >> http://pastie.org/663143. The test still failes. But it shouldn''t! >> > Rails version? > Ruby version? > OS? > etcHi David, alexanders at alexanders-desktop:$ gem list -l rspec *** LOCAL GEMS *** rspec (1.2.9) rspec-rails (1.2.9) alexanders at alexanders-desktop:$ -- Posted via http://www.ruby-forum.com/.
Alexander Seidl
2009-Oct-21 14:00 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
David Chelimsky wrote:> On Wed, Oct 21, 2009 at 7:19 AM, Alexander Seidl > <lists at ruby-forum.com>wrote: > >> http://pastie.org/663143. The test still failes. But it shouldn''t! >> > Rails version? > Ruby version? > OS? > etcSorry, forgot OS: alexanders at alexanders-desktop:$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 9.04 Release: 9.04 Codename: jaunty alexanders at alexanders-desktop:$ -- Posted via http://www.ruby-forum.com/.
Alexander Seidl
2009-Oct-21 14:02 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
David Chelimsky wrote:> On Wed, Oct 21, 2009 at 7:19 AM, Alexander Seidl > <lists at ruby-forum.com>wrote: > >> http://pastie.org/663143. The test still failes. But it shouldn''t! >> > Rails version? > Ruby version? > OS? > etc:( Really sorry for triple answer. But my mind is weakened by all this RAILS_GEM_VERSION = ''2.1.2'' -- Posted via http://www.ruby-forum.com/.
Alexander Seidl
2009-Oct-21 14:10 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
David Chelimsky wrote:> On Wed, Oct 21, 2009 at 7:19 AM, Alexander Seidl > <lists at ruby-forum.com>wrote: > >> http://pastie.org/663143. The test still failes. But it shouldn''t! >> > Rails version? > Ruby version? > OS? > etcBTW :) The second example with the message_controller is copied from your Book^^ Cheers, Alexander -- Posted via http://www.ruby-forum.com/.
Alexander Seidl
2009-Oct-21 15:17 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
Its definitly that line that causes trouble: class User::CategoriesController < UserController ^^^^^^^^^^^^^^^^^ ... end If i change it to: class User::CategoriesController < ActionController::Base ^^^^^^^^^^^^^^^^^^^^^^^ ... end the tests pass as expected. But why may i not inheret my CategoriesController from UserController? Do i have to change my code to make it testable? Cheers, Alexander -- Posted via http://www.ruby-forum.com/.
Pat Maddox
2009-Oct-21 15:28 UTC
[rspec-users] controller code doesn''t seem to be called within rspec test
On Wed, Oct 21, 2009 at 6:56 AM, Alexander Seidl <lists at ruby-forum.com> wrote:> I started a new test: Have a look at my new code: > http://pastie.org/663455 > > 1) The categories_controller is NOT called from the test! > > 2) I created another example with a message_controller and associated > tests. There, the controller IS called! > > You can see that, because the puts statement produces output in 2), but > not in 1). > > Could the reason for this be the fact, that User::CategoriesController > inherits from UserController??Paste UserController as well. If it has a before_filter in there that prevents index from executing, that could be the source of the problem. Pat