在Rails 4升级后,factory_girl导致RSpec规范失败

时间:2014-06-21 22:41:40

标签: ruby-on-rails ruby ruby-on-rails-4 rspec factory-bot

我刚刚将我的应用程序升级到Rails 4,而且我的一些RSpec规格现在都失败了,都是以同样的方式。

SQL (82.3ms)  INSERT INTO "profiles" ("career_goal", "created_at", "email", "encrypted_password", "first_name", "gpa", "grad_year", "hidden", "keywords", "kind", "last_name", "major_names", "middle_name", "minor_names", "phone", "id", "research_interest", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)  [["career_goal", ["Illum et sunt.", "Illo sapiente nesciunt reiciendis nulla fugit est autem."]], ["created_at", Sat, 21 Jun 2014 15:12:40 PDT -07:00], ["email", "madonna@huels.name"], ["encrypted_password", "$2a$10$y1zijhGouDy1OT4qHGnXR./FvXP9T7DHHvu4BofAt5ZBJrqjFisty"], ["first_name", "Jayde"], ["gpa", #<BigDecimal:e684850,'0.25E1',18(36)>], ["grad_year", 2013], ["hidden", false], ["keywords", "Daisha Ea placeat debitis repellendus autem ad voluptas. Illum et sunt. Illo sapiente nesciunt reiciendis nulla fugit est autem.   "], ["kind", "student"], ["last_name", "Reilly"], ["major_names", "Anthropology"], ["middle_name", "Daisha"], ["minor_names", "Sociology"], ["phone", "724-953-4023 x4372"], ["id", "01234567"], ["research_interest", "Ea placeat debitis repellendus autem ad voluptas."], ["updated_at", Sat, 21 Jun 2014 15:12:40 PDT -07:00]]

TypeError: can't cast Array to text: INSERT INTO "profiles" ("career_goal", "created_at", "email", "encrypted_password", "first_name", "gpa", "grad_year", "hidden", "keywords", "kind", "last_name", "major_names", "middle_name", "minor_names", "phone", "id", "research_interest", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

看起来SQL调用现在在INSERT INTO "profiles" ("fields", etc) VALUES (?,?,?)的for中以某种方式格式错误任何关于VALUES部分为什么的见解?s将不胜感激。我检查了我的定义:配置文件,它似乎不像我在其他地方读过的Faker问题。 (我有Faker::Lorem.words(4).join('-')没有提供数组或任何内容。这是一个Active Record问题吗?还有其他地方我应该寻找错误或需要重新配置的东西吗?

1 个答案:

答案 0 :(得分:0)

问号不是问题;他们是价值观的占位符。

这一部分值

["career_goal", ["Illum et sunt.", "Illo sapiente nesciunt reiciendis nulla fugit est autem."]]

表示career_goal设置为数组。将其更改为单个字符串(使用join或通过重写它,无论如何)。