1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/spec/factory_girl/callback_spec.rb

24 lines
810 B
Ruby
Raw Normal View History

2011-09-16 16:06:32 -04:00
require 'spec_helper'
describe FactoryGirl::Callback do
2011-09-16 16:19:42 -04:00
it "has a name" do
FactoryGirl::Callback.new(:after_create, lambda {}).name.should == :after_create
end
2011-09-16 16:06:32 -04:00
2011-09-16 16:19:42 -04:00
it "converts strings to symbols" do
FactoryGirl::Callback.new("after_create", lambda {}).name.should == :after_create
end
2011-09-16 16:06:32 -04:00
2011-09-16 16:19:42 -04:00
it "allows valid callback names to be assigned" do
FactoryGirl::Callback::VALID_NAMES.each do |callback_name|
expect { FactoryGirl::Callback.new(callback_name, lambda {}) }.
to_not raise_error(FactoryGirl::InvalidCallbackNameError)
end
end
2011-09-16 16:06:32 -04:00
2011-09-16 16:19:42 -04:00
it "raises if an invalid callback name is assigned" do
expect { FactoryGirl::Callback.new(:magic_fairies, lambda {}) }.
to raise_error(FactoryGirl::InvalidCallbackNameError, /magic_fairies is not a valid callback name/)
end
2011-09-16 16:06:32 -04:00
end