flipper 0.28.2 → 1.0.0.pre
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/Changelog.md +27 -0
- data/Gemfile +5 -3
- data/docs/images/flipper_cloud.png +0 -0
- data/examples/cloud/app.ru +12 -0
- data/examples/cloud/basic.rb +22 -0
- data/examples/cloud/cloud_setup.rb +4 -0
- data/examples/cloud/forked.rb +31 -0
- data/examples/cloud/import.rb +17 -0
- data/examples/cloud/threaded.rb +36 -0
- data/examples/dsl.rb +0 -14
- data/flipper-cloud.gemspec +19 -0
- data/flipper.gemspec +3 -2
- data/lib/flipper/cloud/configuration.rb +189 -0
- data/lib/flipper/cloud/dsl.rb +27 -0
- data/lib/flipper/cloud/instrumenter.rb +48 -0
- data/lib/flipper/cloud/message_verifier.rb +95 -0
- data/lib/flipper/cloud/middleware.rb +63 -0
- data/lib/flipper/cloud/routes.rb +14 -0
- data/lib/flipper/cloud.rb +53 -0
- data/lib/flipper/dsl.rb +0 -46
- data/lib/flipper/{railtie.rb → engine.rb} +19 -3
- data/lib/flipper/metadata.rb +5 -1
- data/lib/flipper/spec/shared_adapter_specs.rb +43 -43
- data/lib/flipper/test/shared_adapter_test.rb +43 -43
- data/lib/flipper/version.rb +1 -1
- data/lib/flipper.rb +3 -5
- data/spec/flipper/adapters/dual_write_spec.rb +2 -2
- data/spec/flipper/adapters/instrumented_spec.rb +1 -1
- data/spec/flipper/adapters/memoizable_spec.rb +6 -6
- data/spec/flipper/adapters/operation_logger_spec.rb +2 -2
- data/spec/flipper/adapters/read_only_spec.rb +6 -6
- data/spec/flipper/cloud/configuration_spec.rb +269 -0
- data/spec/flipper/cloud/dsl_spec.rb +82 -0
- data/spec/flipper/cloud/message_verifier_spec.rb +104 -0
- data/spec/flipper/cloud/middleware_spec.rb +289 -0
- data/spec/flipper/cloud_spec.rb +180 -0
- data/spec/flipper/dsl_spec.rb +0 -75
- data/spec/flipper/engine_spec.rb +190 -0
- data/spec/flipper_integration_spec.rb +12 -12
- data/spec/flipper_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -12
- data/spec/support/climate_control.rb +7 -0
- metadata +54 -10
- data/spec/flipper/railtie_spec.rb +0 -109
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'rails'
|
2
|
-
require 'flipper/railtie'
|
3
|
-
|
4
|
-
RSpec.describe Flipper::Railtie do
|
5
|
-
let(:application) do
|
6
|
-
Class.new(Rails::Application).create(railties: [Flipper::Railtie]) do
|
7
|
-
config.eager_load = false
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
before do
|
12
|
-
ActiveSupport::Dependencies.autoload_paths = ActiveSupport::Dependencies.autoload_paths.dup
|
13
|
-
ActiveSupport::Dependencies.autoload_once_paths = ActiveSupport::Dependencies.autoload_once_paths.dup
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:config) { application.config.flipper }
|
17
|
-
|
18
|
-
subject { application.initialize! }
|
19
|
-
|
20
|
-
describe 'initializers' do
|
21
|
-
it 'can set env_key from ENV' do
|
22
|
-
ENV['FLIPPER_ENV_KEY'] = 'flopper'
|
23
|
-
|
24
|
-
subject
|
25
|
-
expect(config.env_key).to eq('flopper')
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'can set memoize from ENV' do
|
29
|
-
ENV['FLIPPER_MEMOIZE'] = 'false'
|
30
|
-
|
31
|
-
subject
|
32
|
-
expect(config.memoize).to eq(false)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'can set preload from ENV' do
|
36
|
-
ENV['FLIPPER_PRELOAD'] = 'false'
|
37
|
-
|
38
|
-
subject
|
39
|
-
expect(config.preload).to eq(false)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'can set instrumenter from ENV' do
|
43
|
-
stub_const('My::Cool::Instrumenter', Class.new)
|
44
|
-
ENV['FLIPPER_INSTRUMENTER'] = 'My::Cool::Instrumenter'
|
45
|
-
|
46
|
-
subject
|
47
|
-
expect(config.instrumenter).to eq(My::Cool::Instrumenter)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'can set log from ENV' do
|
51
|
-
ENV['FLIPPER_LOG'] = 'false'
|
52
|
-
|
53
|
-
subject
|
54
|
-
expect(config.log).to eq(false)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'sets defaults' do
|
58
|
-
subject # initialize
|
59
|
-
expect(config.env_key).to eq("flipper")
|
60
|
-
expect(config.memoize).to be(true)
|
61
|
-
expect(config.preload).to be(true)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "configures instrumentor on default instance" do
|
65
|
-
subject # initialize
|
66
|
-
expect(Flipper.instance.instrumenter).to eq(ActiveSupport::Notifications)
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'uses Memoizer middleware if config.memoize = true' do
|
70
|
-
initializer { config.memoize = true }
|
71
|
-
expect(subject.middleware).to include(Flipper::Middleware::Memoizer)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'does not use Memoizer middleware if config.memoize = false' do
|
75
|
-
initializer { config.memoize = false }
|
76
|
-
expect(subject.middleware).not_to include(Flipper::Middleware::Memoizer)
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'passes config to memoizer' do
|
80
|
-
initializer do
|
81
|
-
config.update(
|
82
|
-
env_key: 'my_flipper',
|
83
|
-
preload: [:stats, :search]
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
expect(subject.middleware).to include(Flipper::Middleware::Memoizer)
|
88
|
-
middleware = subject.middleware.detect { |m| m.klass == Flipper::Middleware::Memoizer }
|
89
|
-
expect(middleware.args[0]).to eq({
|
90
|
-
env_key: config.env_key,
|
91
|
-
preload: config.preload,
|
92
|
-
if: nil
|
93
|
-
})
|
94
|
-
end
|
95
|
-
|
96
|
-
it "defines #flipper_id on AR::Base" do
|
97
|
-
subject
|
98
|
-
require 'active_record'
|
99
|
-
expect(ActiveRecord::Base.ancestors).to include(Flipper::Identifier)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# Add app initializer in the same order as config/initializers/*
|
104
|
-
def initializer(&block)
|
105
|
-
application.initializer 'spec', before: :load_config_initializers do
|
106
|
-
block.call
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|