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

Adding tests for models ending in an s, currently breaks.

This commit is contained in:
Josh Owens 2008-11-24 18:11:40 -05:00 committed by Joe Ferris
parent c88fc36517
commit be5e07dfb6
2 changed files with 28 additions and 0 deletions

View file

@ -345,6 +345,24 @@ class FactoryTest < Test::Unit::TestCase
end
context "a factory with a name ending in s" do
setup do
@name = :business
@class = Business
@factory = Factory.new(@name)
end
should "have a factory name" do
assert_equal @name, @factory.factory_name
end
should "have a build class" do
assert_equal @class, @factory.build_class
end
end
context "a factory with a string for a name" do
setup do

View file

@ -16,6 +16,11 @@ class CreateSchema < ActiveRecord::Migration
t.string :name
t.integer :author_id
end
create_table :business, :force => true do |t|
t.string :name
t.integer :owner_id
end
end
end
@ -26,6 +31,11 @@ class User < ActiveRecord::Base
has_many :posts, :foreign_key => 'author_id'
end
class Business < ActiveRecord::Base
validates_presence_of :name, :owner_id
belongs_to :owner, :class_name => 'User'
end
class Post < ActiveRecord::Base
validates_presence_of :name, :author_id
belongs_to :author, :class_name => 'User'