verdict 0.15.1 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27eea30b628bf29627fe68762f18dea365ebc77d0ac34e8b1b63f24e29814276
4
- data.tar.gz: 65a0cb4ae9247c75bdcff094a7546e673cda0d05f8a922c48ed7f448deb931b7
3
+ metadata.gz: 50c44fd8fcc0cf5605c9d21fd5eefcd4dddeffeb03c48e7ec046639d7154715b
4
+ data.tar.gz: d55759fff1145aa793f9ae42232518130ba93efcb5fb62a2f7cbfa24d0322a0f
5
5
  SHA512:
6
- metadata.gz: 813097404fecc5c3f44121d68b5da2cb0213fcbadfa4b5b20c451286577b6d7e35900e636582fe3d4b1d6b95c6df3916da9e89ded291d042f11f963a8a58e895
7
- data.tar.gz: ea1e6b44880d6a6dd085173abf4155f5e8605272d6d679c8dea8a71259d5b7b8f86b62adc39afb49e40126ef8cd547efda8904214a3d51f5881f96030498e028
6
+ metadata.gz: 8ed63a2aaf52ebffe454da41e3022e87df834b80130cb0ab14902466ea6d630ce9d046e1b202e32fc6491a2dc9974f4f825f50aaa14aa862103888f31d5c3df6
7
+ data.tar.gz: 12c379615c6593caf46749157ebca884d91fb17a97d81b7fc60c53cd3531785a0a0c078e79e4b387cd21676f26d55962e0a2ab1ba0caeacb5d99208c3f1e8f8d
@@ -3,9 +3,9 @@ cache: bundler
3
3
  before_install: gem update bundler
4
4
  script: bundle exec rake
5
5
  rvm:
6
- - 2.0
7
- - 2.1
8
- - 2.3.3
6
+ - 2.5
7
+ - 2.6
8
+ - 2.7
9
9
  - ruby-head
10
10
  - jruby
11
11
  matrix:
@@ -1,3 +1,6 @@
1
+ ## v0.15.2
2
+ * Fix edge case where inheriting from `Verdict::Experiment` and overriding `subject_qualifies?` resulted in an error.
3
+
1
4
  ## v0.15.1
2
5
  * Make the `dynamic_qualifies` parameter in `Verdict::Experiment#subject_qualifies?` optional. This fixes a bug where users that were previously calling this method directly experienced issues after v0.15.0
3
6
 
@@ -148,7 +148,7 @@ class Verdict::Experiment
148
148
  subject_identifier = retrieve_subject_identifier(subject)
149
149
  assignment = if previous_assignment
150
150
  previous_assignment
151
- elsif subject_qualifies?(subject, dynamic_qualifiers, context) && is_make_new_assignments?
151
+ elsif dynamic_subject_qualifies?(subject, dynamic_qualifiers, context) && is_make_new_assignments?
152
152
  group = segmenter.assign(subject_identifier, subject, context)
153
153
  subject_assignment(subject, group, nil, group.nil?)
154
154
  else
@@ -243,7 +243,7 @@ class Verdict::Experiment
243
243
  @disqualify_empty_identifier
244
244
  end
245
245
 
246
- def subject_qualifies?(subject, dynamic_qualifiers = [], context = nil)
246
+ def subject_qualifies?(subject, context = nil, dynamic_qualifiers: [])
247
247
  ensure_experiment_has_started
248
248
  return false unless dynamic_qualifiers.all? { |qualifier| qualifier.call(subject) }
249
249
  everybody_qualifies? || @qualifiers.all? { |qualifier| qualifier.call(subject, context) }
@@ -295,4 +295,15 @@ class Verdict::Experiment
295
295
  def is_make_new_assignments?
296
296
  return !(@schedule_stop_new_assignment_timestamp && @schedule_stop_new_assignment_timestamp <= Time.now)
297
297
  end
298
+
299
+ # Used when a Experiment class has overridden the subject_qualifies? method prior to v0.15.0
300
+ # The previous version of subject_qualifies did not accept dynamic qualifiers, thus this is used to
301
+ # determine how many parameters to pass
302
+ def dynamic_subject_qualifies?(subject, dynamic_qualifiers, context)
303
+ if method(:subject_qualifies?).parameters.include?([:key, :dynamic_qualifiers])
304
+ subject_qualifies?(subject, context, dynamic_qualifiers: dynamic_qualifiers)
305
+ else
306
+ subject_qualifies?(subject, context)
307
+ end
308
+ end
298
309
  end
@@ -1,3 +1,3 @@
1
1
  module Verdict
2
- VERSION = "0.15.1"
2
+ VERSION = "0.15.2"
3
3
  end
@@ -668,15 +668,31 @@ class ExperimentTest < Minitest::Test
668
668
  custom_qualifier_a = Proc.new { |subject| subject.even? }
669
669
  custom_qualifier_b = Proc.new { |subject| subject > 0 }
670
670
 
671
- e.switch(subject, qualifiers: [custom_qualifier_a, custom_qualifier_b])
672
-
673
671
  group = e.switch(subject, qualifiers: [custom_qualifier_a, custom_qualifier_b])
674
672
  assert_nil group
675
673
  end
676
674
 
675
+ def test_dynamic_subject_qualifies_call_overridden_method
676
+ e = MyExperiment.new('test') do
677
+ groups do
678
+ group :all, 100
679
+ end
680
+ end
681
+
682
+ group = e.switch(4)
683
+ assert_nil group
684
+ end
685
+
677
686
  private
678
687
 
679
688
  def redis
680
689
  @redis ||= ::Redis.new(host: REDIS_HOST, port: REDIS_PORT)
681
690
  end
682
691
  end
692
+
693
+ class MyExperiment < Verdict::Experiment
694
+ def subject_qualifies?(subject, context = nil)
695
+ return false if subject.even?
696
+ super
697
+ end
698
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verdict
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-08 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest