More with Sinatra and Factory_girl
Mike GriffinTo add factory_girl to rspec when
testing a sinatra app, you only have to do a couple of things. First off,
include the following lines in spec/spec_helper.rb
require 'factory_girl'
Dir[File.dirname(__FILE__)+"/factories/*.rb"].each {|file| require file }
This will look into spec/factories
for each .rb
file and use each one as a
different factory file. Create a file with something simiilar to the following
Factory.define :post do |f|
f.title "A post title"
f.body "A full bodied post"
end
and then in your rspec file, you can use it like this
Factory(:post)