我正试图通过这个简单的断言
assert_select '.price', /\€[,\d]+\.\d\d/
在视图中,.price类的代码是
<span class="price">
<%= number_to_currency(product.price, options = {:format => "%u%n", :unit => "€"}) %> </span>
当我使用默认的<%= number_to_currency(product.price) %>
时,一切都很好。当我切换到欧元时它就不会工作了。
这是错误消息:
/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/
我想我写这个assert_select的方式是错误的。有人可以启发我吗?
感谢您的时间。
答案 0 :(得分:2)
如果从欧元符号中删除转义斜杠,则此正则表达式将正确编译并正常工作。