I have used have_db_column in other project, I don’t understand the undefined method error.
I also tried has_column
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
It looks like you didn’t include shoulda matchers in your spec_helper.rb.