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 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?
Alexander S. 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.
2009/10/21 Alexander S. [email protected]
Alexander S. 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
hi ben,
no impact, same result.
cheers,
Alexander
On Wed, Oct 21, 2009 at 6:12 AM, Alexander S.
[email protected]wrote:
hi ben,
no impact, same result.cheers,
Alexander
Please 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?
On Wed, Oct 21, 2009 at 7:19 AM, Alexander S.
[email protected]wrote:
http://pastie.org/663143. The test still failes. But it shouldn’t!
Rails version?
Ruby version?
OS?
etc
David C. 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.
David C. wrote:
On Wed, Oct 21, 2009 at 7:19 AM, Alexander S.
[email protected]wrote:http://pastie.org/663143. The test still failes. But it shouldn’t!
Rails version?
Ruby version?
OS?
etc
Hi David,
alexanders@alexanders-desktop:$ gem list -l rspec
*** LOCAL GEMS ***
rspec (1.2.9)
rspec-rails (1.2.9)
alexanders@alexanders-desktop:$
I started a new test: Have a look at my new code:
http://pastie.org/663455
The categories_controller is NOT called from the test!
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
David C. wrote:
On Wed, Oct 21, 2009 at 7:19 AM, Alexander S.
[email protected]wrote:http://pastie.org/663143. The test still failes. But it shouldn’t!
Rails version?
Ruby version?
OS?
etc
Sorry,
forgot OS:
alexanders@alexanders-desktop:$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.04
Release: 9.04
Codename: jaunty
alexanders@alexanders-desktop:$
David C. wrote:
On Wed, Oct 21, 2009 at 7:19 AM, Alexander S.
[email protected]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’
David C. wrote:
On Wed, Oct 21, 2009 at 7:19 AM, Alexander S.
[email protected]wrote:http://pastie.org/663143. The test still failes. But it shouldn’t!
Rails version?
Ruby version?
OS?
etc
BTW
The second example with the message_controller is copied from your
Book^^
Cheers,
Alexander
On Wed, Oct 21, 2009 at 6:56 AM, Alexander S. [email protected]
wrote:
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
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs