Sha256: c716f5bfc7b6859645815a4abea705a0de6b78035850f9828c7d910b55fbe504

Contents?: true

Size: 1.54 KB

Versions: 18

Compression:

Stored size: 1.54 KB

Contents

require 'helper'

RSpec.describe Flipper::UI::Action do
  let(:action_subclass) do
    Class.new(described_class) do
      def noooope
        raise 'should never run this'
      end

      def get
        [200, {}, 'get']
      end

      def post
        [200, {}, 'post']
      end

      def put
        [200, {}, 'put']
      end

      def delete
        [200, {}, 'delete']
      end
    end
  end

  it "won't run method that isn't whitelisted" do
    fake_request = Struct.new(:request_method, :env, :session).new('NOOOOPE', {}, {})
    action = action_subclass.new(flipper, fake_request)
    expect do
      action.run
    end.to raise_error(Flipper::UI::RequestMethodNotSupported)
  end

  it 'will run get' do
    fake_request = Struct.new(:request_method, :env, :session).new('GET', {}, {})
    action = action_subclass.new(flipper, fake_request)
    expect(action.run).to eq([200, {}, 'get'])
  end

  it 'will run post' do
    fake_request = Struct.new(:request_method, :env, :session).new('POST', {}, {})
    action = action_subclass.new(flipper, fake_request)
    expect(action.run).to eq([200, {}, 'post'])
  end

  it 'will run put' do
    fake_request = Struct.new(:request_method, :env, :session).new('PUT', {}, {})
    action = action_subclass.new(flipper, fake_request)
    expect(action.run).to eq([200, {}, 'put'])
  end

  it 'will run delete' do
    fake_request = Struct.new(:request_method, :env, :session).new('DELETE', {}, {})
    action = action_subclass.new(flipper, fake_request)
    expect(action.run).to eq([200, {}, 'delete'])
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
flipper-ui-0.16.0 spec/flipper/ui/action_spec.rb
flipper-ui-0.15.0 spec/flipper/ui/action_spec.rb
flipper-ui-0.14.0 spec/flipper/ui/action_spec.rb
flipper-ui-0.13.0 spec/flipper/ui/action_spec.rb
flipper-ui-0.13.0.beta1 spec/flipper/ui/action_spec.rb
flipper-ui-0.12.2 spec/flipper/ui/action_spec.rb
flipper-ui-0.12.1 spec/flipper/ui/action_spec.rb
flipper-ui-0.12.0 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.rc1 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.beta9 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.beta8 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.beta7 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.beta6 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.beta5 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.beta4 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.beta3 spec/flipper/ui/action_spec.rb
flipper-ui-0.11.0.beta1 spec/flipper/ui/action_spec.rb