Loading lib/labkit/covered_experience/experience.rb +3 −4 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ module Labkit # @param extra [Hash] Additional data to include in the log event # @return [self] def checkpoint(**extra) return unless ensure_started! return self unless ensure_started! @checkpoint_time = Time.now.utc checkpoint_counter.increment(checkpoint: "intermediate", **base_labels) Loading @@ -106,7 +106,7 @@ module Labkit # @yield [self] When a block is provided, the experience will be completed automatically. # @param extra [Hash] Additional data to include in the log def resume(**extra, &) return unless ensure_started! return self unless ensure_started! checkpoint(checkpoint_action: 'resume', **extra) Loading @@ -120,8 +120,7 @@ module Labkit # @param extra [Hash] Additional data to include in the log event # @return [self] def complete(**extra) return unless ensure_started! return unless ensure_incomplete! return self unless ensure_started! && ensure_incomplete! begin @end_time = Time.now.utc Loading spec/labkit/covered_experience/experience_spec.rb +7 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,10 @@ RSpec.describe Labkit::CoveredExperience::Experience, :with_metrics_config do expect { experience.resume }.not_to raise_error expect { experience.resume }.not_to resume_covered_experience(:testing_sample) end it 'returns itself' do expect(experience.resume).to be(experience) end end end Loading Loading @@ -305,6 +309,7 @@ RSpec.describe Labkit::CoveredExperience::Experience, :with_metrics_config do context 'when not started' do it { expect { checkpoint }.not_to raise_error } it { expect { checkpoint }.not_to checkpoint_covered_experience(:testing_sample) } it { is_expected.to be(experience) } end end Loading Loading @@ -356,6 +361,7 @@ RSpec.describe Labkit::CoveredExperience::Experience, :with_metrics_config do context 'when not started' do it { expect { complete }.not_to raise_error } it { expect { complete }.not_to complete_covered_experience(:testing_sample) } it { is_expected.to be(experience) } end context 'when already completed' do Loading @@ -365,6 +371,7 @@ RSpec.describe Labkit::CoveredExperience::Experience, :with_metrics_config do it { expect { complete }.not_to raise_error } it { expect { complete }.not_to complete_covered_experience(:testing_sample) } it { is_expected.to be(experience) } end end Loading Loading
lib/labkit/covered_experience/experience.rb +3 −4 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ module Labkit # @param extra [Hash] Additional data to include in the log event # @return [self] def checkpoint(**extra) return unless ensure_started! return self unless ensure_started! @checkpoint_time = Time.now.utc checkpoint_counter.increment(checkpoint: "intermediate", **base_labels) Loading @@ -106,7 +106,7 @@ module Labkit # @yield [self] When a block is provided, the experience will be completed automatically. # @param extra [Hash] Additional data to include in the log def resume(**extra, &) return unless ensure_started! return self unless ensure_started! checkpoint(checkpoint_action: 'resume', **extra) Loading @@ -120,8 +120,7 @@ module Labkit # @param extra [Hash] Additional data to include in the log event # @return [self] def complete(**extra) return unless ensure_started! return unless ensure_incomplete! return self unless ensure_started! && ensure_incomplete! begin @end_time = Time.now.utc Loading
spec/labkit/covered_experience/experience_spec.rb +7 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,10 @@ RSpec.describe Labkit::CoveredExperience::Experience, :with_metrics_config do expect { experience.resume }.not_to raise_error expect { experience.resume }.not_to resume_covered_experience(:testing_sample) end it 'returns itself' do expect(experience.resume).to be(experience) end end end Loading Loading @@ -305,6 +309,7 @@ RSpec.describe Labkit::CoveredExperience::Experience, :with_metrics_config do context 'when not started' do it { expect { checkpoint }.not_to raise_error } it { expect { checkpoint }.not_to checkpoint_covered_experience(:testing_sample) } it { is_expected.to be(experience) } end end Loading Loading @@ -356,6 +361,7 @@ RSpec.describe Labkit::CoveredExperience::Experience, :with_metrics_config do context 'when not started' do it { expect { complete }.not_to raise_error } it { expect { complete }.not_to complete_covered_experience(:testing_sample) } it { is_expected.to be(experience) } end context 'when already completed' do Loading @@ -365,6 +371,7 @@ RSpec.describe Labkit::CoveredExperience::Experience, :with_metrics_config do it { expect { complete }.not_to raise_error } it { expect { complete }.not_to complete_covered_experience(:testing_sample) } it { is_expected.to be(experience) } end end Loading