You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
48 lines
1.2 KiB
2 years ago
|
require "rails_helper"
|
||
|
require "rake"
|
||
|
|
||
|
RSpec.describe "seeding process", type: task do
|
||
|
# rubocop:disable RSpec/ExpectOutput
|
||
|
around do |example|
|
||
|
original_stdout = $stdout
|
||
|
$stdout = File.open(File::NULL, "w")
|
||
|
|
||
|
example.run
|
||
|
|
||
|
$stdout = original_stdout
|
||
|
end
|
||
|
# rubocop:enable RSpec/ExpectOutput
|
||
|
|
||
|
before do
|
||
|
Rake.application.rake_require("tasks/rent_ranges")
|
||
|
Rake::Task.define_task(:environment)
|
||
|
|
||
|
allow(Rails.env).to receive(:test?).and_return(false)
|
||
|
allow(Rails.env).to receive(:review?).and_return(true)
|
||
|
end
|
||
|
|
||
|
it "sets up correct data" do
|
||
|
expect {
|
||
|
Rails.application.load_seed
|
||
|
}.to change(User, :count).by(7)
|
||
|
.and change(Organisation, :count).by(8)
|
||
|
.and change(OrganisationRelationship, :count).by(4)
|
||
|
.and change(Scheme, :count).by(3)
|
||
|
.and change(Location, :count).by(3)
|
||
|
.and change(LaRentRange, :count).by(15_450)
|
||
|
end
|
||
|
|
||
|
it "is idempotent" do
|
||
|
Rails.application.load_seed
|
||
|
|
||
|
expect {
|
||
|
Rails.application.load_seed
|
||
|
}.to not_change(User, :count)
|
||
|
.and not_change(Organisation, :count)
|
||
|
.and not_change(OrganisationRelationship, :count)
|
||
|
.and not_change(Scheme, :count)
|
||
|
.and not_change(Location, :count)
|
||
|
.and not_change(LaRentRange, :count)
|
||
|
end
|
||
|
end
|