optimizely_server_side 0.0.6 → 0.0.7

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
  SHA1:
3
- metadata.gz: 52a8ee884cb6db767b45acb026984cb413f77dca
4
- data.tar.gz: f674f904ce523f6003db14456367a47df57b48d2
3
+ metadata.gz: 4a8b2715ff8f9919582b449925b0838d4f1590b2
4
+ data.tar.gz: c3f89f698fed6d3590fcd342fe8efcff51370377
5
5
  SHA512:
6
- metadata.gz: 42058be44f0bd1cc8ce1a16b6aae1e7aba342d558a4cc5f8dacf13a97a03f5c3751126cf4ba10839cc89a0701026f32213af3e777345051aa3650c22dc851068
7
- data.tar.gz: 115f4e2b2ee276c8eb29b5160fd83074fc12b25aa01f5fcdaab5eb3400c7fcafad738f7fce52781095a96855f218aa6207dc0c7aa63c22567ee0aed0e5614b2a
6
+ metadata.gz: 47125338faa0d15515e4e0586384b9972ca66703e1c912eaaafb535c1f183f1863d4500d6770703e3359d616c959ccdfe4c8f6224abae16455672b1ae6fbcff1
7
+ data.tar.gz: 146fea8cb394cf5cb687c66534fe6deb9c3b7e0ad902cef1f2a3761f8202206c432edd1af2cb3e418ed9add5f8e60ce30307ad06b86dbcd0e382b58ff21e0314
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format progress
1
+ --format documentation
2
2
  --color
data/Gemfile.lock CHANGED
@@ -40,8 +40,6 @@ GEM
40
40
  rspec-core (~> 3.5.0)
41
41
  rspec-expectations (~> 3.5.0)
42
42
  rspec-mocks (~> 3.5.0)
43
- rspec-collection_matchers (1.1.2)
44
- rspec-expectations (>= 2.99.0.beta1)
45
43
  rspec-core (3.5.2)
46
44
  rspec-support (~> 3.5.0)
47
45
  rspec-expectations (3.5.0)
@@ -72,7 +70,6 @@ DEPENDENCIES
72
70
  codeclimate-test-reporter
73
71
  optimizely_server_side!
74
72
  rspec (~> 3.5)
75
- rspec-collection_matchers (~> 1.1, >= 1.1.2)
76
73
  webmock (~> 2.1)
77
74
 
78
75
  BUNDLED WITH
data/Readme.md CHANGED
@@ -29,7 +29,7 @@ This gem solves few things:
29
29
 
30
30
  ### Architecture
31
31
 
