admin_and_default_scenario_spec.rb 790 B

1234567891011121314151617181920212223242526272829303132333435
  1. require 'rails_helper'
  2. require_relative '../../../db/seeds/seeder'
  3. describe Seeder do
  4. before do
  5. stub_puts_to_prevent_spew_in_spec_output
  6. end
  7. describe '.seed' do
  8. before(:each) do
  9. User.delete_all
  10. expect(User.count).to eq(0)
  11. end
  12. it 'imports a default scenario' do
  13. expect { Seeder.seed }.to change(Agent, :count).by(7)
  14. end
  15. it 'creates an admin' do
  16. expect { Seeder.seed }.to change(User, :count).by(1)
  17. expect(User.last).to be_admin
  18. end
  19. it 'can be run multiple times and exit normally' do
  20. Seeder.seed
  21. expect(Seeder).to receive(:exit)
  22. Seeder.seed
  23. end
  24. end
  25. def stub_puts_to_prevent_spew_in_spec_output
  26. allow(Seeder).to receive(:puts).with(anything)
  27. allow(Seeder).to receive(:puts)
  28. end
  29. end