aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert2017-10-21 10:34:16 +0200
committerRobert2017-10-21 10:34:16 +0200
commitbeaa8e127e6b6104cb377c9a2be4a6e4ecae6da9 (patch)
tree11e0c9b68a5dc694a03d41e2169ef151a7335668
parente3f3d13b6c096f7dcd0e5429efc46a70c7da7e7c (diff)
downloadchouette-core-beaa8e127e6b6104cb377c9a2be4a6e4ecae6da9.tar.bz2
Added meta tests for FactoryGirl support too
-rw-r--r--spec/models/faster_specs_spec.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/models/faster_specs_spec.rb b/spec/models/faster_specs_spec.rb
index edae5f485..5581eb076 100644
--- a/spec/models/faster_specs_spec.rb
+++ b/spec/models/faster_specs_spec.rb
@@ -37,29 +37,40 @@ RSpec.describe 'Faster Specs', type: :faster do
it_behaves_like 'correct behavior'
end
- context 'meta' do
- let( :workbench ){ stub_model Workbench }
+ shared_examples_for 'meta' do |org_builder|
context 'workbench belongs to organisation' do
it 'workbench has no orgnaisation' do
expect( workbench.organisation ).to be_nil
end
it 'but it can be set' do
- organisation = stub_model Organisation
+ organisation = stub_model org_builder
workbench.organisation = organisation
expect( workbench.organisation ).to eq(organisation)
end
it 'and by setting it we get the reverse relation working' do
- organisation = stub_model Organisation
+ organisation = stub_model org_builder
workbench.organisation = organisation
expect( organisation.workbenches ).to be_eql([workbench])
end
it 'can also be constructed that way' do
- organisation = stub_model Organisation
+ organisation = stub_model org_builder
workbench = stub_model Workbench, organisation: organisation
expect( workbench.organisation ).to eq(organisation)
expect( organisation.workbenches ).to be_eql([workbench])
end
end
+ end
+
+ context 'ActiveRecordMeta' do
+ let( :workbench ){ stub_model Workbench }
+
+ it_behaves_like 'meta', Organisation
+ end
+
+ context 'FactoryGirlMeta' do
+ let( :workbench ){ stub_model :workbench }
+
+ it_behaves_like 'meta', :organisation
end
end