flipflop 2.5.0 → 2.6.0
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 +4 -4
- data/CHANGES.md +4 -0
- data/lib/flipflop/configurable.rb +6 -0
- data/lib/flipflop/feature_set.rb +3 -0
- data/lib/flipflop/version.rb +1 -1
- data/test/test_helper.rb +16 -7
- data/test/unit/configurable_test.rb +32 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a26786a65478a45e78fe52884fd99b5a5a7e390bde362ce211832e57e3f66f9
|
4
|
+
data.tar.gz: 6a75c2816df20f8ead6f24bcab02f4c2460fad380f6fbcd2ef1a79c3f9234fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47ecb8aeb5efb349c5a7366a559bd8eab2beb38dde0b19aa1202deae013072a3b158c1e77825241a372f2543287022d6a1d9e649755bf0130c3d823e6f604fdf
|
7
|
+
data.tar.gz: fba2c4ca6ab07e14623d06470f733f54f1415198586792e5aee6e2f81e896a5c02973c0b2efb550d10e63d861cb0d617e23fbd6b87e4681c289322a408838f27
|
data/CHANGES.md
CHANGED
@@ -32,6 +32,12 @@ module Flipflop
|
|
32
32
|
end
|
33
33
|
|
34
34
|
FeatureSet.current.use(strategy)
|
35
|
+
rescue StandardError => err
|
36
|
+
if FeatureSet.current.raise_strategy_errors
|
37
|
+
raise err
|
38
|
+
else
|
39
|
+
warn "WARNING: Unable to load Flipflop strategy #{strategy}: #{err}"
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
data/lib/flipflop/feature_set.rb
CHANGED
data/lib/flipflop/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -31,6 +31,20 @@ def create_request
|
|
31
31
|
request
|
32
32
|
end
|
33
33
|
|
34
|
+
def capture_stdout
|
35
|
+
stdout, $stdout = $stdout, StringIO.new
|
36
|
+
yield rescue nil
|
37
|
+
stdout, $stdout = $stdout, stdout
|
38
|
+
stdout.string
|
39
|
+
end
|
40
|
+
|
41
|
+
def capture_stderr
|
42
|
+
stderr, $stderr = $stderr, StringIO.new
|
43
|
+
yield rescue nil
|
44
|
+
stderr, $stderr = $stderr, stderr
|
45
|
+
stderr.string
|
46
|
+
end
|
47
|
+
|
34
48
|
def reload_constant(name)
|
35
49
|
ActiveSupport::Dependencies.remove_constant(name.to_s)
|
36
50
|
path = ActiveSupport::Dependencies.search_for_file(name.to_s.underscore).sub!(/\.rb\z/, "")
|
@@ -162,7 +176,7 @@ class TestApp
|
|
162
176
|
def migrate!
|
163
177
|
ActiveRecord::Base.establish_connection
|
164
178
|
|
165
|
-
|
179
|
+
capture_stdout { ActiveRecord::Tasks::DatabaseTasks.create_current }
|
166
180
|
ActiveRecord::Migration.verbose = false
|
167
181
|
|
168
182
|
if defined?(ActiveRecord::Migrator.migrate)
|
@@ -174,6 +188,7 @@ class TestApp
|
|
174
188
|
end
|
175
189
|
|
176
190
|
def unload!
|
191
|
+
ENV["RAILS_ENV"] = nil
|
177
192
|
Flipflop::Strategies::AbstractStrategy::RequestInterceptor.request = nil
|
178
193
|
Flipflop::FeatureLoader.instance_variable_set(:@current, nil)
|
179
194
|
|
@@ -192,12 +207,6 @@ class TestApp
|
|
192
207
|
|
193
208
|
private
|
194
209
|
|
195
|
-
def silence_stdout
|
196
|
-
stdout, $stdout = $stdout, StringIO.new
|
197
|
-
yield rescue nil
|
198
|
-
$stdout = stdout
|
199
|
-
end
|
200
|
-
|
201
210
|
def path
|
202
211
|
"tmp/" + name
|
203
212
|
end
|
@@ -1,5 +1,12 @@
|
|
1
1
|
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
|
+
class FailingStrategy < Flipflop::Strategies::AbstractStrategy
|
4
|
+
def initialize(*)
|
5
|
+
raise "Oops"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
3
10
|
describe Flipflop::Configurable do
|
4
11
|
subject do
|
5
12
|
Flipflop::FeatureSet.current.send(:initialize)
|
@@ -100,5 +107,30 @@ describe Flipflop::Configurable do
|
|
100
107
|
assert_equal ["awesome"],
|
101
108
|
Flipflop::FeatureSet.current.strategies.map(&:description)
|
102
109
|
end
|
110
|
+
|
111
|
+
it "should raise error when strategy fails to load" do
|
112
|
+
begin
|
113
|
+
rack_env, ENV["RACK_ENV"] = ENV["RACK_ENV"], nil
|
114
|
+
rails_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], nil
|
115
|
+
assert_raises "Oops" do
|
116
|
+
subject.strategy(FailingStrategy)
|
117
|
+
end
|
118
|
+
ensure
|
119
|
+
ENV["RACK_ENV"] = rack_env
|
120
|
+
ENV["RAILS_ENV"] = rails_env
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should not raise error when strategy fails to load in test mode" do
|
125
|
+
begin
|
126
|
+
rack_env, ENV["RACK_ENV"] = ENV["RACK_ENV"], "test"
|
127
|
+
rails_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "test"
|
128
|
+
assert_equal "WARNING: Unable to load Flipflop strategy FailingStrategy: Oops\n",
|
129
|
+
capture_stderr { subject.strategy(FailingStrategy) }
|
130
|
+
ensure
|
131
|
+
ENV["RACK_ENV"] = rack_env
|
132
|
+
ENV["RAILS_ENV"] = rails_env
|
133
|
+
end
|
134
|
+
end
|
103
135
|
end
|
104
136
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipflop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Annesley
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -128,7 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.7.7
|
132
133
|
signing_key:
|
133
134
|
specification_version: 4
|
134
135
|
summary: A feature flipflopper for Rails web applications.
|