# Strange problem on "xhr" and "xml\_http\_request"

**URL:** <https://www.ruby-forum.com/t/strange-problem-on-xhr-and-xml-http-request/122177>\
**Category:** Rails\
**Created:** [December 5, 2007, 9:25am UTC](https://www.ruby-forum.com/t/strange-problem-on-xhr-and-xml-http-request/122177 "2007-12-05T09:25:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@jan](https://www.ruby-forum.com/u/jan)\
**Post date:** [December 5, 2007, 9:25am UTC](https://www.ruby-forum.com/t/strange-problem-on-xhr-and-xml-http-request/122177/1 "2007-12-05T09:25:34Z")

</div>

Hi,

I’m learning the integration test framework of rails, it’s definitely  
great! But when I tried to use xml\_http\_request’s alias xhr, test  
broken …

If I wrote

xml\_http\_request :post, “/store/add\_to\_cart”, :id =\> ruby\_book.id

everything’s ok, tests passed succesfully. After I change this line  
to

xhr :post, “/store/add\_to\_cart”, :id =\> ruby\_book.id

I get exceptions like this:

Loaded suite test/integration/user\_stories\_test  
Started  
E  
Finished in 1.203 seconds.

1. Error:  
test\_buying\_a\_product(UserStoriesTest):  
ArgumentError: wrong number of arguments (4 for 3)  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/  
action\_controller/integration.rb:508:in `post' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/ action_controller/integration.rb:508:in`send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/  
action\_controller/integration.rb:508:in `post' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/ action_controller/test_process.rb:391:in`send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/  
action\_controller/test\_process.rb:391:in `xhr' test/integration/user_stories_test.rb:22:in`test\_buying\_a\_product’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/  
action\_controller/integration.rb:463:in `run’

1 tests, 2 assertions, 0 failures, 1 errors

I don’t know why, xhr is just an alias of xml\_http\_request in the  
source, isn’t?

Thanks,  
Jan
