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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2285d1f81e213c214eba67b891e72bd671b2dea7096759ba142bd8457197c671
4
- data.tar.gz: d560e6dc20e028641bea194e4626b2103e0e4999e40308b3f3d9009574090c64
3
+ metadata.gz: 8a26786a65478a45e78fe52884fd99b5a5a7e390bde362ce211832e57e3f66f9
4
+ data.tar.gz: 6a75c2816df20f8ead6f24bcab02f4c2460fad380f6fbcd2ef1a79c3f9234fb9
5
5
  SHA512:
6
- metadata.gz: 31b1406c3ab135e4bf628040914ea4057ab37bef82909e180da668d60365abf480081819720d4d044baabea59940167f3353d2478ba3433a1867e035dce981e9
7
- data.tar.gz: 2f78138c8de1ae3b96bdf511effbad20cf0e08b66764ce82b159f024c32868c78f9ced8c6918bc52ce316b7599a4301f03583006d58de441f72835a694aa4a09
6
+ metadata.gz: 47ecb8aeb5efb349c5a7366a559bd8eab2beb38dde0b19aa1202deae013072a3b158c1e77825241a372f2543287022d6a1d9e649755bf0130c3d823e6f604fdf
7
+ data.tar.gz: fba2c4ca6ab07e14623d06470f733f54f1415198586792e5aee6e2f81e896a5c02973c0b2efb550d10e63d861cb0d617e23fbd6b87e4681c289322a408838f27
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.6.0
2
+
3
+ * Failure to load strategies in test environments will result in a warning instead of an error. This should aid in running Rake tasks.
4
+
1
5
  ## 2.5.0
2
6
 
3
7
  * Add Sequel strategy. ActiveRecord/Sequel can be used side by side.
@@ -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
@@ -28,7 +28,10 @@ module Flipflop
28
28
  private :new
29
29
  end
30
30
 
31
+ attr_reader :raise_strategy_errors
32
+
31
33
  def initialize
34
+ @raise_strategy_errors = (ENV["RACK_ENV"] || ENV["RAILS_ENV"]) != "test"
32
35
  @features = {}
33
36
  @strategies = {}
34
37
  end
@@ -1,3 +1,3 @@
1
1
  module Flipflop
2
- VERSION = "2.5.0"
2
+ VERSION = "2.6.0"
3
3
  end
@@ -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
- silence_stdout { ActiveRecord::Tasks::DatabaseTasks.create_current }
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.5.0
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-04-19 00:00:00.000000000 Z
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
- rubygems_version: 3.0.3
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.