aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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