From d366fdd516cefd001f69d4641786cef11cc4ea36 Mon Sep 17 00:00:00 2001 From: Chris Gaffney Date: Thu, 19 Dec 2024 10:47:33 -0500 Subject: [PATCH] Fix standardrb issues --- interactor.gemspec | 1 - lib/interactor/context.rb | 6 +++++- spec/interactor/context_spec.rb | 8 +++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/interactor.gemspec b/interactor.gemspec index 2b80ba9..3dc0647 100644 --- a/interactor.gemspec +++ b/interactor.gemspec @@ -12,7 +12,6 @@ Gem::Specification.new do |spec| spec.license = "MIT" spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) - spec.test_files = spec.files.grep(/^spec/) spec.add_dependency "ostruct" spec.add_development_dependency "bundler" diff --git a/lib/interactor/context.rb b/lib/interactor/context.rb index a477f1d..d9ce24d 100644 --- a/lib/interactor/context.rb +++ b/lib/interactor/context.rb @@ -53,7 +53,11 @@ class Context < OpenStruct # # Returns the Interactor::Context. def self.build(context = {}) - self === context ? context : new(context) + if self === context + context + else + new(context) + end end # Public: Whether the Interactor::Context is successful. By default, a new diff --git a/spec/interactor/context_spec.rb b/spec/interactor/context_spec.rb index 94ad4b2..1769172 100644 --- a/spec/interactor/context_spec.rb +++ b/spec/interactor/context_spec.rb @@ -144,9 +144,11 @@ module Interactor end it "makes the context available from the failure" do - context.fail! - rescue Failure => error - expect(error.context).to eq(context) + begin + context.fail! + rescue Failure => error + expect(error.context).to eq(context) + end end end