>
> Hi guys firstly I would like to congratulate you on a great book I am
> enjoying learning Ruby on Rails Immensely thanks to your book, however
> I have hit a bit of a stumbling block which does not appear to be
> covered in the errata, running the integration test on page 116 gives
> me the following failure:
>
> 1) Failure:
> test_browsing_the_site(BrowsingAndSearchingTest)
> [/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/
> ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/assertions/
> response_assertions.rb:26:in `assert_response'
> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/
> ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/assertions/
> response_assertions.rb:18:in `assert_response'
> test/integration/browsing_and_searching_test.rb:19:in
> `browse_index'
> test/integration/browsing_and_searching_test.rb:8:in
> `test_browsing_the_site'
> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/
> ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
> integration.rb:453:in `run']:
> Expected response to be a <:success>, but was <500>
This means that the action the test is trying to run is bombing. Can
you open up log/test.log and see the actual error that causes the 500?
Since you seem to be on OS X, you can open the log file in Console.app
and run the test again to easily see what's going on.
Cheers,
//jarkko
>
>
> I have double checked all my code against the book and then double
> checked it all against the downloadable sample code on the errata yet
> i still get this problem I have tried looking into it but as I am
> still quite new to RoR I'm not 100% on what i should be looking for, I
> was wondering if there was an error in the book which is making this
> test not pass.
>
> I look forward to your reply
>
> Lee
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "Beginning Ruby on Rails E-Commerce" group.
> To post to this group, send email to railsec...@googlegroups.com
> To unsubscribe from this group, send email to railsecommerc...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/railsecommerce?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
>
> Thanks for the quick reply I'm working on a bit of both OS X at work
> and Windows XP at home so how would I go about doing this on my home
> pc??
The log file is just a text file so you can always open it up in a
text editor afterwards. However, I don't know about a log tailing
application like Console or tail on Windows. Anyone?
//jarkko
Can you paste a bit more of the log? The browse_index tries to fetch
an action which should show a normal log entry. Something like this:
Processing EventsController#index (for 127.0.0.1 at 2008-05-13
15:46:00) [GET]
...and a bunch of lines more. Your original error indicated that the
actual action (i.e. not the test code) was throwing an exception, so
the log file should contain a line for calling the action (like
above), and then something resulting in an exception. Do you see
anything like that?
Cheers,
//jarkko
>
> this should be of more help i've uploaded a copy of the test log for
> you to go through :)
>
> http://www.unborndesigns.co.uk/test.log
>
> thanks for your help so far :)
This is the interesting part:
ActionView::TemplateError (can't convert nil into Float) on line #8 of
app/views/catalog/index.rhtml:
5: <dd><%= author.last_name %>, <%= author.first_name %></dd>
6: <% end %>
7: <dd><%= pluralize(book.page_count, "page") %></dd>
8: <dd>Price: $<%= sprintf("%.2f", book.price) %></dd>
9: <dd><small>Publisher: <%= book.publisher.name %></small></dd>
10: <% end %>
11: </dl>
#{RAILS_ROOT}/app/views/catalog/index.rhtml:8:in `sprintf'
Like the error says, the price of the book is nil and it can't be
converted into a float. Either all the books should have a price set,
or there should be a check for it in the code:
<dd>Price: $<%= sprintf("%.2f", book.price) unless book.price.blank?
%></dd>
Or something like that.
If you want the price to be mandatory, use
validates_presence_of ;price in the Book model. I think that's in the
book but don't remember off the top of my head.
//jarkko
>
>
> Lee
>
The count is probably just off, try changing that to match the actual
amount of books and you should be fine.
//jarkko
> div>\r\n\r\n<div id=\"footer\">\r\n © 1995-2006 Emporium\r\n</
> div>
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
>>>>>> integration.rb:453:in `run'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/testsuite.rb:34:in `run'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/testsuite.rb:33:in `each'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/testsuite.rb:33:in `run'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/testsuite.rb:34:in `run'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/testsuite.rb:33:in `each'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/testsuite.rb:33:in `run'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/ui/console/testrunner.rb:67:in
>>>>>> `start_mediator'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/ui/console/testrunner.rb:41:in `start'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in `run'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/autorunner.rb:216:in `run'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>>>>>> ruby/1.8/test/unit/autorunner.rb:12:in `run'
>>>>>> /Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/
>>>>>> lib/
>
> thanks very much I've amended the count and now it seems to be these
> two lines of hte test that are causing the failure:
>
> assert_tag :tag => "dt", :content => "The Idiot"
> check_book_links
>
> I'm wondering if this i because none of the books defined in the
> fixutres have any "content" specified?
No, content refers to the content of the tag, so it's looking for
<dt>The Idiot</dt>, and there is seemingly not such a book.