openapi-generator/samples/client/petstore/ruby/spec/swagger_spec.rb

57 lines
1.6 KiB
Ruby
Raw Normal View History

2012-09-26 20:02:27 +00:00
# require 'spec_helper'
require File.dirname(__FILE__) + '/spec_helper'
2015-04-18 16:42:55 +00:00
describe SwaggerClient::Swagger do
2012-09-26 20:02:27 +00:00
before(:each) do
configure_swagger
end
after(:each) do
end
context 'initialization' do
context 'URL stuff' do
context 'host' do
it 'removes http from host' do
2015-04-18 16:42:55 +00:00
SwaggerClient::Swagger.configure {|c| c.host = 'http://example.com' }
SwaggerClient::Swagger.configuration.host.should == 'example.com'
2012-09-26 20:02:27 +00:00
end
it 'removes https from host' do
2015-04-18 16:42:55 +00:00
SwaggerClient::Swagger.configure {|c| c.host = 'https://wookiee.com' }
SwaggerClient::Swagger.configuration.host.should == 'wookiee.com'
2012-09-26 20:02:27 +00:00
end
it 'removes trailing path from host' do
2015-04-18 16:42:55 +00:00
SwaggerClient::Swagger.configure {|c| c.host = 'hobo.com/v4' }
SwaggerClient::Swagger.configuration.host.should == 'hobo.com'
2012-09-26 20:02:27 +00:00
end
end
context 'base_path' do
it "prepends a slash to base_path" do
2015-04-18 16:42:55 +00:00
SwaggerClient::Swagger.configure {|c| c.base_path = 'v4/dog' }
SwaggerClient::Swagger.configuration.base_path.should == '/v4/dog'
2012-09-26 20:02:27 +00:00
end
it "doesn't prepend a slash if one is already there" do
2015-04-18 16:42:55 +00:00
SwaggerClient::Swagger.configure {|c| c.base_path = '/v4/dog' }
SwaggerClient::Swagger.configuration.base_path.should == '/v4/dog'
2012-09-26 20:02:27 +00:00
end
it "ends up as a blank string if nil" do
2015-04-18 16:42:55 +00:00
SwaggerClient::Swagger.configure {|c| c.base_path = nil }
SwaggerClient::Swagger.configuration.base_path.should == ''
2012-09-26 20:02:27 +00:00
end
end
end
end
2015-04-18 16:42:55 +00:00
end