[rspec-users] Specs for Ajax partials with unicode characters
work at ashleymoran.me.uk
Mon Feb 12 09:43:23 EST 2007
Not sure if this is more Rails or RSpec related...
I've got an app with an RJS view that updates a div in a page with
the contents of a partial. The partial contains a non-ascii
character namely a pound sign.
I set up a simple test app with this RJS view:
page.replace_html("test_div", :partial => "test_action")
and this _test_action.rhtml:
Now this spec fails:
require File.dirname(__FILE__) + '/../../spec_helper'
context "Given a request to render view_test/test_action" do
specify "the response should have a p with £500" do
response.should_have_tag 'p', :content => '£500'
specify "the response should definitely have a p with £500" do
response.should_have 'p', :text => '£500'
The error for the should_have_tag gives this error message:
Element.update("test_div", "<p>\u00a3500</p>"); should include
of our developers that the replacement string is in JSON format.
Either way the only way to make the specs pass is to use :content
(or :text) => '\u00a3500' which is completely different from the
contents of the partial, so not a brilliant solution. An alternative
is to use £ for £, but that kinda defeats the point of using UTF8.
Any ideas how I can get round this?
More information about the rspec-users