【发布时间】:2015-12-31 22:00:07
【问题描述】:
我有一个序列化字段,我想在 Rails 4 的功能测试中使用它。
Fixtures 将哈希值保存为字符串。
Step.rb
serialize :custom, ActiveRecord::Coders::NestedHstore
steps.yml
one:
name: Simple example.
custom:
name:
prompt: What is your name?
在step.custom 中,我想要哈希{name: {prompt: "What is your name?"}。相反,在测试中,我得到一个字符串以及错误:
undefined method `keys' for "{\"prompt\"=>\"What is your name?\"}":String
这当然会导致我的测试失败,因为我的代码库需要一个哈希。我试过<%= hash.to_yaml.inspect %>,但这似乎不起作用。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 functional-testing fixtures