# Beginning Ruby on Rails E-Commerce : Errata Help

**URL:** <https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538>\
**Category:** Rails\
**Created:** [November 20, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538 "2006-11-20T14:45:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [November 20, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538/1 "2006-11-20T14:45:48Z")

</div>

Page 94, chapter 3, running $ ruby test/integration/book\_test.rb  
gives:

Expected response to be a \<:redirect\>, but was \<500\>

Does anyone know how to fix this problem? TIA.

---

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [December 2, 2006, 12:57pm UTC](https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538/2 "2006-12-02T12:57:13Z")

</div>

Anyone figure this out? I get:  
Expected response to be a \<:redirect\>, but was \<200\>

n.

Bala P. wrote:

> Page 94, chapter 3, running $ ruby test/integration/book\_test.rb  
> gives:
> 
> Expected response to be a \<:redirect\>, but was \<500\>
> 
> Does anyone know how to fix this problem? TIA.

---

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [December 2, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538/3 "2006-12-02T22:32:31Z")

</div>

Following table might help:

```
* :success (status code is 200)
* :redirect (status code is within 300..399)
* :missing (status code is 404)
* :error (status code is within 500..599)
* any number (to specifically reference a particular status code)

```

assert\_response :success # page rendered ok  
assert\_response :redirect # we’ve been redirected  
assert\_response :missing # not found  
assert\_response 505 # status code was 505

For more check out: [Peak Obsession](http://manuals.rubyonrails.com/read/chapter/28)

You may also want to use curl on the command line to see the response  
from the server. It also helps to write assert\_tag and other  
assertions.

---

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [December 3, 2006, 12:05pm UTC](https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538/4 "2006-12-03T12:05:40Z")

</div>

Finally solved this mystery -

The first problem was that the newly created book wasn’t being saved, so  
the ‘new’ page was being displayed instead of ‘create’. The cause of  
this was the date. When I changed

:published\_at =\> Time.now

to

:published\_at =\> ‘2006-11-01’

then things were saved correctly and we ended up on the correct page.

Next problem was that assert\_tag wasn’t passing, even though I could see  
the new book in the raw html. On  
[http://wiki.marklunds.com/index.php?title=Test\_Driven\_Development\_with\_Ruby](http://wiki.marklunds.com/index.php?title=Test_Driven_Development_with_Ruby)  
I found that assert\_tag doesn’t work with integration tests unless you  
make this change in test\_process.rb

```
 def html_document

```

- 

```
 @html_document ||= HTML::Document.new(@response.body)

```

- 

```
 HTML::Document.new(@response.body)

```

end

Once I changed that then the integration test passed no problem.

Nick.

Bala P. wrote:

> Following table might help:
> 
> ```
> * :success (status code is 200)
> * :redirect (status code is within 300..399)
> * :missing (status code is 404)
> * :error (status code is within 500..599)
> * any number (to specifically reference a particular status code)
> 
> ```
> 
> assert\_response :success # page rendered ok  
> assert\_response :redirect # we’ve been redirected  
> assert\_response :missing # not found  
> assert\_response 505 # status code was 505
> 
> For more check out: [Peak Obsession](http://manuals.rubyonrails.com/read/chapter/28)
> 
> You may also want to use curl on the command line to see the response  
> from the server. It also helps to write assert\_tag and other  
> assertions.

---

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [December 3, 2006, 6:55pm UTC](https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538/5 "2006-12-03T18:55:06Z")

</div>

Cool. That solves the problem that I was having with my project. I  
will try it out.

I was baffled, when I do curl I see the right page but when I do  
assert\_tag it bombs out!

---

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [December 4, 2006, 4:34am UTC](https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538/6 "2006-12-04T04:34:16Z")

</div>

On page 77, there is a test\_destroy method that fails on assert\_tag

assert\_tag :tag =\> ‘div’,  
:attributes =\> {:id =\> ‘notice’},  
:content =\> ‘Successfully deleted author Joel Spolsky’

I am on Rails 1.2 and the assert\_tag has been deprecated. The test was  
failing so I used assert\_select tag:

assert\_select “div#notice”, ‘Successfully deleted author Joel Spolsky’

---

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [December 3, 2006, 7:11pm UTC](https://www.ruby-forum.com/t/beginning-ruby-on-rails-e-commerce-errata-help/76538/7 "2006-12-03T19:11:42Z")

</div>

Bala P. wrote:

> I was baffled, when I do curl I see the right page but when I do  
> assert\_tag it bombs out!

I used tail -f log/test.log to see exactly what was happening in there.

n.
