mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
29 lines
739 B
Ruby
29 lines
739 B
Ruby
require(File.join(File.dirname(__FILE__), 'test_helper'))
|
|
|
|
class AliasesTest < Test::Unit::TestCase
|
|
|
|
should "include an attribute as an alias for itself by default" do
|
|
assert Factory.aliases_for(:test).include?(:test)
|
|
end
|
|
|
|
should "include the root of a foreign key as an alias by default" do
|
|
assert Factory.aliases_for(:test_id).include?(:test)
|
|
end
|
|
|
|
should "include an attribute's foreign key as an alias by default" do
|
|
assert Factory.aliases_for(:test).include?(:test_id)
|
|
end
|
|
|
|
context "after adding an alias" do
|
|
|
|
setup do
|
|
Factory.alias(/(.*)_suffix/, '\1')
|
|
end
|
|
|
|
should "return the alias in the aliases list" do
|
|
assert Factory.aliases_for(:test_suffix).include?(:test)
|
|
end
|
|
|
|
end
|
|
|
|
end
|