Skip to content

Commit

Permalink
add some kwargs spec
Browse files Browse the repository at this point in the history
  • Loading branch information
nulldef committed Jun 22, 2021
1 parent a01241c commit b8031cc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions spec/building_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
class BaseService < Resol::Service
param :type

option :option

builds { |type| ServiceA if type == :a }
builds { |type| ServiceB if type == :b }
builds { |*, option:| ServiceC if option }

def call
success!(:base_service)
Expand All @@ -23,10 +26,17 @@ def call
end
end

class ServiceC < BaseService
def call
success!(:service_c)
end
end

RSpec.describe Resol do
it "builds a right service" do
expect(BaseService.build(:a)).to be_a(ServiceA)
expect(BaseService.build(:b)).to be_a(ServiceB)
expect(BaseService.build(:other)).to be_a(BaseService)
expect(BaseService.build(:a, option: true)).to be_a(ServiceA)
expect(BaseService.build(:b, option: true)).to be_a(ServiceB)
expect(BaseService.build(:other, option: false)).to be_a(BaseService)
expect(BaseService.build(:other, option: true)).to be_a(ServiceC)
end
end

0 comments on commit b8031cc

Please sign in to comment.