I outputted name and enabled to see if it the mock object was working.
before do
game = mock_model(Game, :name => ‘The Battle for Blaze’, :enabled =>
‘true’)
puts game.name
puts game.enabled
game.should_receive(:name).and_return(‘The Battle for Blaze’)
game.should_receive(:enabled).and_return(‘true’)
@game = game
end
I still got the error but I saw in the print out ‘The Battle for Blaze’
and
‘True’
So I for some reason thought that if I write unknowingly in my partial
<%= h game.enabled %> it might pass and it did.
I was thinking that game.should_recieve was test that the mock model
being
made received Battle for the Blaze like I was confirming that the the
model
was correct.
But then I looked at the code and really thought about it and realized
that
what it was saying that the Game model was expecting name to be called
at
some point during that spec and since it hadn’t been in the partial such
as
game.name then it would fail.
When I’m working with RSpec I sometimes forget what actually is going on
and
I interpret how things are happening in a different way.
For that pragmatic book will it cover things such as:
how to spec a rendered template
how to spec a rendered partial
how to spec a rendered partial collection
how to spec a cookie
…
or will it be more of a guide like the RSpec Peepcode videos but in book
format with more elaboration.
I don’t think I would have ever spec’d view if I hadn’t started using
story
runner.
I love that story runner.
On 10/5/07, David C. [email protected] wrote:
game.should_receive(:enabled).and_return(‘true’)
./spec/views/games/_game.rhtml_spec.rb:19:
require File.dirname(FILE) + ‘/…/…/spec_helper’
:created_at => “Mon Oct 01 00:02:44 -0400 2007”,
@game = game
I cut out most of my specs just to spec the partial.
block was:
game.should_receive(:name).and_return('The Battle for Blaze')
end
I’d need to see the full listing of both spec and code as they are
suppose to come after the render but:
which maybe I have to state:
game
multiple
:people => 5000000,
game_1.should_receive(:salt_grains).and_return(5000000)
response.should have_text(/The Battle for Blaze/)
I think the local variable is showing up nil because my
NoMethodError in '/games/_game.rhtml should show game
game.should_receive(:name).and_return("The Battle
00:02:44
[email protected]
rspec-users mailing list
putting small businesses on-line
Andrew WC Brown
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
–
Monsterbox Productions
putting small businesses on-line
1319 Victoria Avenue East
Thunder Bay, Ontario P7C 1C3
Canada
Andrew WC Brown
web-developer and owner
[email protected]
P: 807-626-9009
F: 807-624-2705