# Ruby on rails ecommerce tests are failing, but why?

**URL:** <https://www.ruby-forum.com/t/ruby-on-rails-ecommerce-tests-are-failing-but-why/78262>\
**Category:** Rails\
**Created:** [December 4, 2006, 4:45pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-ecommerce-tests-are-failing-but-why/78262 "2006-12-04T16:45:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [December 4, 2006, 4:45pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-ecommerce-tests-are-failing-but-why/78262/1 "2006-12-04T16:45:35Z")

</div>

i am working through the Beginning Ruby on Rails Ecommerce book and on  
page 101 where it is talking about integration tests, i run  
test/integration/book\_test.rb and it fails giving me the following  
error message:

1. Failure:  
test\_book\_administration(BookTest)  
[test/integration/book\_test.rb:45:in `add_book' test/integration/book_test.rb:11:in`test\_book\_administration’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/integration.rb:431:in  
`run’]:  
expected tag, but no tag found matching {:content=\>“Ruby for Dummies”,  
:tag=\>“td”} in:  
“\n\<html  
xmlsn=“http://www.w3.org/1999/xhtml”\>\n\t\n\t\tEmporium\n\t\t\<link  
href=”/stylesheets/style.css?1164206463" media=“screen”  
rel=“Stylesheet” type=“text/css” /\>\n\t\n\t\n\t\t\<div  
id=“header”\>\n\t\t\t\<h1 id=“logo”\>Emporium™\n\t\t\t\<h2  
id=“slogan”\>Books on Rails\n\t\t\n\n\t\t\<div  
id=“menu”\>\n\t\t\t
\n\t\t\t\t - \<a  
href="/admin/author"\>Authors&nbsp;|&nbsp;
\n\t\t\t\t - \<a  
href="/admin/publisher"\>Publishers&nbsp;|&nbsp;
\n\t\t\t\t - \<a  
href="/admin/book"\>Books&nbsp;|&nbsp;
\n\t\t\t\t - \<a  
href="/"\>Catalog&nbsp;|&nbsp;
\n\t\t\t\t - \<a  
href="/about"\>About&nbsp;
\n\t\t\t
\n\t\t\n\n\t\t\<div  
id=“content”\>\n\t\t\t\n\t\t\t\n\t\t\t\t\<div  
id=“notice”\>\n\t\t\t\tBook was successfully  
created.\n\t\t\t\t\n\t\t\t\n\t\t\t
# Listing books
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n

| Title | Published at | Isbn | Blurb | Price | Created at | Updated at |
| --- | --- | --- | --- | --- | --- | --- |
| Ruby for Dummies | Mon Dec 04 09:27:30 CST 2006 | 123-123-123-X | The best book released since "Eating for Dummies" | 40.4 | Mon Dec 04 09:27:30 CST 2006 | Mon Dec 04 09:27:30 CST 2006 | Show | Edit | Destroy |

\n\n\n \n\n  
\n\nNew book\n\n\t\t\n\n\t\t
© 1995-2006 Emporium
\n\t\n\n". is not true.

looking through the code, i clearly see that “Ruby for Dummies” is in  
fact in there and I also see that it is wrapped inside of “td” html  
tags… so why is this test failing? i thought there might have been a  
typo in my code somewhere, so i downloaded the sample code from the  
site and i still got the same error message.

i’m new to TDD so i’m not really sure where to start troubleshooting  
this

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [December 4, 2006, 5:13pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-ecommerce-tests-are-failing-but-why/78262/2 "2006-12-04T17:13:41Z")

</div>

The assert\_tag is broken in Rails, you must edit the

vendor/rails/actionpack/lib/action\_controller/test\_process.rb file and  
change the implementation of html\_document as follows:

def html\_document  
@html\_document ||= HTML::Document.new(@response.body)  
HTML::Document.new(@response.body)  
end

From Mark Lund’s website:  
[http://wiki.marklunds.com/index.php?title=Test\_Driven\_Development\_with\_Ruby](http://wiki.marklunds.com/index.php?title=Test_Driven_Development_with_Ruby)

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [December 4, 2006, 5:17pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-ecommerce-tests-are-failing-but-why/78262/3 "2006-12-04T17:17:44Z")

</div>

Bala P. wrote:

> The assert\_tag is broken in Rails, you must edit the
> 
> vendor/rails/actionpack/lib/action\_controller/test\_process.rb file and  
> change the implementation of html\_document as follows:
> 
> def html\_document  
> @html\_document ||= HTML::Document.new(@response.body)  
> HTML::Document.new(@response.body)  
> end
> 
> From Mark Lund’s website:  
> [http://wiki.marklunds.com/index.php?title=Test\_Driven\_Development\_with\_Ruby](http://wiki.marklunds.com/index.php?title=Test_Driven_Development_with_Ruby)

Actually, the patch removes the @html line. it should read

```
 def html_document
     HTML::Document.new(@response.body)
 end

```

[http://wiki.marklunds.com/index.php?title=Test\_Driven\_Development\_with\_Ruby#Integration\_tests](http://wiki.marklunds.com/index.php?title=Test_Driven_Development_with_Ruby#Integration_tests)

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [December 4, 2006, 7:10pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-ecommerce-tests-are-failing-but-why/78262/4 "2006-12-04T19:10:01Z")

</div>

Oops, my bad. Overlooked the - and + there. Try the fix for 1.1.6 and  
see if  
it works. If it does not you can always revert back to the old code.

The latest version has deprecated the assert\_tag, assert\_select is the  
replacement. So I don’t think that fix is for latest version.

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [December 4, 2006, 5:31pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-ecommerce-tests-are-failing-but-why/78262/5 "2006-12-04T17:31:44Z")

</div>

Is this for the latest version of rails though? i’m not running edge  
or anything, just 1.1.6
