File tree Expand file tree Collapse file tree 9 files changed +40
-60
lines changed
Expand file tree Collapse file tree 9 files changed +40
-60
lines changed Original file line number Diff line number Diff line change 33require "rails_helper"
44
55RSpec . describe "Event Procedures seed" do
6+ subject ( :load_seed ) { load seed_file }
7+
68 let ( :seed_file ) { Rails . root . join ( "db/seeds/09_event_procedures.rb" ) }
79
810 before do
1719 end
1820
1921 it "runs without errors" do
20- expect { load seed_file } . not_to raise_error
22+ expect { load_seed } . not_to raise_error
2123 end
2224
2325 it "creates records in the database" do
24- expect ( EventProcedure . count ) . to be ( 0 )
25-
26- load seed_file
27-
28- expect ( EventProcedure . count ) . to be ( 15 )
26+ expect { load_seed } . to change ( EventProcedure , :count ) . from ( 0 ) . to ( 15 )
2927 end
3028end
Original file line number Diff line number Diff line change 33require "rails_helper"
44
55RSpec . describe "Custom Health Insurances seed" do
6+ subject ( :load_seed ) { load seed_file }
7+
68 let ( :seed_file ) { Rails . root . join ( "db/seeds/05_health_insurances_custom.rb" ) }
79
810 before do
911 create ( :user )
1012 end
1113
1214 it "runs without errors" do
13- expect { load seed_file } . not_to raise_error
15+ expect { load_seed } . not_to raise_error
1416 end
1517
1618 it "creates records in the database" do
17- expect ( HealthInsurance . count ) . to be ( 0 )
18-
19- load seed_file
20-
21- expect ( HealthInsurance . count ) . to be ( 1 )
19+ expect { load_seed } . to change ( HealthInsurance , :count ) . from ( 0 ) . to ( 1 )
2220 end
2321end
Original file line number Diff line number Diff line change 33require "rails_helper"
44
55RSpec . describe "Default Health Insurances seed" do
6+ subject ( :load_seed ) { load seed_file }
7+
68 let ( :seed_file ) { Rails . root . join ( "db/seeds/04_health_insurances_default.rb" ) }
79
810 it "runs without errors" do
9- expect { load seed_file } . not_to raise_error
11+ expect { load_seed } . not_to raise_error
1012 end
1113
1214 it "creates records in the database" do
13- expect ( HealthInsurance . count ) . to be ( 0 )
14-
15- load seed_file
16-
17- expect ( HealthInsurance . count ) . to be ( 9 )
15+ expect { load_seed } . to change ( HealthInsurance , :count ) . from ( 0 ) . to ( 9 )
1816 end
1917end
Original file line number Diff line number Diff line change 33require "rails_helper"
44
55RSpec . describe "Hospitals seed" do
6+ subject ( :load_seed ) { load seed_file }
7+
68 let ( :seed_file ) { Rails . root . join ( "db/seeds/06_hospitals.rb" ) }
79
810 it "runs without errors" do
9- expect { load seed_file } . not_to raise_error
11+ expect { load_seed } . not_to raise_error
1012 end
1113
1214 it "creates records in the database" do
13- expect ( Hospital . count ) . to be ( 0 )
14-
15- load seed_file
16-
17- expect ( Hospital . count ) . to be ( 1 )
15+ expect { load_seed } . to change ( Hospital , :count ) . from ( 0 ) . to ( 1 )
1816 end
1917end
Original file line number Diff line number Diff line change 33require "rails_helper"
44
55RSpec . describe "Medical Shifts seed" do
6+ subject ( :load_seed ) { load seed_file }
7+
68 let ( :seed_file ) { Rails . root . join ( "db/seeds/08_medical_shifts.rb" ) }
79
810 before do
1113 end
1214
1315 it "runs without errors" do
14- expect { load seed_file } . not_to raise_error
16+ expect { load_seed } . not_to raise_error
1517 end
1618
1719 it "creates records in the database" do
18- expect ( MedicalShift . count ) . to be ( 0 )
19-
20- load seed_file
21-
22- expect ( MedicalShift . count ) . to be ( 2 )
20+ expect { load_seed } . to change ( MedicalShift , :count ) . from ( 0 ) . to ( 2 )
2321 end
2422end
Original file line number Diff line number Diff line change 33require "rails_helper"
44
55RSpec . describe "Patients seed" do
6+ subject ( :load_seed ) { load seed_file }
7+
68 let ( :seed_file ) { Rails . root . join ( "db/seeds/07_patients.rb" ) }
79
810 before do
911 create ( :user )
1012 end
1113
1214 it "runs without errors" do
13- expect { load seed_file } . not_to raise_error
15+ expect { load_seed } . not_to raise_error
1416 end
1517
1618 it "creates records in the database" do
17- expect ( Patient . count ) . to be ( 0 )
18-
19- load seed_file
20-
21- expect ( Patient . count ) . to be ( 1 )
19+ expect { load_seed } . to change ( Patient , :count ) . from ( 0 ) . to ( 1 )
2220 end
2321end
Original file line number Diff line number Diff line change 33require "rails_helper"
44
55RSpec . describe "Custom Procedures seed" do
6+ subject ( :load_seed ) { load seed_file }
7+
68 let ( :seed_file ) { Rails . root . join ( "db/seeds/03_procedures_custom.rb" ) }
79
810 before do
911 create ( :user )
1012 end
1113
1214 it "runs without errors" do
13- expect { load seed_file } . not_to raise_error
15+ expect { load_seed } . not_to raise_error
1416 end
1517
1618 it "creates records in the database" do
17- expect ( Procedure . count ) . to be ( 0 )
18-
19- load seed_file
20-
21- expect ( Procedure . count ) . to be ( 1 )
19+ expect { load_seed } . to change ( Procedure , :count ) . from ( 0 ) . to ( 1 )
2220 end
2321end
Original file line number Diff line number Diff line change 33require "rails_helper"
44
55RSpec . describe "Default Procedures seed" do
6+ subject ( :load_seed ) { load seed_file }
7+
68 let ( :seed_file ) { Rails . root . join ( "db/seeds/02_procedures_default.rb" ) }
79
810 before do
6264 end
6365
6466 it "runs without errors" do
65- expect { load seed_file } . not_to raise_error
66- end
67-
68- it "starts with no records in the database" do
69- expect ( PortValue . count ) . to be ( 0 )
70- expect ( Procedure . count ) . to be ( 0 )
71- expect ( CbhpmProcedure . count ) . to be ( 0 )
67+ expect { load_seed } . not_to raise_error
7268 end
7369
7470 it "creates records in the database" do
75- load seed_file
76-
77- expect ( PortValue . count ) . to be ( 3 )
78- expect ( Procedure . count ) . to be ( 3 )
79- expect ( CbhpmProcedure . count ) . to be ( 3 )
71+ expect { load_seed } . to change ( PortValue , :count ) . from ( 0 ) . to ( 3 )
72+ . and change ( Procedure , :count ) . from ( 0 ) . to ( 3 )
73+ . and change ( CbhpmProcedure , :count ) . from ( 0 ) . to ( 3 )
8074 end
8175end
Original file line number Diff line number Diff line change 44
55RSpec . describe "User seeds" do
66 describe "users.rb seed" do
7+ subject ( :load_seed ) { load seed_file }
8+
79 let ( :seed_file ) { Rails . root . join ( "db/seeds/01_users.rb" ) }
810
911 it "creates user without errors" do
1012 expect do
11- load seed_file
13+ load_seed
1214 end . not_to raise_error
1315 end
1416
1517 it "creates exactly one user" do
16- expect do
17- load seed_file
18- end . to change ( User , :count ) . by ( 1 )
18+ expect { load_seed } . to change ( User , :count ) . by ( 1 )
1919 end
2020
2121 it "creates user with correct email" do
22- load seed_file
22+ load_seed
2323 user = User . find_by ( email : "user@email.com" )
2424 expect ( user ) . not_to be_nil
2525 end
2626
2727 it "creates user with valid password" do
28- load seed_file
28+ load_seed
2929 user = User . find_by ( email : "user@email.com" )
3030 expect ( user . valid_password? ( "qwe123" ) ) . to be true
3131 end
You can’t perform that action at this time.
0 commit comments