32
- ![alt text](https://github.com/ankit8898/optimizely_server_side/blob/master/docs/general_architecture.png
32
+ ![alt Architecture](https://github.com/ankit8898/optimizely_server_side/blob/master/docs/general_architecture.png
33
33
  "Architecture")
34
34
 
35
35
  ### Getting Started
@@ -125,7 +125,24 @@ class Foo
125
125
  end
126
126
  end
127
127
  ```
128
+ #### Don't want to stick with variation_one, variation_two ?
128
129
 
130
+ You can call you own method names with `variation_` . Below i have `config.variation_best_experience` and `config.variation_pathetic_experience`.
131
+
132
+
133
+ ```ruby
134
+ # in any app/view/foo.html.erb
135
+ <% experiment(EXPERIMENT_KEY) do |config| %>
136
+ <% config.variation_best_experience(VARIATION_ONE_KEY) do %>
137
+ <%= render partial: 'variation_one_experience'
138
+ <% end %>
139
+
140
+ <% config.variation_pathetic_experience(VARIATION_DEFAULT_KEY, primary: true) do %>
141
+ <%= render partial: 'variation_default_experience'
142
+ <% end %>
143
+ <% end %>
144
+
145
+ ```
129
146
  In the above examples:
130
147
 
131
148
  `EXPERIMENT_KEY`: When you will set your experiment this key will be set up that time at https://app.optimizely.com.
@@ -138,7 +155,7 @@ In the above examples:
138
155
 
139
156
  `primary: true` : If you see above some variations are marked with `primary: true`. This enables handling the fallback capabilities of optimizely_server_side. If there is any error pulling datafile or experiment is paused the `primary` experience is served. Not setting primary won't give any experience during fallback times. We encourage setting it up.
140
157
 
141
- ![alt text](https://github.com/ankit8898/optimizely_server_side/blob/master/docs/screenshot.png "Logo Title Text 1")
158
+ ![alt Optimizely dashboard](https://github.com/ankit8898/optimizely_server_side/blob/master/docs/screenshot.png "Optimizely dashboard")
142
159
 
143
160
 
144
161
  ### Instrumentation
@@ -15,13 +15,14 @@ module OptimizelyServerSide
15
15
 
16
16
  class << self
17
17
  attr_writer :configuration
18
- end
19
18
 
20
- def self.configuration
21
- @configuration ||= Configuration.new
22
- end
19
+ def configuration
20
+ @configuration ||= Configuration.new
21
+ end
23
22
 
24
- def self.configure
25
- yield(configuration)
23
+ def configure
24
+ yield(configuration)
25
+ end
26
26
  end
27
+
27
28
  end
@@ -12,15 +12,25 @@ module OptimizelyServerSide
12
12
  self.applicable_variation
13
13
  end
14
14
 
15
- [
16
- :variation_one,
17
- :variation_two,
18
- :variation_three,
19
- :variation_default,
20
- ].each do |variation|
21
- define_method(variation) do |key, opts={}, &blk| # def variation_one(key, opts = {}, &blk)
22
- add_variation(key, opts, &blk) # add_variation(key, opts, &blk)
23
- end # end
15
+ def variation_one(key, opts = {}, &blk)
16
+ add_variation(key, opts, &blk)
17
+ end
18
+
19
+ def variation_two(key, opts = {}, &blk)
20
+ add_variation(key, opts, &blk)
21
+ end
22
+
23
+ def variation_default(key, opts = {}, &blk)
24
+ add_variation(key, opts, &blk)
25
+ end
26
+
27
+ # Support for variation_three, variation_four till variation_n
28
+ def method_missing(key, *args, &blk)
29
+ if key.to_s.match('variation_')
30
+ add_variation(args[0], args[1] || {}, &blk)
31
+ else
32
+ super
33
+ end
24
34
  end
25
35
 
26
36
  # Selects and calls the variation which is applicable
@@ -2,8 +2,8 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'optimizely_server_side'
5
- s.version = '0.0.6'
6
- s.date = '2016-08-14'
5
+ s.version = '0.0.7'
6
+ s.date = '2016-08-15'
7
7
  s.summary = "Optimizely server side. A wrapper on top of optimizely's ruby sdk for easy caching of server side config "
8
8
  s.description = "Optimizely server side. A A/B test wrapper on top of optimizely's ruby sdk for easy caching of server side config and exposing few more utility helpers. Handling of fallbacks and marking primary experiments. "
9
9
  s.authors = ["Ankit Gupta"]
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
  'https://github.com/ankit8898/optimizely_server_side'
17
17
  s.license = 'MIT'
18
18
  s.add_development_dependency 'rspec', '~> 3.5'
19
- s.add_development_dependency 'rspec-collection_matchers', '~> 1.1', '>= 1.1.2'
20
19
  s.add_development_dependency 'webmock', '~> 2.1'
21
20
  s.add_runtime_dependency 'optimizely-sdk' , '~> 0.1.1'
22
21
  s.add_runtime_dependency 'activesupport', '~> 4.2', '>= 4.2.6'
@@ -37,6 +37,31 @@ RSpec.describe OptimizelyServerSide::Experiment do
37
37
  end
38
38
 
39
39
 
40
+ context 'when the variation are named anything else' do
41
+
42
+ subject { OptimizelyServerSide::Experiment.new(variation_key = 'foobar') }
43
+
44
+ let(:some_method) { Proc.new {|n| n*2 } }
45
+
46
+ let(:some_html_block) do
47
+ -> { '<h1>Foo</h1>' }
48
+ end
49
+
50
+ let(:string_blk) { -> { 'Hello!'} }
51
+
52
+
53
+ before do
54
+ subject.variation_bottom_lead_form('foo', &some_method)
55
+
56
+ subject.variation_middle_lead_form('foo_two', primary: true, &some_html_block)
57
+
58
+ subject.variation_pathetic_form('foobar', &string_blk)
59
+ end
60
+
61
+ it { expect(subject.applicable_variation).to eq('Hello!') }
62
+ end
63
+
64
+
40
65
  end
41
66
 
42
67
  describe '#variation_one' do
@@ -141,6 +166,32 @@ RSpec.describe OptimizelyServerSide::Experiment do
141
166
  end
142
167
  end
143
168
 
169
+
170
+ describe '#variation_bottom_lead_form' do
171
+
172
+ let(:blk) { -> {'<div><h1>Hello</h1></div>'} }
173
+
174
+ before do
175
+ @variation_instance = subject.variation_bottom_lead_form('foo', primary: true, &blk)
176
+ end
177
+
178
+ it 'returns a variation instance passed' do
179
+ expect(@variation_instance).to be_kind_of(OptimizelyServerSide::Variation)
180
+ end
181
+
182
+ it 'returns a key of foo' do
183
+ expect(@variation_instance.key).to eq('foo')
184
+ end
185
+
186
+ it 'returns a content with blk ' do
187
+ expect(@variation_instance.instance_variable_get(:@content)).to eq(blk)
188
+ end
189
+
190
+ it 'is primary' do
191
+ expect(@variation_instance.primary).to be(true)
192
+ end
193
+ end
194
+
144
195
  describe '#variations' do
145
196
 
146
197
  context 'key accepts regular strings' do
@@ -152,7 +203,7 @@ RSpec.describe OptimizelyServerSide::Experiment do
152
203
  end
153
204
 
154
205
  it 'holds collection of variations' do
155
- expect(subject.instance_variable_get(:@variations)).to have(1).items
206
+ expect(subject.instance_variable_get(:@variations).count).to eq(1)
156
207
  end
157
208
 
158
209
  it 'is a type of Variation' do
@@ -216,7 +267,7 @@ RSpec.describe OptimizelyServerSide::Experiment do
216
267
  end
217
268
 
218
269
  it 'has all variations' do
219
- expect(subject.instance_variable_get(:@variations)).to have(3).items
270
+ expect(subject.instance_variable_get(:@variations).count).to eq(3)
220
271
  end
221
272
 
222
273
  it 'has all variations of class Variation' do
@@ -282,5 +333,21 @@ RSpec.describe OptimizelyServerSide::Experiment do
282
333
  it { expect(subject.primary_variation.call).to eq('<h1>Foo</h1>') }
283
334
  end
284
335
 
336
+
337
+ context 'when test are having own variation names' do
338
+
339
+ before do
340
+ subject.variation_bottom_lead_form('foo', &some_method)
341
+
342
+ subject.variation_middle_lead_form('foo_two', primary: true, &some_html_block)
343
+
344
+ subject.variation_pathetic_form('foo_three',&string_blk)
345
+ end
346
+
347
+ it { expect(subject.primary_variation).not_to be_nil }
348
+
349
+ it { expect(subject.primary_variation.call).to eq('<h1>Foo</h1>') }
350
+ end
351
+
285
352
  end
286
353
  end
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,6 @@ CodeClimate::TestReporter.start
3
3
 
4
4
  require 'bundler/setup'
5
5
  require 'webmock/rspec'
6
- require 'rspec/collection_matchers'
7
6
 
8
7
  Bundler.setup
9
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optimizely_server_side
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankit Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-14 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -24,26 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.5'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec-collection_matchers
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 1.1.2
37
- type: :development
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '1.1'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 1.1.2
47
27
  - !ruby/object:Gem::Dependency
48
28
  name: webmock
49
29
  requirement: !ruby/object:Gem::Requirement
@@ -106,7 +86,6 @@ files:
106
86
  - Gemfile
107
87
  - Gemfile.lock
108
88
  - Readme.md
109
- - blocky.rb
110
89
  - docs/general_architecture.png
111
90
  - docs/screenshot.png
112
91
  - lib/optimizely_server_side.rb