2012-01-26 60 views
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 
+0

它看起來像你沒有包括應該匹配... – lucapette

+0

好電話,就是這樣!需要'寶石shoulda'請發表回答 –

+0

很高興幫助!我做到了:) – lucapette

回答

1

看起來你並沒有包括在spec_helper.rb早該的匹配。

相關問題