Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Add failing spec to demonstrate conflict with 'prefix' and 'version'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Moon committed Jan 3, 2013
1 parent a65068b commit 3c1e695
Showing 1 changed file with 42 additions and 15 deletions.
57 changes: 42 additions & 15 deletions spec/shared/versioning_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,50 @@
last_response.status.should eql 404
end

it 'allows the same endpoint to be implemented for different versions' do
subject.version 'v2', macro_options
subject.get 'version' do
request.env['api.version']
end
context 'with different versions for the same endpoint' do
context 'without a prefix' do
it 'allows the same endpoint to be implemented' do
subject.version 'v2', macro_options
subject.get 'version' do
request.env['api.version']
end

subject.version 'v1', macro_options do
get 'version' do
"version " + request.env['api.version']
subject.version 'v1', macro_options do
get 'version' do
"version " + request.env['api.version']
end
end

versioned_get '/version', 'v2', macro_options
last_response.status.should == 200
last_response.body.should == 'v2'
versioned_get '/version', 'v1', macro_options
last_response.status.should == 200
last_response.body.should == 'version v1'
end
end

versioned_get '/version', 'v2', macro_options
last_response.status.should == 200
last_response.body.should == 'v2'
versioned_get '/version', 'v1', macro_options
last_response.status.should == 200
last_response.body.should == 'version v1'
context 'with a prefix' do
it 'allows the same endpoint to be implemented' do
subject.prefix 'api'
subject.version 'v2', macro_options
subject.get 'version' do
request.env['api.version']
end

subject.version 'v1', macro_options do
get 'version' do
"version " + request.env['api.version']
end
end

versioned_get '/api/version', 'v2', macro_options
last_response.status.should == 200
last_response.body.should == 'v2'
versioned_get '/api/version', 'v1', macro_options
last_response.status.should == 200
last_response.body.should == 'version v1'
end
end
end
end
end

0 comments on commit 3c1e695

Please sign in to comment.