rollout 2.2.4 → 2.3.0

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: 3784af8ad4c004b68a7a82919b817aa8bbc7d2be
4
- data.tar.gz: 576389f114e7a59c035dd1a32e5de72d696a1bc9
3
+ metadata.gz: f64f1c9012cf7fed3496317cec7542d606c1b7b7
4
+ data.tar.gz: af8ead4306e97cd5038a16cc88b495e4dc68c9ca
5
5
  SHA512:
6
- metadata.gz: 48f5979f7396375cbdd583bf90bb50137169ef0796f1298e25ef65577ab6b5cdeaaa657f7ec9fabf6b2a40deb036efe43a154f50a3147b2b554f16b16a5f45b6
7
- data.tar.gz: a379d25c430a815a84e17e406f587560c6ec67c0832e8458523bdde5bb477383a6380779f25f42506a8f26c4872aed62eb210d9773807694c8406019f054cf5b
6
+ metadata.gz: 6972dfe9065234da74ed4f260a8d73ca837828b83793fc7b12ea8327c45fc463af2ab89782ec79a0f8988a0fbcc7af7291e3c829452c8d373a27f72494ba7db7
7
+ data.tar.gz: e82e2f6c194edd80142e88b54419c4d466910438a3b92ee243e2edbd71ea546178b72fedc34749c9ca114851e862221f2009f23e8adedd2fa65213736fbda5b6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rollout (2.2.4)
4
+ rollout (2.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -45,4 +45,4 @@ DEPENDENCIES
45
45
  rspec
46
46
 
47
47
  BUNDLED WITH
48
- 1.10.6
48
+ 1.12.5
@@ -13,7 +13,7 @@ class Rollout
13
13
 
14
14
  if string
15
15
  raw_percentage,raw_users,raw_groups = string.split("|")
16
- @percentage = raw_percentage.to_i
16
+ @percentage = raw_percentage.to_f
17
17
  @users = (raw_users || "").split(",").map(&:to_s).to_set
18
18
  @groups = (raw_groups || "").split(",").map(&:to_sym).to_set
19
19
  else
@@ -85,7 +85,7 @@ class Rollout
85
85
  end
86
86
 
87
87
  def user_in_percentage?(user)
88
- Zlib.crc32(user_id_for_percentage(user)) % 100 < @percentage
88
+ Zlib.crc32(user_id_for_percentage(user)) % 100_000 < @percentage * 1_000
89
89
  end
90
90
 
91
91
  def user_id_for_percentage(user)
@@ -1,3 +1,3 @@
1
1
  class Rollout
2
- VERSION = "2.2.4"
2
+ VERSION = "2.3.0"
3
3
  end
@@ -227,7 +227,7 @@ RSpec.describe "Rollout" do
227
227
  end
228
228
 
229
229
  it "activates the feature for that percentage of the users" do
230
- expect((1..120).select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(1).of(20)
230
+ expect((1..100).select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(2).of(20)
231
231
  end
232
232
  end
233
233
 
@@ -237,7 +237,7 @@ RSpec.describe "Rollout" do
237
237
  end
238
238
 
239
239
  it "activates the feature for that percentage of the users" do
240
- expect((1..200).select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(5).of(40)
240
+ expect((1..200).select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(4).of(40)
241
241
  end
242
242
  end
243
243
 
@@ -251,6 +251,16 @@ RSpec.describe "Rollout" do
251
251
  end
252
252
  end
253
253
 
254
+ describe "activating a feature for a percentage of users" do
255
+ before do
256
+ @rollout.activate_percentage(:chat, 0.1)
257
+ end
258
+
259
+ it "activates the feature for that percentage of the users" do
260
+ expect((1..10_000).to_set.select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(2).of(10)
261
+ end
262
+ end
263
+
254
264
  describe "activating a feature for a percentage of users" do
255
265
  before do
256
266
  @rollout.activate_percentage(:chat, 20)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollout
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Golick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-14 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec