Skip to content

Commit

Permalink
Merge pull request #1069 from sanger/sh/remove-spec-puts
Browse files Browse the repository at this point in the history
Tidy rspec output
  • Loading branch information
StephenHulme authored Jul 25, 2023
2 parents a933818 + 776f702 commit 996efca
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 27 deletions.
147 changes: 122 additions & 25 deletions spec/lib/tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,76 @@

describe 'create tags' do
it 'creates all of the pacbio tag sets' do
Rake::Task['tags:create:pacbio_all'].invoke
expect { Rake::Task['tags:create:pacbio_all'].invoke }.to output(
<<~HEREDOC
-> Creating Sequel_16_barcodes_v3 tag set and tags
-> Tag Set successfully created
-> Sequel_16_barcodes_v3 tags successfully created
-> Creating Sequel_48_Microbial_Barcoded_OHA_v1tag set and tags
-> Tag Set successfully created
-> Sequel_48_Microbial_Barcoded_OHA_v1 tags successfully created
-> Creating TruSeq_CD_i7_i5_D0x_8mer tag set and tags
-> Tag Set successfully created
-> TruSeq_CD_i7_i5_D0x_8mer tags successfully created
-> Creating Sequel_96_Barcoded_OHA_v1 tag set and tags
-> Tag Set successfully created
-> Sequel_96_Barcoded_OHA_v1 tags successfully created
-> Creating Pacbio IsoSeq tag set and tags
-> Tag Set successfully created
-> IsoSeq_Primers_12_Barcodes_v1 created
-> Creating Nextera UD tag set and tags
-> Tag Set successfully created
-> Nextera_UD_Index_PlateA tags successfully created
-> Creating Pacbio_96_barcode_plate_v3 tag set and tags
-> Tag Set successfully created
-> Pacbio_96_barcode_plate_v3 tags successfully created
HEREDOC
).to_stdout
expect(TagSet.count).to eq(7)
end

it 'creates all of the ont tag sets' do
Rake::Task['tags:create:ont_all'].invoke
expect { Rake::Task['tags:create:ont_all'].invoke }.to output(
<<~HEREDOC
-> Creating SQK-NBD114.96 tag set and tags
-> Tag Set successfully created
-> SQK-NBD114.96 tags successfully created
HEREDOC
).to_stdout
expect(TagSet.count).to eq(1)
end

it 'creates all of the tag sets' do
# We need to reenable all tag tasks because they have all already been invoked by this point
Rake.application.in_namespace(:tags) { |namespace| namespace.tasks.each(&:reenable) }
Rake::Task['tags:create:traction_all'].invoke
expect { Rake::Task['tags:create:traction_all'].invoke }.to output(
<<~HEREDOC
-> Creating Sequel_16_barcodes_v3 tag set and tags
-> Tag Set successfully created
-> Sequel_16_barcodes_v3 tags successfully created
-> Creating Sequel_48_Microbial_Barcoded_OHA_v1tag set and tags
-> Tag Set successfully created
-> Sequel_48_Microbial_Barcoded_OHA_v1 tags successfully created
-> Creating TruSeq_CD_i7_i5_D0x_8mer tag set and tags
-> Tag Set successfully created
-> TruSeq_CD_i7_i5_D0x_8mer tags successfully created
-> Creating Sequel_96_Barcoded_OHA_v1 tag set and tags
-> Tag Set successfully created
-> Sequel_96_Barcoded_OHA_v1 tags successfully created
-> Creating Pacbio IsoSeq tag set and tags
-> Tag Set successfully created
-> IsoSeq_Primers_12_Barcodes_v1 created
-> Creating Nextera UD tag set and tags
-> Tag Set successfully created
-> Nextera_UD_Index_PlateA tags successfully created
-> Creating Pacbio_96_barcode_plate_v3 tag set and tags
-> Tag Set successfully created
-> Pacbio_96_barcode_plate_v3 tags successfully created
-> Creating SQK-NBD114.96 tag set and tags
-> Tag Set successfully created
-> SQK-NBD114.96 tags successfully created
HEREDOC
).to_stdout
expect(TagSet.count).to eq(8)
end
end
Expand All @@ -40,19 +97,21 @@
Rake::Task['tags:create:pacbio_isoseq'].reenable
expect { Rake::Task['pacbio_data:create'].invoke }
.to output(
"-> Creating Sequel_16_barcodes_v3 tag set and tags\n" \
"-> Tag Set successfully created\n" \
"-> Sequel_16_barcodes_v3 tags successfully created\n" \
"-> Creating Pacbio IsoSeq tag set and tags\n" \
"-> Tag Set successfully created\n" \
"-> IsoSeq_Primers_12_Barcodes_v1 created\n" \
"-> Creating pacbio plates and tubes...\b\b\b\n" \
"-> Creating pacbio libraries...\b\b\b\n" \
"-> Finding Pacbio SMRT Link versions...\b\b\b\n" \
"-> Creating pacbio runs:\n " \
"-> Creating runs for v11...\b\b\b\n " \
"-> Creating runs for v12_revio...\b\b\b\n" \
"-> Pacbio runs successfully created\n"
<<~HEREDOC
-> Creating Sequel_16_barcodes_v3 tag set and tags
-> Tag Set successfully created
-> Sequel_16_barcodes_v3 tags successfully created
-> Creating Pacbio IsoSeq tag set and tags
-> Tag Set successfully created
-> IsoSeq_Primers_12_Barcodes_v1 created
-> Creating pacbio plates and tubes...\b\b\b#{' '}
-> Creating pacbio libraries...\b\b\b#{' '}
-> Finding Pacbio SMRT Link versions...\b\b\b#{' '}
-> Creating pacbio runs:
-> Creating runs for v11...\b\b\b#{' '}
-> Creating runs for v12_revio...\b\b\b#{' '}
-> Pacbio runs successfully created
HEREDOC
).to_stdout
expect(Pacbio::Run.count)
.to eq(12)
Expand All @@ -61,26 +120,42 @@

