Created
December 3, 2012 22:25
-
-
Save cableray/4198703 to your computer and use it in GitHub Desktop.
api routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api_entry_point GET /api/:version(.:format) api/api/v1/entry_point#index {:version=>/(v?1)/, :format=>"json"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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