Commit fe3d77ad6224e4ca88b99b1099f1364d9b87c5b8
Exists in
master
and in
1 other branch
Merge pull request #493 from nfedyashev/testing_factories_first
Test all factories
Showing
2 changed files
with
17 additions
and
9 deletions
Show diff stats
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +Fabrication::Config.fabricator_dir.each do |folder| | ||
4 | + Dir.glob(File.join(Rails.root, folder, '**', '*.rb')).each do |file| | ||
5 | + require file | ||
6 | + end | ||
7 | +end | ||
8 | + | ||
9 | +describe "Fabrication" do | ||
10 | + Fabrication::Fabricator.schematics.keys.sort.each do |fabricator_name| | ||
11 | + context "Fabricate(:#{fabricator_name})" do | ||
12 | + subject { Fabricate.build(fabricator_name) } | ||
13 | + | ||
14 | + it { should be_valid } | ||
15 | + end | ||
16 | + end | ||
17 | +end |
spec/models/problem_spec.rb
@@ -3,9 +3,6 @@ require 'spec_helper' | @@ -3,9 +3,6 @@ require 'spec_helper' | ||
3 | describe Problem do | 3 | describe Problem do |
4 | describe "Fabrication" do | 4 | describe "Fabrication" do |
5 | context "Fabricate(:problem)" do | 5 | context "Fabricate(:problem)" do |
6 | - it 'should be valid' do | ||
7 | - Fabricate.build(:problem).should be_valid | ||
8 | - end | ||
9 | it 'should have no comment' do | 6 | it 'should have no comment' do |
10 | lambda do | 7 | lambda do |
11 | Fabricate(:problem) | 8 | Fabricate(:problem) |
@@ -14,9 +11,6 @@ describe Problem do | @@ -14,9 +11,6 @@ describe Problem do | ||
14 | end | 11 | end |
15 | 12 | ||
16 | context "Fabricate(:problem_with_comments)" do | 13 | context "Fabricate(:problem_with_comments)" do |
17 | - it 'should be valid' do | ||
18 | - Fabricate.build(:problem_with_comments).should be_valid | ||
19 | - end | ||
20 | it 'should have 3 comments' do | 14 | it 'should have 3 comments' do |
21 | lambda do | 15 | lambda do |
22 | Fabricate(:problem_with_comments) | 16 | Fabricate(:problem_with_comments) |
@@ -25,9 +19,6 @@ describe Problem do | @@ -25,9 +19,6 @@ describe Problem do | ||
25 | end | 19 | end |
26 | 20 | ||
27 | context "Fabricate(:problem_with_errs)" do | 21 | context "Fabricate(:problem_with_errs)" do |
28 | - it 'should be valid' do | ||
29 | - Fabricate.build(:problem_with_errs).should be_valid | ||
30 | - end | ||
31 | it 'should have 3 errs' do | 22 | it 'should have 3 errs' do |
32 | lambda do | 23 | lambda do |
33 | Fabricate(:problem_with_errs) | 24 | Fabricate(:problem_with_errs) |