Sha256: dd859b01434311912a66bc3c48b233b3fd4d62e7a412181274006513537173f8

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe FeatureGate::GatedFeature do
  let!(:gate) { create(:gated_feature) }

  describe '#destroyable?' do
    it 'returns true if files do not contain any feature gate references' do
      text = <<-TEXT
        <div>
          <% FeatureGate::Manager.gate('test') do %>
            foo
          <% end %>
        </div>

        def index
          FeatureGate::Manager.gate_page('test')
        end
      TEXT

      fake_file = double(read: text)
      allow(File).to receive(:new).and_return(fake_file)
      expect(gate).to be_destroyable
    end

    it 'returns false if files contain feature gate gating a page' do
      text = <<-TEXT
        <div>
          <% FeatureGate::Manager.gate('#{gate.name}') do %>
            foo
          <% end %>
        </div>

        def index
          FeatureGate::Manager.gate_page('test')
        end
      TEXT

      fake_file = double(read: text)
      allow(File).to receive(:new).and_return(fake_file)
      expect(gate).not_to be_destroyable
    end

    it 'return false if files contain feature gate gating part of a page' do
      text = <<-TEXT
        <div>
          <% FeatureGate::Manager.gate('test') do %>
            foo
          <% end %>
        </div>

        def index
          FeatureGate::Manager.gate_page('#{gate.name}')
        end
      TEXT

      fake_file = double(read: text)
      allow(File).to receive(:new).and_return(fake_file)
      expect(gate).not_to be_destroyable
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
feature_gate-0.2.6 spec/models/feature_gate/gated_feature_spec.rb
feature_gate-0.2.5 spec/models/feature_gate/gated_feature_spec.rb
feature_gate-0.2.4 spec/models/feature_gate/gated_feature_spec.rb
feature_gate-0.2.3 spec/models/feature_gate/gated_feature_spec.rb