diff options
Diffstat (limited to 'spec/views/layouts/_published_experiments.html.haml_spec.rb')
-rw-r--r-- | spec/views/layouts/_published_experiments.html.haml_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/views/layouts/_published_experiments.html.haml_spec.rb b/spec/views/layouts/_published_experiments.html.haml_spec.rb new file mode 100644 index 00000000000..d1ade8ddd6e --- /dev/null +++ b/spec/views/layouts/_published_experiments.html.haml_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'layouts/_published_experiments', :experiment do + before do + stub_const('TestControlExperiment', ApplicationExperiment) + stub_const('TestCandidateExperiment', ApplicationExperiment) + stub_const('TestExcludedExperiment', ApplicationExperiment) + + TestControlExperiment.new('test_control').tap do |e| + e.variant(:control) + e.publish + end + TestCandidateExperiment.new('test_candidate').tap do |e| + e.variant(:candidate) + e.publish + end + TestExcludedExperiment.new('test_excluded').tap do |e| + e.exclude! + e.publish + end + + render + end + + it 'renders out data for all non-excluded, published experiments' do + output = rendered + + expect(output).to include('gl.experiments = {') + expect(output).to match(/"test_control":\{[^}]*"variant":"control"/) + expect(output).to match(/"test_candidate":\{[^}]*"variant":"candidate"/) + expect(output).not_to include('"test_excluded"') + end +end |