I'm trying to work through Patrick Lenz' book. And am getting stuck on the functional tests. I am running Instant Rails 2.0. I have run into one difference from the book, which was to do with scaffolding, but since the book was only using it for a quick demonstration, then building views directly, I didn't worry about it.
I built the view and controller the way the book said, ran the unit tests, which all worked perfectly. The differences between my skeleton functional test file and the books were pretty significant. I first tried making the book edits based on the generated skeleton (assuming the 2.0 changes were important) I tried running the rake test: functionals and got a bunch of errors, so I went back and used the book story_controller_test.rb. I've checked everything as much as I could.
When I run the functional tests, I get an error that says
It shows the only two lines of code in my index.html.erb file which are as follows:
1) Error: test_should_show_index(StoryControllerTest):
ActionView::TemplateError: You have a nil object when you didn't expect it!
The error occured while evaluating nil.name
On line #2 of story/index.html.erb
It then spits out 30-40 lines of ruby/libs/ruby/gems/1.8/gems/* all kinds of problems.
A random link:
<%= link_to @story.name, @story.link %>
Any ideas? Are their any global changes that need to be done to accomodate the book to 2.0? I am new to Ruby (hence the book) and assume that any references to .rhtml are now to be changed to .html.erb.
Here is my story_controller_test.rb file
Please let me know if there is more info that you need to give me any guidance. Happy Mother's Day everyone.
require File.dirname(__FILE__) + '/../test_helper'
# Re-raise errors caught by the controller
class StoryController; def rescue_action(e) raise e end; end
class StoryControllerTest < Test::Unit::TestCase
@controller = StoryController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new