Mike Griffin

Using factory_girl with sinatra and the sequel gem

Sequel does not appear to have a save! method which means that using factory_girl is a bit more involved. Instead of being able to write Factory.create and have the model saved, I found that I had to do it in two steps.

When I tried to use Factory.create(:post) I was getting an error telling me

undefined method `save!' for #<Post:0x9e8bd08> (NoMethodError)

To get around the error, I used Factory.build and then manually saved the post like this

post = Factory.build(:post)
post.save

That worked and now my cucumber tests are back to passing again