| 
									
										
										
										
											2016-03-16 08:18:07 +08:00
										 |  |  | require 'spec_helper' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe GrapeSwagger::DocMethods::OperationId do | 
					
						
							|  |  |  |   subject { described_class } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   specify { expect(subject).to eql GrapeSwagger::DocMethods::OperationId } | 
					
						
							|  |  |  |   specify { expect(subject).to respond_to :build } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe 'build' do | 
					
						
							| 
									
										
										
										
											2016-05-07 05:18:45 +08:00
										 |  |  |     if defined?(Grape::VERSION) && Gem::Version.new(::Grape::VERSION) < Gem::Version.new('0.16.0') | 
					
						
							|  |  |  |       let(:route) { Grape::Route.new(method: method) } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       let(:route) { Grape::Router::Route.new(method, '/path', requirements: {}) } | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-04-25 03:44:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     describe 'GET' do | 
					
						
							|  |  |  |       let(:method) { 'GET' } | 
					
						
							|  |  |  |       specify { expect(subject.build(route)).to eql 'get' } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     describe 'get' do | 
					
						
							|  |  |  |       let(:method) { 'get' } | 
					
						
							|  |  |  |       specify { expect(subject.build(route)).to eql 'get' } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     describe ':get' do | 
					
						
							|  |  |  |       let(:method) { :get } | 
					
						
							|  |  |  |       specify { expect(subject.build(route)).to eql 'get' } | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-05-01 18:31:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     describe 'path given' do | 
					
						
							|  |  |  |       let(:method) { 'GET' } | 
					
						
							|  |  |  |       it 'GET with path foo' do | 
					
						
							|  |  |  |         expect(subject.build(route, 'foo')).to eql 'getFoo' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       it 'GET with path /foo' do | 
					
						
							|  |  |  |         expect(subject.build(route, '/foo')).to eql 'getFoo' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       it 'GET with path bar/foo' do | 
					
						
							|  |  |  |         expect(subject.build(route, 'bar/foo')).to eql 'getBarFoo' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       it 'GET with path bar/foo{id}' do | 
					
						
							|  |  |  |         expect(subject.build(route, 'bar/foo{id}')).to eql 'getBarFooId' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       it 'GET with path /bar_foo{id}' do | 
					
						
							|  |  |  |         expect(subject.build(route, '/bar_foo{id}')).to eql 'getBarFooId' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       it 'GET with path /bar-foo{id}' do | 
					
						
							|  |  |  |         expect(subject.build(route, '/bar-foo{id}')).to eql 'getBarFooId' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       it 'GET with path /simple_test/bar-foo{id}' do | 
					
						
							|  |  |  |         expect(subject.build(route, '/simple_test/bar-foo{id}')).to eql 'getSimpleTestBarFooId' | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-03-16 08:18:07 +08:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |