Rspec: Is there a problem with rspec-rails when initializing a controller class with super(args)?

If you call super(args) you're passing in a single argument - the array referenced by args Using the splat operator super(*args) turns the array in to a list and passes along each element of args as an individual argument As Wayne has pointed out, there's also a little syntactic sugar in Ruby that lets you just say super and it will automatically pass on the arguments for you, treating it like super(*args) instead of just super() In your particular case, I would guess that your Controller's superclass's initialize method doesn't accept an array, so when RSpec tried to instantiate your Controller it failed, which ultimately resulted in the error message you saw.

If you call super(args), you're passing in a single argument - the array referenced by args. Using the "splat operator" - super(*args) - turns the array in to a list and passes along each element of args as an individual argument. As Wayne has pointed out, there's also a little syntactic sugar in Ruby that lets you just say super and it will automatically pass on the arguments for you, treating it like super(*args) instead of just super().

In your particular case, I would guess that your Controller's superclass's initialize method doesn't accept an array, so when RSpec tried to instantiate your Controller it failed, which ultimately resulted in the error message you saw.

Thanks John. Have a good one! – btelles Feb 2 '10 at 19:42.

Doh! Figured it out... The initialize method had "super(args)" instead of "super(*args)" If anyone wants to rewrite this answer and give a full explanation, (or perhaps explain why I should not define an instance variable in that manner) I'll be happy to up-vote and give you the accepted answer. Bernie.

1 super(*args) is fine when the subclass's initialize doesn't care about the arguments except to pass them along to the superclass initialize. Did you know you can just say "super" and Ruby will automatically pass on all of the arguments? To call the superclass method with no arguments, you'd have to say "super()".

– Wayne Conrad Feb 1 '10 at 19:59 Cool, I didn't know that. Thanks! – btelles Feb 2 '10 at 1:24.

I've been using Rspec for a while and for some reason am receiving errors on a controller called ReferencesController. But I get an error for both! Any Idea what could be going on wrong?

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