From d7ccf3b5d496b7933b8ecc443f772f311fb76567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Dunda=CC=81c=CC=8Cek?= Date: Thu, 31 Oct 2024 08:12:19 +0100 Subject: [PATCH] Fix spec --- lib/flatware/rspec/cli.rb | 4 +++- spec/flatware/rspec/formatter_spec.rb | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/flatware/rspec/cli.rb b/lib/flatware/rspec/cli.rb index cc90759..a9d64b4 100644 --- a/lib/flatware/rspec/cli.rb +++ b/lib/flatware/rspec/cli.rb @@ -23,9 +23,11 @@ def rspec(*rspec_args) start_sink(jobs: jobs, workers: workers, formatter: formatter) end + private + def formatter @formatter ||= begin - formatter_klass = "Flatware::RSpec::Formatters::#{options[:formatter].capitalize}".constantize + formatter_klass = Flatware::RSpec::Formatters.const_get(options[:formatter].capitalize) formatter_klass.new( ::RSpec.configuration.output_stream, diff --git a/spec/flatware/rspec/formatter_spec.rb b/spec/flatware/rspec/formatter_spec.rb index 705472f..41ccc17 100644 --- a/spec/flatware/rspec/formatter_spec.rb +++ b/spec/flatware/rspec/formatter_spec.rb @@ -5,13 +5,25 @@ context 'when example_passed' do it "sends a 'passed' progress message to the sink client" do formatter = described_class.new StringIO.new - example = double 'Example' + example = double 'Example', full_description: 'example description', + location: 'here', + location_rerun_argument: 'here[1]', + metadata: {}, + execution_result: double( + 'Execution result', + status: :passed, + exception: nil, + finished_at: Time.now, + run_time: 0.1, + started_at: Time.now - 0.1 + ) + notification = double 'Notification', example: example client = double 'Client', progress: true Flatware::Sink.client = client - formatter.example_passed example + formatter.example_passed notification expect(client).to have_received(:progress).with anything do |message| - expect(message.progress).to eq :passed + expect(message.example.execution_result.status).to eq :passed true end end