Rails 3.1 invalid multibyte char (UTF-8)
I'm trying to pass this simple assertion
assert_select '.price', /\€[,\d]+\.\d\d/
In the view the code for the .price class is
<span class="price">
<%= number_to_currency(product.price, options = {:format => "%u%n", :unit => "€"}) %> </span>
When I'm using th开发者_JAVA百科e default <%= number_to_currency(product.price) %>
everything's just fine. When I switch to the Euro it just wont work.
This is the error message:
/Users/noapologize/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require': /Users/noapologize/rails_projects/depot/test/functional/store_controller_test.rb:11: invalid multibyte char (UTF-8) (SyntaxError)
/Users/noapologize/rails_projects/depot/test/functional/store_controller_test.rb:11: invalid multibyte char (UTF-8)
/Users/noapologize/rails_projects/depot/test/functional/store_controller_test.rb:11: syntax error, unexpected $end, expecting keyword_end
assert_select '.price', /\€[,\d]+\.\d\d/
I suppose the way I'm writing this assert_select is wrong. Could someone enlighten me?
Thank you for your time.
If you remove the escape slash from the Euro sign this regexp will compile properly and work.
精彩评论