diff options
| -rw-r--r-- | spec/models/faster_specs_spec.rb | 25 | ||||
| -rw-r--r-- | spec/support/faster/model_stubber/implementation.rb | 2 | 
2 files changed, 18 insertions, 9 deletions
| diff --git a/spec/models/faster_specs_spec.rb b/spec/models/faster_specs_spec.rb index 2c97d1055..31f31e0f8 100644 --- a/spec/models/faster_specs_spec.rb +++ b/spec/models/faster_specs_spec.rb @@ -1,13 +1,17 @@  RSpec.describe 'Faster Specs', type: :faster do -   + +  N = (ENV['N'] || 50).to_i +    shared_examples_for 'correct behavior' do -    it 'finds workbench' do -      expect( referential.workbench ).to eq(workbench) -    end +    N.times do +      it 'finds workbench' do +        expect( referential.workbench ).to eq(workbench) +      end -    it 'finds referentials' do -      expect( workbench.referentials ).to eq([referential]) +      it 'finds referentials' do +        expect( workbench.referentials ).to eq([referential]) +      end      end    end @@ -15,16 +19,20 @@ RSpec.describe 'Faster Specs', type: :faster do    context 'in DB' do       let( :workbench ){ create :workbench }      let( :referential ){ create(:referential, workbench: workbench) } -     +      it_behaves_like 'correct behavior'    end    context 'stubbed' do       let( :workbench ){ stub_model Workbench }      let( :referential ){ stub_model( Referential, workbench: workbench ) } -     +      it_behaves_like 'correct behavior' +  end + +  context 'meta' do +    let( :workbench ){ stub_model Workbench }      context 'workbench belongs to organisation' do        it 'workbench has no orgnaisation' do          expect( workbench.organisation ).to be_nil @@ -46,5 +54,6 @@ RSpec.describe 'Faster Specs', type: :faster do          expect( organisation.workbenches ).to be_eql([workbench])        end      end +    end  end diff --git a/spec/support/faster/model_stubber/implementation.rb b/spec/support/faster/model_stubber/implementation.rb index 9ee1f417a..1170629d3 100644 --- a/spec/support/faster/model_stubber/implementation.rb +++ b/spec/support/faster/model_stubber/implementation.rb @@ -28,7 +28,7 @@ module ModelStubber      end      def setup_belongs_to reflection, model, key, value -      model.stub(key){value} +      mystub(model, key){value}        has_manys =           value.class.reflect_on_all_associations(:has_many).select{|v| v.foreign_type == "#{model.class.name.underscore.pluralize}_type" }        has_manys.each do | has_many | | 
