Created
January 3, 2012 15:51
-
-
Save karledurante/1555451 to your computer and use it in GitHub Desktop.
Rails 3 Functional Test: assert_select finds nothing on XHR requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setup do | |
xhr :post, :summarize | |
end | |
should "find a tag" do | |
# FAILS in Rails3, SUCCEEDS in Rails2 | |
assert_select :span, :text => "some content" | |
# SUCCEEDS in Rails3 & Rails2 | |
assert_match /\<span\>some content<\/span\>/, @response.body | |
end |
Yeah, I'm using assert_match for now. Honestly, I don't like functional tests that expect certain tags to be in place, especially something as generic as span. I think just matching the content is sufficient.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
assert_select
will look at the Content-Type before actually testing. If it seesxhr/js
, it will assume the response isrjs
. That being said, I don't have a solution. I supposed you could extract the regexs fromassert_select
and write a test helper on your own?