# String escape sequences in Test environment

**URL:** <https://www.ruby-forum.com/t/string-escape-sequences-in-test-environment/134153>\
**Category:** Rails\
**Created:** [April 8, 2008, 11:56am UTC](https://www.ruby-forum.com/t/string-escape-sequences-in-test-environment/134153 "2008-04-08T11:56:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Myron\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Myron\_M](https://www.ruby-forum.com/u/Myron_M)\
**Post date:** [April 8, 2008, 11:56am UTC](https://www.ruby-forum.com/t/string-escape-sequences-in-test-environment/134153/1 "2008-04-08T11:56:30Z")

</div>

I’m attempting to use the assert valid markup plugin (http://  
[redgreenblu.com/svn/projects/assert\_valid\_markup/](http://redgreenblu.com/svn/projects/assert_valid_markup/)) but I’m having a  
really strange issue with the way my strings are handled in the test  
environment.

I’ve got some html fragments stored in the database that get retrieved  
and shown on certain pages (as just about every rails app does, I  
expect). These html fragments are indexed by a unique name in a table  
named page\_html\_parts. My code to retrieve them is like this:

part = PageHtmlPart.find(:first, :conditions =\> [“name = ?”, name])

When validating my xhtml using the plugin in test mode, I get extra  
escape sequences in the html returned by my PageHtmlPart object. For  
example, the quotes around the URLs in my anchor tags get changed to  
" (i.e. the ruby escape sequence for a double quote within a double-  
quoted string). In turn, the extra slash gets inserted into my xhtml  
that gets passed on the W3C validator, and consequently my validation  
fails.

In development and production mode, this works fine. I’ve set a  
breakpoint and inspected the results I’m getting here, and in these  
modes there are no escape sequences. My XHTML is valid.

Does the Rails test environment treat strings differently form the  
production and development environments? Does anyone know how to fix  
this?

Thanks,  
Myron
