Skip to content

Commit

Permalink
Add unit test for 'Avoid toggles nil exception'
Browse files Browse the repository at this point in the history
  • Loading branch information
rarruda committed Oct 26, 2018
1 parent 397ca48 commit 4f60216
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions spec/unleash/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,50 @@
).to have_been_made.once
end


it "should not fail if we are provided no toggles from the unleash server" do
WebMock.stub_request(:post, "http://test-url//client/register")
.with(
headers: {
'Accept'=>'*/*',
'Content-Type'=>'application/json',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'User-Agent'=>'Ruby',
'X-Api-Key'=>'123'
})
.to_return(status: 200, body: "", headers: {})

WebMock.stub_request(:post, "http://test-url//client/features")
.with(
headers: {
'Accept'=>'*/*',
'Content-Type'=>'application/json',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'User-Agent'=>'Ruby',
'X-Api-Key'=>'123'
})
.to_return(status: 200, body: '{"version": 1, "features": []}', headers: {})

Unleash.configure do |config|
config.url = 'http://test-url/'
config.app_name = 'my-test-app'
config.instance_id = 'rspec/test'
config.disable_metrics = true
config.custom_http_headers = {'X-API-KEY' => '123'}
end

unleash_client = Unleash::Client.new(
url: 'http://test-url/',
app_name: 'my-test-app',
instance_id: 'rspec/test',
custom_http_headers: {'X-API-KEY' => '123'}
)

expect(
unleash_client.is_enabled?('any_feature', {}, true)
).to eq(true)
end

it "does something useful" do
expect(false).to eq(false)
end
Expand Down

0 comments on commit 4f60216

Please sign in to comment.