From 40e9fa60812db5f0e4843ba1503eb5a9b1d171db Mon Sep 17 00:00:00 2001 From: Nikita Fedyashev Date: Fri, 31 May 2013 21:05:42 +0600 Subject: [PATCH] Test all factories --- spec/fabricators_spec.rb | 17 +++++++++++++++++ spec/models/problem_spec.rb | 9 --------- 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 spec/fabricators_spec.rb diff --git a/spec/fabricators_spec.rb b/spec/fabricators_spec.rb new file mode 100644 index 0000000..293a8a8 --- /dev/null +++ b/spec/fabricators_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +Fabrication::Config.fabricator_dir.each do |folder| + Dir.glob(File.join(Rails.root, folder, '**', '*.rb')).each do |file| + require file + end +end + +describe "Fabrication" do + Fabrication::Fabricator.schematics.keys.sort.each do |fabricator_name| + context "Fabricate(:#{fabricator_name})" do + subject { Fabricate.build(fabricator_name) } + + it { should be_valid } + end + end +end diff --git a/spec/models/problem_spec.rb b/spec/models/problem_spec.rb index eb748ee..b7732dd 100644 --- a/spec/models/problem_spec.rb +++ b/spec/models/problem_spec.rb @@ -3,9 +3,6 @@ require 'spec_helper' describe Problem do describe "Fabrication" do context "Fabricate(:problem)" do - it 'should be valid' do - Fabricate.build(:problem).should be_valid - end it 'should have no comment' do lambda do Fabricate(:problem) @@ -14,9 +11,6 @@ describe Problem do end context "Fabricate(:problem_with_comments)" do - it 'should be valid' do - Fabricate.build(:problem_with_comments).should be_valid - end it 'should have 3 comments' do lambda do Fabricate(:problem_with_comments) @@ -25,9 +19,6 @@ describe Problem do end context "Fabricate(:problem_with_errs)" do - it 'should be valid' do - Fabricate.build(:problem_with_errs).should be_valid - end it 'should have 3 errs' do lambda do Fabricate(:problem_with_errs) -- libgit2 0.21.2