Skip to content

Commit

Permalink
test(can_have_try_result): fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Apr 15, 2023
1 parent 92914dc commit a15bbeb
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

require "convenient_service"

# rubocop:disable RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::CanHaveTryResult::Concern do
include ConvenientService::RSpec::Matchers::DelegateTo

Expand Down Expand Up @@ -68,19 +69,37 @@

example_group "class methods" do
describe ".try_result" do
let(:service_class) do
Class.new do
include ConvenientService::Configs::Standard

##
# TODO: Remove once `CanHaveTryResult` becomes included into `Standard` config.
#
concerns do
use ConvenientService::Service::Plugins::CanHaveTryResult::Concern
end

def try_result
success
end
end
end

specify do
expect { ignoring_error(ConvenientService::Service::Plugins::CanHaveTryResult::Errors::TryResultIsNotOverridden) { service_class.try_result(*args, **kwargs, &block) } }
expect { service_class.try_result(*args, **kwargs, &block) }
.to delegate_to(service_class, :new)
.with_arguments(*args, **kwargs, &block)
end

specify do
allow(service_class).to receive(:new).and_return(service_instance)

expect { ignoring_error(ConvenientService::Service::Plugins::CanHaveTryResult::Errors::TryResultIsNotOverridden) { service_class.try_result(*args, **kwargs, &block) } }
expect { service_class.try_result(*args, **kwargs, &block) }
.to delegate_to(service_instance, :try_result)
.and_return_its_value
end
end
end
end
# rubocop:enable RSpec/MultipleMemoizedHelpers

0 comments on commit a15bbeb

Please sign in to comment.