# Functional test and flash with an error

**URL:** <https://www.ruby-forum.com/t/functional-test-and-flash-with-an-error/89802>\
**Category:** Rails\
**Created:** [March 22, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/functional-test-and-flash-with-an-error/89802 "2007-03-22T20:57:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![solidariti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@solidariti](https://www.ruby-forum.com/u/solidariti)\
**Post date:** [March 22, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/functional-test-and-flash-with-an-error/89802/1 "2007-03-22T20:57:18Z")

</div>

I’m getting this error thats moaning about expected tag, but no tag  
found matching {:content=\>“User James Apps was successfully created.”,  
:attributes=\>{:id=\>“notice”}, :tag=\>“div”} in the file application.rb.

I tried using a regular expression - /#{user.first\_name}/ , but that  
wouldn’t work either

user\_controller\_test.rb

1. Failure:  
test\_create(Admin::UserControllerTest)  
[/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action\_controller/assertions/tag\_assertions.rb:102:in  
`assert_tag' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/assertions/tag_assertions.rb:99:in `clean\_backtrace’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action\_controller/assertions/tag\_assertions.rb:99:in  
`assert_tag' test/functional/admin/user_controller_test.rb:49:in `test\_create’  
test/functional/admin/user\_controller\_test.rb:40:in  
`assert_difference' test/functional/admin/user_controller_test.rb:40:in `test\_create’]:  
expected tag, but no tag found matching {:content=\>“User James Apps was  
successfully created.”, :attributes=\>{:id=\>“notice”}, :tag=\>“div”} in:  
“\n\<html  
xmlns="[http://www.w3.org/1999/xhtml\](http://www.w3.org/1999/xhtml%5C)”\>\n\n\<meta  
http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"  
/\>\nView Users\n\<link  
href="/stylesheets/dissertation.css?1174589813" media="screen"  
rel="Stylesheet" type="text/css" /\>\n\n\n\n\<div  
id="header"\>\n\t\<div id="metaNav"\>\n\t \<ul id="nav1"\>\n\t

- User
\n\t - Sign Out
\n\t - Date
\n\t \n\t \n\t
# View Users
 
\n 
\n- Projects
\n - Settings
\n - Contacts
\n
\n 
\n\n
\n
\n\t\t\t
\n\t\t\t\t\t
\n\t
# View Users
\n

From here you can view the users in the system.

\n\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n

| Name | Edit | Delete |
| --- | --- | --- |
| James Apps | Edit | 

\n |
| Mark Faulkner | Edit | 

\n |
| Andy Jardine | Edit | 

\n |
| James Apps | Edit | 

\n |

\n\n

Add a User

\n
\n\t\n
\n\t
\n\t\t\t
## News
\t\n\t\t\t

Test, Test, Test, Test

\n\t
\n\t\t\t\n\t
\n\t
## Projects
\n\t\t
\n\t\t - \n\t\t 
- \n\t\t
- \n\t\t

\n\t
\n\t\t\n 
\n\t \n\t
\n
\n
\n\n". is not true.

user\_controller.rb

1. def create
2. 

```
# Created a user object rom the request parameters sent from

```

the form on the new page.  
3. @user = User.new(params[:user])  
4. if @user.save  
5. # If user is valid then save and create a flash message then  
redirect to a page that lists the users  
6. flash[:notice] = “User #{@user.name} was successfully  
created.”  
7. redirect\_to :action =\> ‘index’  
8. else  
9. # If user couldn’t be saved (due to failing the validations)  
then the new page is rendered again.  
10. @page\_title = ‘Create new user’  
11. render :action =\> ‘new’  
12. end  
13. end

application.rb

1. \<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

“[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)”\>  
2.   
3.   
4.   
5. \<%= @page\_title || ‘Dissertation’ -%\>  
6. \<%= stylesheet\_link\_tag “dissertation” %\>  
7.   
8.  
9.   
10.

  
11. 
  
12. 
  
13. - User
  
14. - Sign Out
  
15. - Date
  
16. 
  
17. 
  
18. \<%= “
# #{@page\_title}
” if @page\_title -%\>  
19. 
  
20. 
  
21. - Projects
  
22. - Settings
  
23. - Contacts
  
24. 
  
25. 
  
26. 
  
27. 
  
28. 
  
29. \<% if flash[:notice] -%\>  
30. 
  
31. \<% flash[:notice] -%\>  
32. 
  
33. \<% end -%\>  
34. \<%= yield -%\>  
35.  
36. 
  
37.  
38. 
  
39. 
  
40. 
## News
  
41. 

Test, Test, Test, Test

  
42. 
  
43.  
44. 
  
45. 
## Projects
  
46. 
  
47. -   
48. 
-   
49. 
-   
50. 

  
51. 
  
52.  
53. 
  
54.  
55. 
  
56. 
  
57. 
  
58.   
59.

---

<div class="post-metadata">

**Author:** ![solidariti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@solidariti](https://www.ruby-forum.com/u/solidariti)\
**Post date:** [March 23, 2007, 1:07pm UTC](https://www.ruby-forum.com/t/functional-test-and-flash-with-an-error/89802/2 "2007-03-23T13:07:31Z")

</div>

On 22 Mar 2007, at 19:57, Solidariti wrote:

> I’m getting this error thats moaning about expected tag, but no tag  
> found matching {:content=\>“User James Apps was successfully created.”,  
> :attributes=\>{:id=\>“notice”}, :tag=\>“div”} in the file application.rb.
> 
> I tried using a regular expression - /#{user.first\_name}/ , but that  
> wouldn’t work either

Please post the actual assert statement that is tripping up. You’ve  
given us everything but the test itself!

Regards,  
Andy S.
