[rspec-users] mock_model named spaces not working

Luis Lavena luislavena at gmail.com
Sat Sep 29 02:06:49 EDT 2007


On 9/29/07, Andrew WC Brown <omen.king at gmail.com> wrote:
> I have a namespace called saltmines
>
> The following will fail the spec
>
> @player = mock_model(Saltmines::Player)
>
> 1)
> ActionView::TemplateError in '/saltmines/players/index.rhtml should render
> list of saltmines/players'
> You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.each
> On line #9 of app/views/saltmines/players/index.rhtml
>
>     6:     <th>Player</th>
>     7:   </tr>
>     8:
>     9: <% for player in @players %>
>
>
> My application works but these specs fail. How do I get them to pass?
>

you're mocking @player and not a collection/array of players.

maybe:

@players = [mock_model(Saltmines::Player), mock_model(Saltmines::Player)]

Could work for you?

The whole spec will be helpful, since we don't have the setup (before)
or the whole context.

HTH,

-- 
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi


More information about the rspec-users mailing list