Posted by: khirakawa on: July 15, 2009
Being a newbie rails developer, there are a number of rails caveats that I wish I knew beforehand, such as this one:
Suppose I have a div with id = “test” and I have a controller function that removes the div using
page[:test].remove
Now suppose I have a functional test as such:
assert_select_rjs :remove, "test"
Well, it happens to be so that this test fails, even though all my other assert_select_rjs assertions succeed. Only when the first argument is :remove does the test fail.
Now I don’t know why this is (anybody want to enlighten me?), but I’ve found a workaround.
Instead of the the code above, do:
assert_equal @response.body, '$("test").remove();'
The assert_select_rjs function supposedly does a similar thing under the hood where it does a regex comparison on the response body.
And there you have it. Test success!
October 26, 2009 at 4:15 pm
you should use assert_select_rjs :chained_remove, “test” because you are using chained method or you can use in your controller page.remove “test”, or something similar.