Skip to content

Commit

Permalink
Merge pull request #665 from clowder/patch-1
Browse files Browse the repository at this point in the history
Update RSpec helper to support block syntax
  • Loading branch information
andrehjr authored Nov 7, 2021
2 parents 8e4f7f8 + b65e5b2 commit 7872301
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ module SplitHelper
# use_ab_test(signup_form: "single_page", pricing: "show_enterprise_prices")
#
def use_ab_test(alternatives_by_experiment)
allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment|
alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment, &block|
variant = alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
block.call(variant) unless block.nil?
variant
end
end
end
Expand Down

0 comments on commit 7872301

Please sign in to comment.