Skip to content

Instantly share code, notes, and snippets.

@cableray
Created December 3, 2012 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cableray/4198703 to your computer and use it in GitHub Desktop.
Save cableray/4198703 to your computer and use it in GitHub Desktop.
api routing
require 'spec_helper'
describe Api do
describe "routing" do
it "routes to entry point" do
['1','v1'].each do |version_spec|
get("api/#{version_spec}").should route_to 'api/v1/entry_point#index'
end
end
end
end
1) Api routing routes to entry point
Failure/Error: get("api/#{version_spec}.json/").should route_to 'api/v1/entry_point#index'
No route matches "/api/v1.json"
# ./spec/routing/api_routing_spec.rb:7:in `block (4 levels) in <top (required)>'
# ./spec/routing/api_routing_spec.rb:6:in `each'
# ./spec/routing/api_routing_spec.rb:6:in `block (3 levels) in <top (required)>'
---------------------------
1) Api routing routes to entry point
Failure/Error: get("api/#{version_spec}").should route_to 'api/v1/entry_point#index'
The recognized options <{"format"=>"json",
"controller"=>"api/v1/entry_point",
"action"=>"index",
"version"=>"1"}> did not match <{"controller"=>"api/v1/entry_point", "action"=>"index"}>, difference: <{"format"=>"json", "version"=>"1"}>.
<{"controller"=>"api/v1/entry_point", "action"=>"index"}> expected but was
<{"format"=>"json",
"controller"=>"api/v1/entry_point",
"action"=>"index",
"version"=>"1"}>.
# ./spec/routing/api_routing_spec.rb:7:in `block (4 levels) in <top (required)>'
# ./spec/routing/api_routing_spec.rb:6:in `each'
# ./spec/routing/api_routing_spec.rb:6:in `block (3 levels) in <top (required)>'
api_entry_point GET /api/:version(.:format) api/api/v1/entry_point#index {:version=>/(v?1)/, :format=>"json"}
namespace :api do
api version: 1, allow_prefix: 'v' do
get "/", to:'v1/entry_point#index', as: :entry_point
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment