Prechádzať zdrojové kódy

Properly mock the exit call in `Seeder`

Fixes the spec suite never finishing properly because the `exit` call
terminated the rspec call. This also caused the specs to always finish
successfully on CI even though there were failures.
Dominik Sander 6 rokov pred
rodič
commit
3a2ecc50d8

+ 7 - 1
spec/db/seeds/admin_and_default_scenario_spec.rb

@@ -7,6 +7,11 @@ describe Seeder do
   end
 
   describe '.seed' do
+    before(:each) do
+      User.delete_all
+      expect(User.count).to eq(0)
+    end
+
     it 'imports a default scenario' do
       expect { Seeder.seed }.to change(Agent, :count).by(7)
     end
@@ -18,7 +23,8 @@ describe Seeder do
 
     it 'can be run multiple times and exit normally' do
       Seeder.seed
-      expect { Seeder.seed }.to raise_error(SystemExit)
+      mock(Seeder).exit
+      Seeder.seed
     end
   end