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
|