Skip to content

Commit cbccb94

Browse files
committed
[C] Use rspec-rebound to avoid sequence errors with ingestion test
1 parent 643c6a3 commit cbccb94

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

api/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ group :development, :test do
147147
gem "rspec-json_expectations", "~> 2.0"
148148
gem "rspec-mocks", "~> 3.0"
149149
gem "rspec-rails", "> 6"
150-
gem "rspec-retry", "~> 0.6.2"
150+
gem "rspec-rebound", "~> 0.2.1"
151151
gem "rspec-support", "~> 3.0"
152152
gem "rswag", "~> 2.16"
153153
gem "rswag-api", "2.16.0"

api/Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,8 @@ GEM
667667
rspec-expectations (~> 3.12)
668668
rspec-mocks (~> 3.12)
669669
rspec-support (~> 3.12)
670-
rspec-retry (0.6.2)
671-
rspec-core (> 3.3)
670+
rspec-rebound (0.2.1)
671+
rspec-core (~> 3.3)
672672
rspec-support (3.12.1)
673673
rswag (2.16.0)
674674
rswag-api (= 2.16.0)
@@ -975,7 +975,7 @@ DEPENDENCIES
975975
rspec-json_expectations (~> 2.0)
976976
rspec-mocks (~> 3.0)
977977
rspec-rails (> 6)
978-
rspec-retry (~> 0.6.2)
978+
rspec-rebound (~> 0.2.1)
979979
rspec-support (~> 3.0)
980980
rswag (~> 2.16)
981981
rswag-api (= 2.16.0)

api/spec/services/ingestions/post_processors/set_start_section_spec.rb

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,32 @@
55
RSpec.describe Ingestions::PostProcessors::SetStartSection do
66
include TestHelpers::IngestionHelper
77

8+
let_it_be(:project, refind: true) { FactoryBot.create :project }
9+
let_it_be(:creator, refind: true) { FactoryBot.create :user }
10+
811
shared_examples_for "the start section assignment" do |section_name|
9-
before { described_class.run(manifest: manifest, text: text, context: context) }
12+
it "determines the start_text_section_id", retry: 5 do
13+
expect do
14+
described_class.run!(manifest:, text:, context:)
15+
end.to execute_safely
1016

11-
it "determines the start_text_section_id" do
1217
expect(text.start_text_section).not_to be_nil
1318
expect(text.start_text_section.name).to eq section_name
1419
end
1520
end
1621

1722
context "when manifest" do
18-
let!(:ingestion) { FactoryBot.create :ingestion, :uningested, :file_source, source_path: path }
23+
let!(:ingestion) { FactoryBot.create :ingestion, :uningested, :file_source, project:, creator:, source_path: path }
24+
1925
let(:context) { create_context(ingestion) }
26+
2027
let(:manifest) do
21-
manifest = Ingestions::Strategies::Manifest.run(context: context).result
22-
manifest = Ingestions::PreProcessor.run(context: context, manifest: manifest).result
23-
manifest
28+
Ingestions::Strategies::Manifest.run!(context:).then do |manifest|
29+
Ingestions::PreProcessor.run!(context:, manifest:)
30+
end
2431
end
25-
let!(:text) { Ingestions::Compiler.run(manifest: manifest, context: context).result }
32+
33+
let!(:text) { Ingestions::Compiler.run!(manifest:, context:) }
2634

2735
context "when starting section source is referenced multiple times" do
2836
let(:path) { Rails.root.join("spec", "data", "ingestion", "manifest", "all_local.zip") }
@@ -38,13 +46,16 @@
3846
end
3947

4048
context "when epub" do
41-
let!(:ingestion) { FactoryBot.create :ingestion, :uningested, :file_source, source_path: path }
49+
let!(:ingestion) { FactoryBot.create :ingestion, :uningested, :file_source, project:, creator:, source_path: path }
50+
4251
let(:context) { create_context(ingestion) }
52+
4353
let(:manifest) do
44-
manifest = Ingestions::Strategies::Epub.run(context: context).result
45-
manifest = Ingestions::PreProcessor.run(context: context, manifest: manifest).result
46-
manifest
54+
Ingestions::Strategies::Epub.run!(context:).then do |manifest|
55+
Ingestions::PreProcessor.run!(context:, manifest:)
56+
end
4757
end
58+
4859
let!(:text) { Ingestions::Compiler.run(manifest: manifest, context: context).result }
4960

5061
context "when V2" do

0 commit comments

Comments
 (0)