flipflop 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +0 -1
- data/.travis.yml +23 -27
- data/CHANGES.md +7 -0
- data/Gemfile +14 -8
- data/README.md +27 -1
- data/Rakefile +20 -8
- data/app/controllers/flipflop/features_controller.rb +20 -10
- data/app/controllers/flipflop/strategies_controller.rb +4 -4
- data/app/views/flipflop/features/index.html.erb +64 -41
- data/app/views/flipflop/stylesheets/_flipflop.css +1 -0
- data/app/views/layouts/flipflop.html.erb +8 -1
- data/config/features.rb +7 -0
- data/config/locales/en.yml +34 -0
- data/flipflop.gemspec +0 -5
- data/lib/flipflop/configurable.rb +10 -0
- data/lib/flipflop/engine.rb +10 -15
- data/lib/flipflop/feature_definition.rb +5 -6
- data/lib/flipflop/feature_loader.rb +40 -0
- data/lib/flipflop/feature_set.rb +7 -9
- data/lib/flipflop/group_definition.rb +11 -0
- data/lib/flipflop/strategies/abstract_strategy.rb +2 -1
- data/lib/flipflop/version.rb +1 -1
- data/lib/flipflop.rb +2 -0
- data/lib/test_engine/config/features.rb +3 -0
- data/lib/test_engine/test_engine.rb +7 -0
- data/src/stylesheets/_flipflop.scss +160 -0
- data/test/integration/app_test.rb +50 -21
- data/test/integration/dashboard_test.rb +395 -52
- data/test/templates/nl.yml +30 -0
- data/test/templates/test_app_features.rb +7 -0
- data/test/templates/test_engine.rb +7 -0
- data/test/templates/test_engine_features.rb +3 -0
- data/test/test_helper.rb +83 -10
- data/test/unit/configurable_test.rb +1 -1
- data/test/unit/feature_definition_test.rb +27 -2
- data/test/unit/feature_set_test.rb +7 -19
- data/test/unit/flipflop_test.rb +16 -11
- data/test/unit/group_definition_test.rb +21 -0
- data/test/unit/strategies/abstract_strategy_test.rb +14 -25
- data/test/unit/strategies/active_record_strategy_test.rb +4 -0
- data/test/unit/strategies/cookie_strategy_test.rb +4 -0
- data/test/unit/strategies/default_strategy_test.rb +10 -4
- data/test/unit/strategies/lambda_strategy_test.rb +11 -27
- data/test/unit/strategies/query_string_strategy_test.rb +4 -0
- data/test/unit/strategies/redis_strategy_test.rb +4 -0
- data/test/unit/strategies/session_strategy_test.rb +4 -0
- data/test/unit/strategies/test_strategy_test.rb +4 -0
- metadata +22 -9
- data/app/assets/stylesheets/flipflop.css +0 -1
data/test/test_helper.rb
CHANGED
@@ -5,6 +5,7 @@ gem "minitest"
|
|
5
5
|
require "minitest/autorun"
|
6
6
|
|
7
7
|
require "action_controller"
|
8
|
+
require "rails/generators"
|
8
9
|
|
9
10
|
# Who is setting this to true? :o
|
10
11
|
$VERBOSE = false
|
@@ -37,29 +38,67 @@ def reload_constant(name)
|
|
37
38
|
Object.const_get(name)
|
38
39
|
end
|
39
40
|
|
41
|
+
class TestEngineGenerator < Rails::Generators::Base
|
42
|
+
source_root File.expand_path("../templates", __FILE__)
|
43
|
+
|
44
|
+
def copy_engine_file
|
45
|
+
copy_file "test_engine.rb", "lib/test_engine/test_engine.rb"
|
46
|
+
end
|
47
|
+
|
48
|
+
def copy_engine_features_file
|
49
|
+
copy_file "test_engine_features.rb", "lib/test_engine/config/features.rb"
|
50
|
+
end
|
51
|
+
|
52
|
+
def require_engine
|
53
|
+
environment "require 'test_engine/test_engine'"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class TestFeaturesGenerator < Rails::Generators::Base
|
58
|
+
source_root File.expand_path("../templates", __FILE__)
|
59
|
+
|
60
|
+
def copy_app_features_file
|
61
|
+
copy_file "test_app_features.rb", "config/features.rb"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class TestLocaleGenerator < Rails::Generators::Base
|
66
|
+
source_root File.expand_path("../templates", __FILE__)
|
67
|
+
|
68
|
+
def copy_locale_file
|
69
|
+
copy_file "nl.yml", "config/locales/nl.yml"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
40
73
|
class TestApp
|
41
74
|
class << self
|
42
|
-
def new
|
43
|
-
|
44
|
-
super.tap do |current|
|
75
|
+
def new(generators = [])
|
76
|
+
name = "my_test_app"
|
77
|
+
super(name, generators).tap do |current|
|
45
78
|
current.create!
|
46
79
|
current.load!
|
47
80
|
current.migrate!
|
48
|
-
reload_constant("Flipflop::Feature")
|
49
81
|
end
|
50
82
|
end
|
51
83
|
end
|
52
84
|
|
85
|
+
attr_reader :name, :generators
|
86
|
+
|
87
|
+
def initialize(name, generators = [])
|
88
|
+
@name = name
|
89
|
+
@generators = generators
|
90
|
+
end
|
91
|
+
|
53
92
|
def create!
|
54
|
-
require "rails/generators"
|
55
93
|
require "rails/generators/rails/app/app_generator"
|
56
94
|
require "generators/flipflop/install/install_generator"
|
57
95
|
|
58
|
-
FileUtils.rm_rf(File.expand_path("../../
|
96
|
+
FileUtils.rm_rf(File.expand_path("../../" + path, __FILE__))
|
59
97
|
Dir.chdir(File.expand_path("../..", __FILE__))
|
60
98
|
|
61
|
-
Rails::Generators::AppGenerator.new([
|
99
|
+
Rails::Generators::AppGenerator.new([path],
|
62
100
|
quiet: true,
|
101
|
+
api: ENV["RAILS_API_ONLY"].to_i.nonzero?,
|
63
102
|
skip_active_job: true,
|
64
103
|
skip_bundle: true,
|
65
104
|
skip_gemfile: true,
|
@@ -74,15 +113,26 @@ class TestApp
|
|
74
113
|
Flipflop::InstallGenerator.new([],
|
75
114
|
quiet: true,
|
76
115
|
).invoke_all
|
116
|
+
|
117
|
+
generators.each do |generator|
|
118
|
+
generator.new([], quiet: true, force: true).invoke_all
|
119
|
+
end
|
77
120
|
end
|
78
121
|
|
79
122
|
def load!
|
80
123
|
ENV["RAILS_ENV"] = "test"
|
81
124
|
require "rails"
|
82
125
|
require "flipflop/engine"
|
83
|
-
|
84
|
-
|
85
|
-
load(
|
126
|
+
|
127
|
+
load File.expand_path("../../#{path}/config/application.rb", __FILE__)
|
128
|
+
load File.expand_path("../../#{path}/config/environments/test.rb", __FILE__)
|
129
|
+
Rails.application.config.cache_classes = false
|
130
|
+
Rails.application.config.action_view.raise_on_missing_translations = true
|
131
|
+
Rails.application.config.i18n.enforce_available_locales = false
|
132
|
+
Rails.application.initialize!
|
133
|
+
|
134
|
+
I18n.locale = :en
|
135
|
+
|
86
136
|
require "capybara/rails"
|
87
137
|
end
|
88
138
|
|
@@ -94,9 +144,32 @@ class TestApp
|
|
94
144
|
ActiveRecord::Migrator.migrate(Rails.application.paths["db/migrate"].to_a)
|
95
145
|
end
|
96
146
|
|
147
|
+
def unload!
|
148
|
+
Flipflop::Strategies::AbstractStrategy::RequestInterceptor.request = nil
|
149
|
+
Flipflop::FeatureLoader.instance_variable_set(:@current, nil)
|
150
|
+
|
151
|
+
match = -> (path) { path.include?(File.expand_path("../..", __FILE__)) }
|
152
|
+
Rails.application.config.i18n.railties_load_path.reject!(&match)
|
153
|
+
Rails.application.config.i18n.load_path.reject!(&match)
|
154
|
+
I18n.load_path.reject!(&match)
|
155
|
+
|
156
|
+
Rails.app_class.instance_variable_set(:@instance, nil) if defined?(Rails.app_class)
|
157
|
+
Rails.instance_variable_set(:@application, nil)
|
158
|
+
I18n::Railtie.instance_variable_set(:@i18n_inited, false)
|
159
|
+
|
160
|
+
ActiveSupport::Dependencies.remove_constant(name.camelize)
|
161
|
+
ActiveSupport::Dependencies.remove_constant("Flipflop::Feature")
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
|
97
166
|
def silence_stdout
|
98
167
|
stdout, $stdout = $stdout, StringIO.new
|
99
168
|
yield rescue nil
|
100
169
|
$stdout = stdout
|
101
170
|
end
|
171
|
+
|
172
|
+
def path
|
173
|
+
"tmp/" + name
|
174
|
+
end
|
102
175
|
end
|
@@ -10,13 +10,25 @@ describe Flipflop::FeatureDefinition do
|
|
10
10
|
assert_equal :my_key, subject.key
|
11
11
|
end
|
12
12
|
|
13
|
-
it "should have
|
14
|
-
assert_equal "
|
13
|
+
it "should have name derived from key" do
|
14
|
+
assert_equal "my_key", subject.name
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have title derived from key" do
|
18
|
+
assert_equal "My key", subject.title
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have no description" do
|
22
|
+
assert_nil subject.description
|
15
23
|
end
|
16
24
|
|
17
25
|
it "should default to false" do
|
18
26
|
assert_equal false, subject.default
|
19
27
|
end
|
28
|
+
|
29
|
+
it "should have no group" do
|
30
|
+
assert_nil subject.group
|
31
|
+
end
|
20
32
|
end
|
21
33
|
|
22
34
|
describe "with options" do
|
@@ -24,6 +36,7 @@ describe Flipflop::FeatureDefinition do
|
|
24
36
|
Flipflop::FeatureDefinition.new(:my_key,
|
25
37
|
default: true,
|
26
38
|
description: "Awesome feature",
|
39
|
+
group: Flipflop::GroupDefinition.new(:my_group),
|
27
40
|
)
|
28
41
|
end
|
29
42
|
|
@@ -31,6 +44,14 @@ describe Flipflop::FeatureDefinition do
|
|
31
44
|
assert_equal :my_key, subject.key
|
32
45
|
end
|
33
46
|
|
47
|
+
it "should have name derived from key" do
|
48
|
+
assert_equal "my_key", subject.name
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have title derived from key" do
|
52
|
+
assert_equal "My key", subject.title
|
53
|
+
end
|
54
|
+
|
34
55
|
it "should have specified description" do
|
35
56
|
assert_equal "Awesome feature", subject.description
|
36
57
|
end
|
@@ -38,5 +59,9 @@ describe Flipflop::FeatureDefinition do
|
|
38
59
|
it "should have specified default" do
|
39
60
|
assert_equal true, subject.default
|
40
61
|
end
|
62
|
+
|
63
|
+
it "should have specified group" do
|
64
|
+
assert_equal :my_group, subject.group.key
|
65
|
+
end
|
41
66
|
end
|
42
67
|
end
|
@@ -19,7 +19,7 @@ end
|
|
19
19
|
|
20
20
|
describe Flipflop::FeatureSet do
|
21
21
|
subject do
|
22
|
-
Flipflop::FeatureSet.current.
|
22
|
+
Flipflop::FeatureSet.current.send(:initialize)
|
23
23
|
Flipflop::FeatureSet.current.tap do |set|
|
24
24
|
set.add(Flipflop::FeatureDefinition.new(:one))
|
25
25
|
end
|
@@ -105,18 +105,12 @@ describe Flipflop::FeatureSet do
|
|
105
105
|
assert subject.feature(feature.key).frozen?
|
106
106
|
end
|
107
107
|
|
108
|
-
it "should raise if feature with same key is added" do
|
108
|
+
it "should raise error with message if feature with same key is added" do
|
109
109
|
subject.add(Flipflop::FeatureDefinition.new(:feature))
|
110
|
-
assert_raises Flipflop::FeatureError do
|
111
|
-
subject.add(Flipflop::FeatureDefinition.new(:feature))
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should raise with message if feature with same key is added" do
|
116
|
-
subject.add(Flipflop::FeatureDefinition.new(:feature))
|
117
|
-
assert_raises Flipflop::FeatureError do
|
110
|
+
error = assert_raises Flipflop::FeatureError do
|
118
111
|
subject.add(Flipflop::FeatureDefinition.new(:feature))
|
119
112
|
end
|
113
|
+
assert_equal "Feature 'feature' already defined.", error.message
|
120
114
|
end
|
121
115
|
end
|
122
116
|
|
@@ -131,18 +125,12 @@ describe Flipflop::FeatureSet do
|
|
131
125
|
assert subject.strategy(strategy.key).frozen?
|
132
126
|
end
|
133
127
|
|
134
|
-
it "should raise if strategy with same key is added" do
|
128
|
+
it "should raise error with message if strategy with same key is added" do
|
135
129
|
subject.use(NullStrategy.new)
|
136
|
-
assert_raises Flipflop::StrategyError do
|
137
|
-
subject.use(NullStrategy.new)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
it "should raise with message if strategy with same key is added" do
|
142
|
-
subject.use(NullStrategy.new)
|
143
|
-
assert_raises Flipflop::StrategyError do
|
130
|
+
error = assert_raises Flipflop::StrategyError do
|
144
131
|
subject.use(NullStrategy.new)
|
145
132
|
end
|
133
|
+
assert_equal "Strategy 'null' (NullStrategy) already defined with identical options.", error.message
|
146
134
|
end
|
147
135
|
end
|
148
136
|
|
data/test/unit/flipflop_test.rb
CHANGED
@@ -2,22 +2,25 @@ require File.expand_path("../../test_helper", __FILE__)
|
|
2
2
|
|
3
3
|
describe Flipflop do
|
4
4
|
before do
|
5
|
-
Flipflop.
|
6
|
-
|
7
|
-
|
5
|
+
Flipflop::FeatureSet.current.replace do
|
6
|
+
Flipflop.configure do
|
7
|
+
feature :one, default: true
|
8
|
+
feature :two, default: false
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
11
|
-
describe "
|
13
|
+
describe "replace" do
|
12
14
|
before do
|
13
|
-
Flipflop.
|
14
|
-
|
15
|
+
Flipflop::FeatureSet.current.replace do
|
16
|
+
Flipflop.configure do
|
17
|
+
feature :config_feature, default: true
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
22
|
it "should reset feature set" do
|
19
|
-
Flipflop.
|
20
|
-
end
|
23
|
+
Flipflop::FeatureSet.current.replace
|
21
24
|
assert_equal [], Flipflop::FeatureSet.current.features
|
22
25
|
end
|
23
26
|
|
@@ -57,9 +60,11 @@ describe Flipflop do
|
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
|
-
Flipflop.
|
61
|
-
|
62
|
-
|
63
|
+
Flipflop::FeatureSet.current.replace do
|
64
|
+
Flipflop.configure do
|
65
|
+
strategy counter
|
66
|
+
feature :one, default: true
|
67
|
+
end
|
63
68
|
end
|
64
69
|
|
65
70
|
begin
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
describe Flipflop::GroupDefinition do
|
4
|
+
describe "with defaults" do
|
5
|
+
subject do
|
6
|
+
Flipflop::GroupDefinition.new(:my_key)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have specified key" do
|
10
|
+
assert_equal :my_key, subject.key
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have name derived from key" do
|
14
|
+
assert_equal "my_key", subject.name
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have title derived from key" do
|
18
|
+
assert_equal "My key", subject.title
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -14,6 +14,10 @@ describe Flipflop::Strategies::AbstractStrategy do
|
|
14
14
|
assert_equal "abstract", subject.name
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should have title derived from name" do
|
18
|
+
assert_equal "Abstract", subject.title
|
19
|
+
end
|
20
|
+
|
17
21
|
it "should have no default description" do
|
18
22
|
assert_nil subject.description
|
19
23
|
end
|
@@ -36,22 +40,12 @@ describe Flipflop::Strategies::AbstractStrategy do
|
|
36
40
|
assert_equal 3, subject.send(:request)
|
37
41
|
end
|
38
42
|
|
39
|
-
it "should raise if request is missing" do
|
40
|
-
Flipflop::Strategies::AbstractStrategy::RequestInterceptor.request = nil
|
41
|
-
assert_raises Flipflop::StrategyError do
|
42
|
-
subject.send(:request)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should raise with message if request is missing" do
|
43
|
+
it "should raise error with message if request is missing" do
|
47
44
|
Flipflop::Strategies::AbstractStrategy::RequestInterceptor.request = nil
|
48
|
-
|
49
|
-
begin
|
45
|
+
error = assert_raises Flipflop::StrategyError do
|
50
46
|
subject.send(:request)
|
51
|
-
rescue => err
|
52
|
-
message = err.message
|
53
47
|
end
|
54
|
-
assert_equal "Strategy 'abstract' required request, but was used outside request context.", message
|
48
|
+
assert_equal "Strategy 'abstract' required request, but was used outside request context.", error.message
|
55
49
|
end
|
56
50
|
|
57
51
|
it "should raise if request is missing in thread" do
|
@@ -88,6 +82,10 @@ describe Flipflop::Strategies::AbstractStrategy do
|
|
88
82
|
assert_equal "strategy", subject.name
|
89
83
|
end
|
90
84
|
|
85
|
+
it "should have title derived from name" do
|
86
|
+
assert_equal "Strategy", subject.title
|
87
|
+
end
|
88
|
+
|
91
89
|
it "should have specified description" do
|
92
90
|
assert_equal "my strategy", subject.description
|
93
91
|
end
|
@@ -105,20 +103,11 @@ describe Flipflop::Strategies::AbstractStrategy do
|
|
105
103
|
).freeze
|
106
104
|
end
|
107
105
|
|
108
|
-
it "should raise error" do
|
109
|
-
assert_raises Flipflop::StrategyError do
|
110
|
-
subject
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should raise with message" do
|
115
|
-
message = nil
|
116
|
-
begin
|
106
|
+
it "should raise error with message" do
|
107
|
+
error = assert_raises Flipflop::StrategyError do
|
117
108
|
subject
|
118
|
-
rescue => err
|
119
|
-
message = err.message
|
120
109
|
end
|
121
|
-
assert_equal "Strategy 'abstract' did not understand option :unknown, :other.", message
|
110
|
+
assert_equal "Strategy 'abstract' did not understand option :unknown, :other.", error.message
|
122
111
|
end
|
123
112
|
end
|
124
113
|
end
|
@@ -46,6 +46,10 @@ describe Flipflop::Strategies::ActiveRecordStrategy do
|
|
46
46
|
assert_equal "active_record", subject.name
|
47
47
|
end
|
48
48
|
|
49
|
+
it "should have title derived from name" do
|
50
|
+
assert_equal "Active record", subject.title
|
51
|
+
end
|
52
|
+
|
49
53
|
it "should have default description" do
|
50
54
|
assert_equal "Stores features in database. Applies to all users.",
|
51
55
|
subject.description
|
@@ -18,6 +18,10 @@ describe Flipflop::Strategies::CookieStrategy do
|
|
18
18
|
assert_equal "cookie", subject.name
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should have title derived from name" do
|
22
|
+
assert_equal "Cookie", subject.title
|
23
|
+
end
|
24
|
+
|
21
25
|
it "should have default description" do
|
22
26
|
assert_equal "Stores features in a browser cookie. Applies to current user.",
|
23
27
|
subject.description
|
@@ -2,12 +2,14 @@ require File.expand_path("../../../test_helper", __FILE__)
|
|
2
2
|
|
3
3
|
describe Flipflop::Strategies::DefaultStrategy do
|
4
4
|
before do
|
5
|
-
Flipflop.
|
6
|
-
|
7
|
-
|
5
|
+
Flipflop::FeatureSet.current.replace do
|
6
|
+
Flipflop.configure do
|
7
|
+
feature :one, default: true
|
8
|
+
feature :two
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
|
-
|
12
|
+
|
11
13
|
describe "with defaults" do
|
12
14
|
subject do
|
13
15
|
Flipflop::Strategies::DefaultStrategy.new.freeze
|
@@ -17,6 +19,10 @@ describe Flipflop::Strategies::DefaultStrategy do
|
|
17
19
|
assert_equal "default", subject.name
|
18
20
|
end
|
19
21
|
|
22
|
+
it "should have title derived from name" do
|
23
|
+
assert_equal "Default", subject.title
|
24
|
+
end
|
25
|
+
|
20
26
|
it "should have no default description" do
|
21
27
|
assert_equal "Uses feature default status.", subject.description
|
22
28
|
end
|
@@ -10,6 +10,10 @@ describe Flipflop::Strategies::LambdaStrategy do
|
|
10
10
|
assert_equal "lambda", subject.name
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should have title derived from name" do
|
14
|
+
assert_equal "Lambda", subject.title
|
15
|
+
end
|
16
|
+
|
13
17
|
it "should not have default description" do
|
14
18
|
assert_equal "Resolves feature settings with custom code.",
|
15
19
|
subject.description
|
@@ -94,44 +98,24 @@ describe Flipflop::Strategies::LambdaStrategy do
|
|
94
98
|
Flipflop::Strategies::LambdaStrategy.new(lambda: ->() { }).freeze
|
95
99
|
end
|
96
100
|
|
97
|
-
it "should raise error" do
|
98
|
-
assert_raises Flipflop::StrategyError do
|
99
|
-
subject
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should raise with message" do
|
104
|
-
message = nil
|
105
|
-
begin
|
101
|
+
it "should raise error with message" do
|
102
|
+
error = assert_raises Flipflop::StrategyError do
|
106
103
|
subject
|
107
|
-
rescue => err
|
108
|
-
message = err.message
|
109
104
|
end
|
110
|
-
assert_equal "Strategy 'lambda' has lambda with arity 0, expected 1 or -1.", message
|
105
|
+
assert_equal "Strategy 'lambda' has lambda with arity 0, expected 1 or -1.", error.message
|
111
106
|
end
|
112
107
|
end
|
113
108
|
|
114
109
|
describe "with non conforming return value" do
|
115
110
|
subject do
|
116
|
-
Flipflop::Strategies::LambdaStrategy.new(lambda: ->(feature) {
|
117
|
-
return feature
|
118
|
-
}).freeze
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should raise error" do
|
122
|
-
assert_raises Flipflop::StrategyError do
|
123
|
-
subject.enabled?(:one)
|
124
|
-
end
|
111
|
+
Flipflop::Strategies::LambdaStrategy.new(lambda: -> (feature) {feature}).freeze
|
125
112
|
end
|
126
113
|
|
127
|
-
it "should raise with message" do
|
128
|
-
|
129
|
-
begin
|
114
|
+
it "should raise error with message" do
|
115
|
+
error = assert_raises Flipflop::StrategyError do
|
130
116
|
subject.enabled?(:one)
|
131
|
-
rescue => err
|
132
|
-
message = err.message
|
133
117
|
end
|
134
|
-
assert_equal "Strategy 'lambda' returned invalid result :one for feature 'one'.", message
|
118
|
+
assert_equal "Strategy 'lambda' returned invalid result :one for feature 'one'.", error.message
|
135
119
|
end
|
136
120
|
end
|
137
121
|
end
|
@@ -18,6 +18,10 @@ describe Flipflop::Strategies::QueryStringStrategy do
|
|
18
18
|
assert_equal "query_string", subject.name
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should have title derived from name" do
|
22
|
+
assert_equal "Query string", subject.title
|
23
|
+
end
|
24
|
+
|
21
25
|
it "should not have default description" do
|
22
26
|
assert_equal "Interprets query string parameters as features.",
|
23
27
|
subject.description
|
@@ -16,6 +16,10 @@ describe Flipflop::Strategies::RedisStrategy do
|
|
16
16
|
assert_equal "redis", subject.name
|
17
17
|
end
|
18
18
|
|
19
|
+
it "should have title derived from name" do
|
20
|
+
assert_equal "Redis", subject.title
|
21
|
+
end
|
22
|
+
|
19
23
|
it "should have default description" do
|
20
24
|
assert_equal "Stores features in Redis. Applies to all users.",
|
21
25
|
subject.description
|
@@ -18,6 +18,10 @@ describe Flipflop::Strategies::SessionStrategy do
|
|
18
18
|
assert_equal "session", subject.name
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should have title derived from name" do
|
22
|
+
assert_equal "Session", subject.title
|
23
|
+
end
|
24
|
+
|
21
25
|
it "should have default description" do
|
22
26
|
assert_equal "Stores features in the user session. Applies to current user.",
|
23
27
|
subject.description
|
@@ -10,6 +10,10 @@ describe Flipflop::Strategies::TestStrategy do
|
|
10
10
|
assert_equal "test", subject.name
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should have title derived from name" do
|
14
|
+
assert_equal "Test", subject.title
|
15
|
+
end
|
16
|
+
|
13
17
|
it "should not have default description" do
|
14
18
|
assert_nil subject.description
|
15
19
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Annesley
|
@@ -10,20 +10,20 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '4.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '4.0'
|
29
29
|
description: Declarative API for specifying features, switchable in declaration, database
|
@@ -36,18 +36,21 @@ executables: []
|
|
36
36
|
extensions: []
|
37
37
|
extra_rdoc_files: []
|
38
38
|
files:
|
39
|
-
- .gitignore
|
40
|
-
- .travis.yml
|
39
|
+
- ".gitignore"
|
40
|
+
- ".travis.yml"
|
41
|
+
- CHANGES.md
|
41
42
|
- Gemfile
|
42
43
|
- LICENSE
|
43
44
|
- README.md
|
44
45
|
- Rakefile
|
45
|
-
- app/assets/stylesheets/flipflop.css
|
46
46
|
- app/controllers/flipflop/features_controller.rb
|
47
47
|
- app/controllers/flipflop/strategies_controller.rb
|
48
48
|
- app/models/flipflop/feature.rb
|
49
49
|
- app/views/flipflop/features/index.html.erb
|
50
|
+
- app/views/flipflop/stylesheets/_flipflop.css
|
50
51
|
- app/views/layouts/flipflop.html.erb
|
52
|
+
- config/features.rb
|
53
|
+
- config/locales/en.yml
|
51
54
|
- config/routes.rb
|
52
55
|
- flipflop.gemspec
|
53
56
|
- lib/flipflop.rb
|
@@ -56,7 +59,9 @@ files:
|
|
56
59
|
- lib/flipflop/facade.rb
|
57
60
|
- lib/flipflop/feature_cache.rb
|
58
61
|
- lib/flipflop/feature_definition.rb
|
62
|
+
- lib/flipflop/feature_loader.rb
|
59
63
|
- lib/flipflop/feature_set.rb
|
64
|
+
- lib/flipflop/group_definition.rb
|
60
65
|
- lib/flipflop/strategies/abstract_strategy.rb
|
61
66
|
- lib/flipflop/strategies/active_record_strategy.rb
|
62
67
|
- lib/flipflop/strategies/cookie_strategy.rb
|
@@ -77,14 +82,22 @@ files:
|
|
77
82
|
- lib/generators/flipflop/migration/templates/create_features.rb
|
78
83
|
- lib/generators/flipflop/routes/USAGE
|
79
84
|
- lib/generators/flipflop/routes/routes_generator.rb
|
85
|
+
- lib/test_engine/config/features.rb
|
86
|
+
- lib/test_engine/test_engine.rb
|
87
|
+
- src/stylesheets/_flipflop.scss
|
80
88
|
- test/integration/app_test.rb
|
81
89
|
- test/integration/dashboard_test.rb
|
90
|
+
- test/templates/nl.yml
|
91
|
+
- test/templates/test_app_features.rb
|
92
|
+
- test/templates/test_engine.rb
|
93
|
+
- test/templates/test_engine_features.rb
|
82
94
|
- test/test_helper.rb
|
83
95
|
- test/unit/configurable_test.rb
|
84
96
|
- test/unit/feature_cache_test.rb
|
85
97
|
- test/unit/feature_definition_test.rb
|
86
98
|
- test/unit/feature_set_test.rb
|
87
99
|
- test/unit/flipflop_test.rb
|
100
|
+
- test/unit/group_definition_test.rb
|
88
101
|
- test/unit/strategies/abstract_strategy_request_test.rb
|
89
102
|
- test/unit/strategies/abstract_strategy_test.rb
|
90
103
|
- test/unit/strategies/active_record_strategy_test.rb
|
@@ -106,12 +119,12 @@ require_paths:
|
|
106
119
|
- lib
|
107
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
121
|
requirements:
|
109
|
-
- -
|
122
|
+
- - ">="
|
110
123
|
- !ruby/object:Gem::Version
|
111
124
|
version: '0'
|
112
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
126
|
requirements:
|
114
|
-
- -
|
127
|
+
- - ">="
|
115
128
|
- !ruby/object:Gem::Version
|
116
129
|
version: '0'
|
117
130
|
requirements: []
|