RoR and RSpec: How to access controller instance variables without defining accessors?

Controller. Instance_variable_get(:var) if you find yourself doing this, you might want to rethink your approach to information hiding so that you are testing essential behavior rather than incidental implementation details. Your tests should ensure that the "thing" functions as it should without being too tightly bound to the particular implementation EDIT: Isn't assigns(:var) the rails testing magic for doing the same thing with controllers?

Controller. Instance_variable_get(:var) if you find yourself doing this, you might want to rethink your approach to information hiding so that you are testing essential behavior rather than incidental implementation details. Your tests should ensure that the "thing" functions as it should without being too tightly bound to the particular implementation.

EDIT: Isn't assigns(:var) the rails testing magic for doing the same thing with controllers?

Yeah probably you're right - I should test the results of the action instead of the implementation details. Thanks anyway. – j t Jul 16 '09 at 14:35 to be fair, for controllers, instance variables are things that should be tested.

I answered this question before coffee. – Ben Hughes Jul 16 '09 at 14:54 assigns(:var) is correct – codecraig Mar 29 at 17:54.

I'm writing a rspec tests for my controller and I cannot find solution following problem. For one of the edge case tests I need to verify the value of one instance variable. How can I access it without having to define the accessor?

I'm sure that there is a more inteligent way.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions