vinted-ab 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f227fe8202a3994a25c47c152ed4ca675ad5d571
4
- data.tar.gz: f50d6b977402e19d57a62cba1a9affcf749d011a
3
+ metadata.gz: 524583866170f2c146e62a8e3e0856c70c182c30
4
+ data.tar.gz: 5d2eb21da061a576bf9ba799980f205c69cf5150
5
5
  SHA512:
6
- metadata.gz: dedbd7a58d4d5490e6a27677f36e31dc426ec762a063bbb10c7c2b80cd41fa11efed903e575a63f0dc301603f41529d30eb285e1e836ca39b5196e3b40f188bd
7
- data.tar.gz: 41246c457af514bea7a803938b3418a87a195e4cae254abe0080ea081ffd6e850f5a183c1065af8a7a9077257af6b649c961b92cf2d29bbc1d67ee051a9d382c
6
+ metadata.gz: f272ba169ff0cf3f0ca4c17595cc1d2a0ea2d66573534f2e4f1fd6f316b374dffba59f8b3561bffcc3af143908f8ee111d87689a45c37a5d6c5796498685ecd3
7
+ data.tar.gz: 58155d2dca6f2cc55cb61ba557e8ddd9d59126b282d6bd4588cf8e421e3d4c96af0956437b64a4bba65746cc6dea232566384c1876cd97efe029d9419d556f8c
@@ -25,11 +25,11 @@ module Ab
25
25
  return unless part_of_test?
26
26
  return unless running?
27
27
 
28
- AssignedTest.before.call(@test.name) if run_callbacks && AssignedTest.before.respond_to?(:call)
28
+ AssignedTest.before.call(name) if run_callbacks && AssignedTest.before.respond_to?(:call)
29
29
  picked_variant = @test.variants.find { |v| v.accumulated_chance_weight > weight_id }
30
30
 
31
31
  result = picked_variant.name if picked_variant
32
- AssignedTest.after.call(@test.name, result) if run_callbacks && AssignedTest.after.respond_to?(:call)
32
+ AssignedTest.after.call(name, result) if run_callbacks && AssignedTest.after.respond_to?(:call)
33
33
  result
34
34
  end
35
35
  end
@@ -48,6 +48,10 @@ module Ab
48
48
 
49
49
  private
50
50
 
51
+ def name
52
+ @test.name
53
+ end
54
+
51
55
  def part_of_test?
52
56
  @test.all_buckets? ||
53
57
  @test.buckets && @test.buckets.include?(bucket_id)
@@ -58,7 +62,7 @@ module Ab
58
62
  end
59
63
 
60
64
  def running?
61
- DateTime.now.between?(@test.start_at, @test.end_at)
65
+ DateTime.now.between?(start_at, end_at)
62
66
  end
63
67
 
64
68
  def weight_id
@@ -20,7 +20,13 @@ module Ab
20
20
  end
21
21
 
22
22
  def log_missing_variant(meth)
23
- Ab.config.logger.debug("[AB_testing] Checking non-existing variant: #{meth}")
23
+ return unless name
24
+
25
+ Ab.config.logger.debug("[AB_testing] Checking non-existing variant: #{name}##{meth}")
26
+ end
27
+
28
+ def name
29
+ nil
24
30
  end
25
31
  end
26
32
  end
@@ -1,3 +1,3 @@
1
1
  module Ab
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
@@ -18,7 +18,7 @@ module Ab
18
18
 
19
19
  context 'with non existent variant' do
20
20
  let(:variants) { [OpenStruct.new(name: 'enabled', accumulated_chance_weight: 2)] }
21
- let(:message) { '[AB_testing] Checking non-existing variant: disabled?' }
21
+ let(:message) { '[AB_testing] Checking non-existing variant: feed#disabled?' }
22
22
 
23
23
  before { Ab.config.logger.should_receive(:debug).with(message) }
24
24
 
@@ -8,8 +8,12 @@ module Ab
8
8
  its(:start_at) { should_not be_nil }
9
9
  its(:end_at) { should_not be_nil }
10
10
 
11
- specify 'does not raise for method ending in question mark' do
12
- lambda { subject.bla? }.should_not raise_error
11
+ context 'with method ending in question mark' do
12
+ before { Ab.config.logger.should_not_receive(:debug) }
13
+
14
+ specify 'does not raise' do
15
+ lambda { subject.bla? }.should_not raise_error
16
+ end
13
17
  end
14
18
 
15
19
  specify 'raises for method not ending in question mark' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vinted-ab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-19 00:00:00.000000000 Z
12
+ date: 2015-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake