# Strange testing situation

**URL:** <https://www.ruby-forum.com/t/strange-testing-situation/125513>\
**Category:** Rails\
**Created:** [January 9, 2008, 9:29pm UTC](https://www.ruby-forum.com/t/strange-testing-situation/125513 "2008-01-09T21:29:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [January 9, 2008, 9:29pm UTC](https://www.ruby-forum.com/t/strange-testing-situation/125513/1 "2008-01-09T21:29:13Z")

</div>

I have a number of functional tests that check the response that was  
created by the JavaScriptGenerator for some redirects. ie:

render :update do |page|  
page.redirect\_to comment\_path(@comment)  
end

The tests’ assertions look like this:

@javascript = @response.body  
assert\_equal “window.location.href = “#{comment\_path(@comment)}”;”,  
@javascript

This is fine except that when I run ‘rake test’, I get failures stating  
that:

\<“window.location.href = “/comments/1”;”\> expected but was  
\<“window.location.href = “\/comments\/1”;”\>.

But when I run only the specific Comments functional test (‘ruby  
test/functional/comments\_controller\_test.rb’), no failures show up. Why  
would ‘rake test’ escape these javascript strings differently? How can  
I make it so that both the ‘rake test’ and ‘ruby  
test/functional/comments\_controller\_test.rb’ pass?

Thanks

---

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [January 9, 2008, 10:32pm UTC](https://www.ruby-forum.com/t/strange-testing-situation/125513/2 "2008-01-09T22:32:25Z")

</div>

Check out the ARTS plugin  
[http://glu.ttono.us/articles/2006/05/29/guide-test-driven-rjs-with-arts](http://glu.ttono.us/articles/2006/05/29/guide-test-driven-rjs-with-arts)

assert\_rjs :redirect\_to, …

Makes it much easier to test the simple RJS.

Jason
