spec/api_client_spec.rb in dkron-rb-0.11.2 vs spec/api_client_spec.rb in dkron-rb-1.0.0
- old
+ new
@@ -1,14 +1,14 @@
=begin
#Dkron REST API
#You can communicate with Dkron using a RESTful JSON API over HTTP. Dkron nodes usually listen on port `8080` for API requests. All examples in this section assume that you've found a running leader at `localhost:8080`. Dkron implements a RESTful JSON API over HTTP to communicate with software clients. Dkron listens in port `8080` by default. All examples in this section assume that you're using the default port. Default API responses are unformatted JSON add the `pretty=true` param to format the response.
-OpenAPI spec version: 0.11.2
+OpenAPI spec version: 1
Generated by: https://github.com/swagger-api/swagger-codegen.git
-Swagger Codegen version: 2.3.1
+Swagger Codegen version: 2.4.2
=end
require 'spec_helper'
@@ -49,123 +49,123 @@
end
end
end
end
- describe "params_encoding in #build_request" do
+ describe 'params_encoding in #build_request' do
let(:config) { Dkron::Configuration.new }
let(:api_client) { Dkron::ApiClient.new(config) }
- it "defaults to nil" do
+ it 'defaults to nil' do
expect(Dkron::Configuration.default.params_encoding).to eq(nil)
expect(config.params_encoding).to eq(nil)
request = api_client.build_request(:get, '/test')
expect(request.options[:params_encoding]).to eq(nil)
end
- it "can be customized" do
+ it 'can be customized' do
config.params_encoding = :multi
request = api_client.build_request(:get, '/test')
expect(request.options[:params_encoding]).to eq(:multi)
end
end
- describe "timeout in #build_request" do
+ describe 'timeout in #build_request' do
let(:config) { Dkron::Configuration.new }
let(:api_client) { Dkron::ApiClient.new(config) }
- it "defaults to 0" do
+ it 'defaults to 0' do
expect(Dkron::Configuration.default.timeout).to eq(0)
expect(config.timeout).to eq(0)
request = api_client.build_request(:get, '/test')
expect(request.options[:timeout]).to eq(0)
end
- it "can be customized" do
+ it 'can be customized' do
config.timeout = 100
request = api_client.build_request(:get, '/test')
expect(request.options[:timeout]).to eq(100)
end
end
- describe "#deserialize" do
+ describe '#deserialize' do
it "handles Array<Integer>" do
api_client = Dkron::ApiClient.new
- headers = {'Content-Type' => 'application/json'}
+ headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '[12, 34]')
data = api_client.deserialize(response, 'Array<Integer>')
expect(data).to be_instance_of(Array)
expect(data).to eq([12, 34])
end
- it "handles Array<Array<Integer>>" do
+ it 'handles Array<Array<Integer>>' do
api_client = Dkron::ApiClient.new
- headers = {'Content-Type' => 'application/json'}
+ headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '[[12, 34], [56]]')
data = api_client.deserialize(response, 'Array<Array<Integer>>')
expect(data).to be_instance_of(Array)
expect(data).to eq([[12, 34], [56]])
end
- it "handles Hash<String, String>" do
+ it 'handles Hash<String, String>' do
api_client = Dkron::ApiClient.new
- headers = {'Content-Type' => 'application/json'}
+ headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '{"message": "Hello"}')
data = api_client.deserialize(response, 'Hash<String, String>')
expect(data).to be_instance_of(Hash)
- expect(data).to eq({:message => 'Hello'})
+ expect(data).to eq(:message => 'Hello')
end
end
describe "#object_to_hash" do
- it "ignores nils and includes empty arrays" do
+ it 'ignores nils and includes empty arrays' do
# uncomment below to test object_to_hash for model
- #api_client = Dkron::ApiClient.new
- #_model = Dkron::ModelName.new
+ # api_client = Dkron::ApiClient.new
+ # _model = Dkron::ModelName.new
# update the model attribute below
- #_model.id = 1
+ # _model.id = 1
# update the expected value (hash) below
- #expected = {id: 1, name: '', tags: []}
- #expect(api_client.object_to_hash(_model)).to eq(expected)
+ # expected = {id: 1, name: '', tags: []}
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
end
end
- describe "#build_collection_param" do
+ describe '#build_collection_param' do
let(:param) { ['aa', 'bb', 'cc'] }
let(:api_client) { Dkron::ApiClient.new }
- it "works for csv" do
+ it 'works for csv' do
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
end
- it "works for ssv" do
+ it 'works for ssv' do
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
end
- it "works for tsv" do
+ it 'works for tsv' do
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
end
- it "works for pipes" do
+ it 'works for pipes' do
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
end
- it "works for multi" do
+ it 'works for multi' do
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
end
- it "fails for invalid collection format" do
+ it 'fails for invalid collection format' do
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
end
end
- describe "#json_mime?" do
+ describe '#json_mime?' do
let(:api_client) { Dkron::ApiClient.new }
- it "works" do
+ it 'works' do
expect(api_client.json_mime?(nil)).to eq false
expect(api_client.json_mime?('')).to eq false
expect(api_client.json_mime?('application/json')).to eq true
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
@@ -175,14 +175,14 @@
expect(api_client.json_mime?('text/plain')).to eq false
expect(api_client.json_mime?('application/jsonp')).to eq false
end
end
- describe "#select_header_accept" do
+ describe '#select_header_accept' do
let(:api_client) { Dkron::ApiClient.new }
- it "works" do
+ it 'works' do
expect(api_client.select_header_accept(nil)).to be_nil
expect(api_client.select_header_accept([])).to be_nil
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
@@ -191,14 +191,14 @@
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
end
end
- describe "#select_header_content_type" do
+ describe '#select_header_content_type' do
let(:api_client) { Dkron::ApiClient.new }
- it "works" do
+ it 'works' do
expect(api_client.select_header_content_type(nil)).to eq('application/json')
expect(api_client.select_header_content_type([])).to eq('application/json')
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
@@ -206,13 +206,13 @@
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
end
end
- describe "#sanitize_filename" do
+ describe '#sanitize_filename' do
let(:api_client) { Dkron::ApiClient.new }
- it "works" do
+ it 'works' do
expect(api_client.sanitize_filename('sun')).to eq('sun')
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')