From d683ce5c10ee84d9fde153329d08425c7e99941f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Oct 2012 18:20:46 +0300 Subject: [PATCH] refactored factory + fixed tests --- spec/factories.rb | 6 ++++++ spec/factories/groups.rb | 21 --------------------- spec/models/group_spec.rb | 2 ++ 3 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 spec/factories/groups.rb diff --git a/spec/factories.rb b/spec/factories.rb index 760465aa..82d73fec 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -47,6 +47,12 @@ FactoryGirl.define do owner end + factory :group do + sequence(:name) { |n| "group#{n}" } + code { name.downcase.gsub(/\s/, '_') } + owner + end + factory :users_project do user project diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb deleted file mode 100644 index d583b186..00000000 --- a/spec/factories/groups.rb +++ /dev/null @@ -1,21 +0,0 @@ -# == Schema Information -# -# Table name: groups -# -# id :integer not null, primary key -# name :string(255) not null -# code :string(255) not null -# owner_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null -# - -# Read about factories at https://github.com/thoughtbot/factory_girl - -FactoryGirl.define do - factory :group do - name "MyString" - code "MyString" - owner_id 1 - end -end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index eea196fd..fd7db4b2 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -13,6 +13,8 @@ require 'spec_helper' describe Group do + let!(:group) { create(:group) } + it { should have_many :projects } it { should validate_presence_of :name } it { should validate_uniqueness_of(:name) }