• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Unleash / unleash-client-ruby / 3781944398

pending completion
3781944398

push

github

Renato Arruda
chore: add ruby 3.2 support in gh actions

0 of 2286 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/spec/unleash/bootstrap/handler_spec.rb
1
require 'unleash/bootstrap/handler'
×
2
require 'unleash/bootstrap/configuration'
×
3

4
RSpec.describe Unleash::Bootstrap::Handler do
×
5
  Unleash.configure do |config|
×
6
    config.url      = 'http://unleash-url/'
×
7
    config.app_name = 'my-test-app'
×
8
    config.instance_id = 'rspec/test'
×
9
    config.custom_http_headers = { 'X-API-KEY' => '123' }
×
10
  end
11

12
  it 'is marked as invalid when no bootstrap options are provided' do
×
13
    bootstrap_config = Unleash::Bootstrap::Configuration.new
×
14
    expect(bootstrap_config.valid?).to be(false)
×
15
  end
16

17
  it 'is marked as valid when at least one valid bootstrap option is provided' do
×
18
    bootstrap_config = Unleash::Bootstrap::Configuration.new({ 'data' => '' })
×
19
    expect(bootstrap_config.valid?).to be(true)
×
20
  end
21

22
  it 'resolves bootstrap toggle correctly from url provider' do
×
23
    expected_repsonse_data = '{
×
24
      "version": 1,
25
      "features": [
26
        {
27
          "name": "featureX",
28
          "enabled": true,
29
          "strategies": [{ "name": "default" }]
30
        }
31
      ]
32
    }'
33

34
    WebMock.stub_request(:get, "http://test-url/")
×
35
      .with(
36
        headers: {
37
          'Accept' => '*/*',
38
          'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
39
          'Content-Type' => 'application/json',
40
          'User-Agent' => 'Ruby'
41
        }
42
      )
43
      .to_return(status: 200, body: expected_repsonse_data, headers: {})
44

45
    url_provider_options = {
×
46
      'url' => 'http://test-url/',
47
      'url_headers' => {}
48
    }
49

50
    bootstrap_config = Unleash::Bootstrap::Configuration.new(url_provider_options)
×
51
    bootstrap_response = Unleash::Bootstrap::Handler.new(bootstrap_config).retrieve_toggles
×
52
    expect(JSON.parse(bootstrap_response)).to eq(JSON.parse(expected_repsonse_data))
×
53
  end
54

55
  it 'resolves bootstrap toggle correctly from file provider' do
×
56
    file_path = './spec/unleash/bootstrap-resources/features-v1.json'
×
57
    actual_file_contents = File.open(file_path).read
×
58

59
    file_provider_options = {
×
60
      'file_path' => file_path
61
    }
62

63
    bootstrap_config = Unleash::Bootstrap::Configuration.new(file_provider_options)
×
64
    bootstrap_response = Unleash::Bootstrap::Handler.new(bootstrap_config).retrieve_toggles
×
65

66
    expect(JSON.parse(bootstrap_response)).to eq(JSON.parse(actual_file_contents))
×
67
  end
68

69
  it 'resolves bootstrap toggle correctly from raw data' do
×
70
    expected_repsonse_data = '{
×
71
      "version": 1,
72
      "features": [
73
        {
74
          "name": "featureX",
75
          "enabled": true,
76
          "strategies": [{ "name": "default" }]
77
        }
78
      ]
79
    }'
80

81
    data_provider_options = {
×
82
      'data' => expected_repsonse_data
83
    }
84

85
    bootstrap_config = Unleash::Bootstrap::Configuration.new(data_provider_options)
×
86
    bootstrap_response = Unleash::Bootstrap::Handler.new(bootstrap_config).retrieve_toggles
×
87

88
    expect(JSON.parse(bootstrap_response)).to eq(JSON.parse(expected_repsonse_data))
×
89
  end
90

91
  it 'resolves bootstrap toggle correctly from lambda' do
×
92
    expected_repsonse_data = '{
×
93
      "version": 1,
94
      "features": [
95
        {
96
          "name": "featureX",
97
          "enabled": true,
98
          "strategies": [{ "name": "default" }]
99
        }
100
      ]
101
    }'
102

103
    data_provider_options = {
×
104
      'block' => -> { expected_repsonse_data }
×
105
    }
106

107
    bootstrap_config = Unleash::Bootstrap::Configuration.new(data_provider_options)
×
108
    bootstrap_response = Unleash::Bootstrap::Handler.new(bootstrap_config).retrieve_toggles
×
109

110
    expect(JSON.parse(bootstrap_response)).to eq(JSON.parse(expected_repsonse_data))
×
111
  end
112
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc