【发布时间】:2011-05-19 21:23:22
【问题描述】:
当我在我的控制器中分配时
@my_hash = { :my_key => :my_value }
并通过以下方式测试该控制器
get 'index'
assigns(:my_hash).should == { :my_key => :my_value }
然后我收到以下错误消息:
expected: {:my_key=>:my_value},
got: {"my_key"=>:my_value} (using ==)
为什么会发生这种从符号到字符串的自动转换?为什么会影响hash的key?
【问题讨论】:
-
你真的应该设置你的 Gravatar,因为你的用户名很棒。
标签: ruby-on-rails unit-testing testing rspec rspec2