Skip to content

Instantly share code, notes, and snippets.

@wireframe
Created October 4, 2011 22:02
Show Gist options
  • Save wireframe/1262967 to your computer and use it in GitHub Desktop.
Save wireframe/1262967 to your computer and use it in GitHub Desktop.
# spec/support/factory_girl_with.rb
# replace instance variables and before blocks with memoized factory instances
module FactoryGirl
module With
def with(name, options = {})
let(name) { ::Factory.create(name, options) }
end
end
end
# spec/spec_helper.rb
# add factory_girl_with extension to rspec env
RSpec.configure do |config|
config.extend FactoryGirl::With
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment