File: features_spec.rb

package info (click to toggle)
ruby-gitlab 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,660 kB
  • sloc: ruby: 12,582; makefile: 7; sh: 4
file content (65 lines) | stat: -rw-r--r-- 1,689 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Client do
  describe '.features' do
    before do
      stub_get('/features', 'features')
      @features = Gitlab.features
    end

    it 'gets the correct resource' do
      expect(a_get('/features')).to have_been_made
    end

    it 'returns a paginated response of features' do
      expect(@features).to be_a Gitlab::PaginatedResponse
    end
  end

  describe '.set_feature' do
    context 'when setting boolean value' do
      before do
        stub_post('/features/new_library', 'feature')
        @feature = Gitlab.set_feature('new_library', true)
      end

      it 'gets the correct resource' do
        expect(a_post('/features/new_library')
          .with(body: { value: true })).to have_been_made
      end

      it 'returns information about the feature' do
        expect(@feature).to be_a Gitlab::ObjectifiedHash
      end
    end

    context 'when setting percentage-of-time gate value' do
      before do
        stub_post('/features/new_library', 'feature')
        @feature = Gitlab.set_feature('new_library', 30)
      end

      it 'gets the correct resource' do
        expect(a_post('/features/new_library')
          .with(body: { value: 30 })).to have_been_made
      end

      it 'returns information about the feature' do
        expect(@feature).to be_a Gitlab::ObjectifiedHash
      end
    end
  end

  describe '.delete_feature' do
    before do
      stub_delete('/features/new_library', 'empty')
      Gitlab.delete_feature('new_library')
    end

    it 'gets the correct resource' do
      expect(a_delete('/features/new_library')).to have_been_made
    end
  end
end