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/aliases_spec.rb

32 lines
821 B
Ruby
Raw Normal View History

require 'spec_helper'
2009-04-11 11:27:23 -04:00
describe FactoryGirl, "aliases" do
context "aliases for an attribute" do
subject { FactoryGirl.aliases_for(:test) }
it { should include(:test) }
it { should include(:test_id) }
2009-04-11 11:27:23 -04:00
end
context "aliases for a foreign key" do
subject { FactoryGirl.aliases_for(:test_id) }
it { should include(:test) }
it { should include(:test_id) }
2009-04-11 11:27:23 -04:00
end
context "aliases for an attribute starting with an underscore" do
subject { FactoryGirl.aliases_for(:_id) }
it { should_not include(:id) }
2009-04-11 11:27:23 -04:00
end
end
2009-04-11 11:27:23 -04:00
2012-07-27 14:10:38 -04:00
describe FactoryGirl, "after defining an alias" do
before do
2012-03-09 17:45:42 -05:00
FactoryGirl.aliases << [/(.*)_suffix/, '\1']
end
subject { FactoryGirl.aliases_for(:test_suffix) }
2009-04-11 11:27:23 -04:00
it { should include(:test) }
it { should include(:test_suffix_id) }
2009-04-11 11:27:23 -04:00
end