[Ror-es] factory_girl + :uniquessness => true
Marcelino Llano
Wed Feb 17 22:50:35 GMT 2010
Tengo un test que está resistiéndose.
No pretendo testear los modelos en el test de controlador,
pero no consigo generar titles únicos.
# episode.rb
class Episode < ActiveRecord::Base
validates :title, :uniqueness => true
end
#factories.rb
Factory.sequence :title do |n|
"Foo #{n}"
end
Factory.define :episode do |f|
f.title { Factory.next(:title) }
end
#episode_controller_test.rb
class Admin::EpisodesControllerTest < ActionController::TestCase
def setup
@episode = Factory.create(:episode)
end
test "should create episode" do
assert_difference('Episode.count') do
post :create, :episode => Factory.attributes_for(:episode)
end
assert_redirected_to admin_episodes_path
assert_equal "El episodio ha sido creado", flash[:notice]
end
end
¿Qué puede fallar?
Marcelino Llano
Por favor, no imprimas este email o sus adjuntos si no es necesario.
Please, do not print this email or its attachments if it is not necessary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.simplelogica.net/pipermail/ror-es/attachments/20100217/5e3c5e12/attachment.htm