1
我在其他項目中使用過have_db_column,我不明白undefined method
錯誤。
我也試過has_column
未定義的方法`has_db_column?'爲#<通知:0xcc2b350>
describe Notification do
context "has valid db fields" do
subject { Factory.build(:notification)}
it { should be_valid }
it { should have_db_column(:title)}
end
end
mysql> describe notifications;
+---------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(255) | YES | | NULL | |
Factory.define :notification do |notification|
notification.title {'test'}
end
它看起來像你沒有包括應該匹配... – lucapette
好電話,就是這樣!需要'寶石shoulda'請發表回答 –
很高興幫助!我做到了:) – lucapette