Created
December 17, 2013 16:34
-
-
Save Bivek/8007908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FactoryGirlAdditions | |
# create instance without running callbacks and validations | |
def insert(*args) | |
record = FactoryGirl.build(*args) | |
def record.run_callbacks(*args, &block) | |
if block_given? | |
block.arity.zero? ? yield : yield(self) | |
end | |
end | |
record.save! | |
record | |
end | |
def pure(*args) | |
factory_name = args.shift | |
if args.last.is_a?(Hash) | |
options = args.pop | |
else | |
options = {} | |
end | |
traits = [:pure] | args | |
FactoryGirl.build(factory_name, *traits, options) | |
end | |
end | |
RSpec.configure do |config| | |
config.include FactoryGirl::Syntax::Methods | |
config.include FactoryGirlAdditions | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment