admin_and_default_scenario_spec.rb 670 B

1234567891011121314151617181920212223242526272829
  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. it 'imports a default scenario' do
  9. expect { Seeder.seed }.to change(Agent, :count).by(7)
  10. end
  11. it 'creates an admin' do
  12. expect { Seeder.seed }.to change(User, :count).by(1)
  13. expect(User.last).to be_admin
  14. end
  15. it 'can be run multiple times and exit normally' do
  16. Seeder.seed
  17. expect { Seeder.seed }.to raise_error(SystemExit)
  18. end
  19. end
  20. def stub_puts_to_prevent_spew_in_spec_output
  21. stub(Seeder).puts(anything)
  22. stub(Seeder).puts
  23. end
  24. end