簡體   English   中英

在Rails 4升級后,factory_girl導致RSpec規范失敗

[英]factory_girl causing RSpec spec to fail after Rails 4 upgrade

我剛剛將應用程序升級到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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

看起來,現在在INSERT INTO "profiles" ("fields", etc) VALUES (?,?,?) ,SQL調用的格式有些不正確INSERT INTO "profiles" ("fields", etc) VALUES (?,?,?)關於VALUES部分為何全部為?s的任何見解都將受到贊賞。 我檢查了:profile的定義,這似乎不是Faker的問題,正如我在其他地方閱讀過的那樣。 (我有Faker::Lorem.words(4).join('-') ,它不提供數組或其他任何東西。這是Active Record問題嗎?還有其他地方我應該尋找錯誤或需要的東西嗎?重新配置?

問號不是問題; 它們是價值的占位符。

值陣列的這一部分

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

表示將career_goal設置為數組。 將其更改為單個字符串(使用join或通過重寫它,無論如何)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM