diff options
author | Rémy Coutable <remy@rymai.me> | 2017-05-31 15:43:19 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-06-02 19:06:50 +0200 |
commit | 857d039145bccaa81da1e7654e51eee9e4b4823a (patch) | |
tree | 5ee5fdc54d98ec7d54fa0f08957dcb7952ff42a4 /spec/factories_spec.rb | |
parent | 19ee16a0f85dd4bacddbd066237e62a1bbb7113a (diff) | |
download | gitlab-ce-857d039145bccaa81da1e7654e51eee9e4b4823a.tar.gz |
Lint our factories creation in addition to their build33139-lint-our-factories
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/factories_spec.rb')
-rw-r--r-- | spec/factories_spec.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb index 786e1456f5f..09b3c0b0994 100644 --- a/spec/factories_spec.rb +++ b/spec/factories_spec.rb @@ -3,14 +3,20 @@ require 'spec_helper' describe 'factories' do FactoryGirl.factories.each do |factory| describe "#{factory.name} factory" do - let(:entity) { build(factory.name) } + it 'does not raise error when built' do + expect { build(factory.name) }.not_to raise_error + end it 'does not raise error when created' do - expect { entity }.not_to raise_error + expect { create(factory.name) }.not_to raise_error end - it 'is valid', if: factory.build_class < ActiveRecord::Base do - expect(entity).to be_valid + factory.definition.defined_traits.map(&:name).each do |trait_name| + describe "linting #{trait_name} trait" do + skip 'does not raise error when created' do + expect { create(factory.name, trait_name) }.not_to raise_error + end + end end end end |