From 411eb0b1657e0703c550046e5ba2c27c957dd86a Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Sun, 29 Oct 2023 23:16:37 +0100 Subject: [PATCH] Specs: Use Runner factory and provide strategy class --- spec/factories/runner.rb | 4 ++++ spec/models/runner_spec.rb | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/factories/runner.rb b/spec/factories/runner.rb index 7db65b186..a12959d3a 100644 --- a/spec/factories/runner.rb +++ b/spec/factories/runner.rb @@ -6,5 +6,9 @@ runner_id { SecureRandom.uuid } execution_environment factory: :ruby contributor factory: :external_user + + after(:build) do |runner| + runner.strategy = Runner.strategy_class.new(runner.runner_id, runner.execution_environment) + end end end diff --git a/spec/models/runner_spec.rb b/spec/models/runner_spec.rb index d16aff1ab..873131464 100644 --- a/spec/models/runner_spec.rb +++ b/spec/models/runner_spec.rb @@ -53,7 +53,7 @@ end describe '#destroy_at_management' do - let(:runner) { described_class.create } + let(:runner) { create(:runner) } before do allow(strategy_class).to receive_messages(request_from_management: runner_id, new: strategy) @@ -66,7 +66,7 @@ end describe '#attach to execution' do - let(:runner) { described_class.create } + let(:runner) { create(:runner) } let(:command) { 'ls' } let(:event_loop) { instance_double(Runner::EventLoop) } let(:connection) { instance_double(Runner::Connection) } @@ -123,7 +123,7 @@ end describe '#copy_files' do - let(:runner) { described_class.create } + let(:runner) { create(:runner) } before do allow(strategy_class).to receive_messages(request_from_management: runner_id, new: strategy)