describe 'library_types:create' do
it 'creates the library types' do
expect { Rake::Task['library_types:create'].invoke }.to change(LibraryType, :count).by(15).and output("-> Library types updated\n").to_stdout
expect { Rake::Task['library_types:create'].invoke }.to change(LibraryType, :count).by(15).and output(
<<~HEREDOC
-> Library types updated
HEREDOC
).to_stdout
end
end

describe 'data_types:create' do
it 'creates the data types' do
expect { Rake::Task['data_types:create'].invoke }.to change(DataType, :count).by(2).and output("-> Data types updated\n").to_stdout
expect { Rake::Task['data_types:create'].invoke }.to change(DataType, :count).by(2).and output(
<<~HEREDOC
-> Data types updated
HEREDOC
).to_stdout
end
end

describe 'ont_instruments:create' do
it 'creates the correct instrument data' do
Rake::Task['ont_instruments:create'].reenable
expect { Rake::Task['ont_instruments:create'].invoke }.to change(Ont::Instrument, :count).and output("-> ONT Instruments successfully created\n").to_stdout
expect { Rake::Task['ont_instruments:create'].invoke }.to change(Ont::Instrument, :count).and output(
<<~HEREDOC
-> ONT Instruments successfully created
HEREDOC
).to_stdout
end
end

describe 'min_know_versions:create' do
it 'creates the correct MinKnowVersion data' do
expect { Rake::Task['min_know_versions:create'].invoke }.to change(Ont::MinKnowVersion, :count).and output("-> ONT MinKnow versions successfully created\n").to_stdout
expect { Rake::Task['min_know_versions:create'].invoke }.to change(Ont::MinKnowVersion, :count).and output(
<<~HEREDOC
-> ONT MinKnow versions successfully created
HEREDOC
).to_stdout
end
end

Expand Down Expand Up @@ -150,7 +225,11 @@

it 'modifies the data correctly' do
expect(Pacbio::Well.count).to eq(6) # create(:pacbio_plate) also creates a well
Rake::Task['pacbio_wells:migrate_smrt_link_options'].invoke
expect { Rake::Task['pacbio_wells:migrate_smrt_link_options'].invoke }.to output(
<<~HEREDOC
-> 6 instances of pacbio well updated.
HEREDOC
).to_stdout
[well1, well2, well3, well4, well5].collect(&:reload)
expect(well1.generate_hifi).to eq('In SMRT Link')
expect(well2.generate_hifi).to eq('On Instrument')
Expand All @@ -162,7 +241,11 @@

describe 'qc_assay_types:create' do
it 'creates the correct number of qc assay types' do
expect { Rake::Task['qc_assay_types:create'].invoke }.to change(QcAssayType, :count).by(10).and output("-> QC Assay Types updated\n").to_stdout
expect { Rake::Task['qc_assay_types:create'].invoke }.to change(QcAssayType, :count).by(10).and output(
<<~HEREDOC
-> QC Assay Types updated
HEREDOC
).to_stdout
end
end

Expand Down Expand Up @@ -191,7 +274,11 @@
# Reenabling the task makes it possible to invoke again.
# Invoke the data migration task for smrt_link options.
Rake::Task['pacbio_wells:migrate_smrt_link_options'].reenable
Rake::Task['pacbio_wells:migrate_smrt_link_options'].invoke
expect { Rake::Task['pacbio_wells:migrate_smrt_link_options'].invoke }.to output(
<<~HEREDOC
-> 2 instances of pacbio well updated.
HEREDOC
).to_stdout

# Reload the attributes of the record from the database.
# We want to see what was saved by the task.
Expand All @@ -208,7 +295,13 @@
describe 'migrate_pacbio_run_smrt_link_versions' do
it 'creates smrt link version and options for v10' do
Rake::Task['pacbio_runs:migrate_pacbio_run_smrt_link_versions'].reenable
Rake::Task['pacbio_runs:migrate_pacbio_run_smrt_link_versions'].invoke
expect do
Rake::Task['pacbio_runs:migrate_pacbio_run_smrt_link_versions'].invoke
end.to output(
<<~HEREDOC
-> Pacbio SMRT Link versions and options successfully created
HEREDOC
).to_stdout

version = Pacbio::SmrtLinkVersion.find_by(name: 'v10', default: true, active: true)
expect(version).not_to be_nil
Expand Down Expand Up @@ -294,7 +387,11 @@

Rake::Task['smrt_link_versions:create'].reenable
Rake::Task['pacbio_runs:migrate_pacbio_run_smrt_link_versions'].reenable
Rake::Task['pacbio_runs:migrate_pacbio_run_smrt_link_versions'].invoke
expect { Rake::Task['pacbio_runs:migrate_pacbio_run_smrt_link_versions'].invoke }.to output(
<<~HEREDOC
-> Pacbio SMRT Link versions and options successfully created
HEREDOC
).to_stdout

run10.reload
run11.reload
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
# config.default_formatter = "doc"
# end
#
# Print the 10 slowest examples and example groups at the
# Print the 1 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
config.profile_examples = 1
#
# # Run specs in random order to surface order dependencies. If you find an
# # order dependency and want to debug it, you can fix the order by providing
Expand Down

0 comments on commit 996efca

Please sign in to comment.