Sha256: 482df20b5892a8997ee983ef0df37042168db71bbce00faf9923c739044be0c5
Contents?: true
Size: 1.29 KB
Versions: 16
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe GrapeSwagger::DocMethods::OptionalObject do subject { described_class } specify { expect(subject).to eql GrapeSwagger::DocMethods::OptionalObject } specify { expect(subject).to respond_to :build } describe 'build' do let(:key) { :host } let!(:request) { Rack::Request.new(Rack::MockRequest.env_for('http://example.com:8080/')) } describe 'no option given for host, take from request' do let(:options) { { foo: 'foo' } } specify do expect(subject.build(key, options, request)).to eql request.host_with_port end end let(:value) { 'grape-swagger.example.com' } describe 'option is a string' do let(:options) { { host: value } } specify do expect(subject.build(key, options, request)).to eql value end end describe 'option is a lambda' do let(:options) { { host: -> { value } } } specify do expect(subject.build(key, options, request)).to eql value end end describe 'option is a proc' do let(:options) do { host: proc { |request| request.host =~ /^example/ ? '/api-example' : '/api' } } end specify do expect(subject.build(key, options, request)).to eql '/api-example' end end end end
Version data entries
16 entries across 16 versions & 2 rubygems