2012-01-26 3 views
1

私は他のプロジェクトでhave_db_columnを使用しましたが、私はundefined methodエラーを理解していません。
私はまた、あなたのspec_helper.rbでshouldaマッチャが含まれていなかったように見えます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

いいですよ、それでした!必要な 'gem shoulda'回答として投稿してください –

+0

助けてくれてうれしい!私はそれをやった:) – lucapette

答えて

関連する問題