Accept custom :as argument for path strategy #19

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
2 participants

One of the reasons I considered using versionist is to clean up the helper method namespace. By default only the path strategy passes an :as parameter to the routing namespace. I'd like to have the 'default' route not have a prefix on the url helper methods.

Owner

bploetz commented Jun 24, 2012

  1. Please add a snippet to the README exhibiting this new feature and how to use it. It's not clear to me based on the code what you're trying to achieve here.
  2. This change breaks several tests (see below), and is missing tests of it's own. These need to be rectified before I will consider pulling this in.
  3. In the future, please rebase feature branches to squash commits and clean up history before submitting the pull request.
Failures:

  1) Versionist::Routing#api_version v1 :path :default => true should route to the default when no version given
     Failure/Error: match '/foos.(:format)' => 'foos#index', :via => :get
     ArgumentError:
       Invalid route name: '/v1'
     # ./spec/api_routing_spec.rb:465:in `block (9 levels) in <top (required)>'
     # ./lib/versionist/routing.rb:42:in `configure_path'
     # ./lib/versionist/routing.rb:19:in `api_version'
     # ./spec/api_routing_spec.rb:464:in `block (8 levels) in <top (required)>'
     # ./spec/api_routing_spec.rb:463:in `block (7 levels) in <top (required)>'

  2) Versionist::Routing#api_version v1 :path :default => true should not route to the default when another configured version is given
     Failure/Error: match '/foos.(:format)' => 'foos#index', :via => :get
     ArgumentError:
       Invalid route name: '/v1'
     # ./spec/api_routing_spec.rb:465:in `block (9 levels) in <top (required)>'
     # ./lib/versionist/routing.rb:42:in `configure_path'
     # ./lib/versionist/routing.rb:19:in `api_version'
     # ./spec/api_routing_spec.rb:464:in `block (8 levels) in <top (required)>'
     # ./spec/api_routing_spec.rb:463:in `block (7 levels) in <top (required)>'

  3) Versionist::Routing#api_version v2 :path :default => true should route to the default when no version given
     Failure/Error: match '/foos.(:format)' => 'foos#index', :via => :get
     ArgumentError:
       Invalid route name: '/v2'
     # ./spec/api_routing_spec.rb:465:in `block (9 levels) in <top (required)>'
     # ./lib/versionist/routing.rb:42:in `configure_path'
     # ./lib/versionist/routing.rb:19:in `api_version'
     # ./spec/api_routing_spec.rb:464:in `block (8 levels) in <top (required)>'
     # ./spec/api_routing_spec.rb:463:in `block (7 levels) in <top (required)>'

  4) Versionist::Routing#api_version v2 :path :default => true should not route to the default when another configured version is given
     Failure/Error: match '/foos.(:format)' => 'foos#index', :via => :get
     ArgumentError:
       Invalid route name: '/v2'
     # ./spec/api_routing_spec.rb:465:in `block (9 levels) in <top (required)>'
     # ./lib/versionist/routing.rb:42:in `configure_path'
     # ./lib/versionist/routing.rb:19:in `api_version'
     # ./spec/api_routing_spec.rb:464:in `block (8 levels) in <top (required)>'
     # ./spec/api_routing_spec.rb:463:in `block (7 levels) in <top (required)>'

  5) Versionist::Routing#api_version v2.1 :path :default => true should route to the default when no version given
     Failure/Error: match '/foos.(:format)' => 'foos#index', :via => :get
     ArgumentError:
       Invalid route name: '/v2.1'
     # ./spec/api_routing_spec.rb:465:in `block (9 levels) in <top (required)>'
     # ./lib/versionist/routing.rb:42:in `configure_path'
     # ./lib/versionist/routing.rb:19:in `api_version'
     # ./spec/api_routing_spec.rb:464:in `block (8 levels) in <top (required)>'
     # ./spec/api_routing_spec.rb:463:in `block (7 levels) in <top (required)>'

  6) Versionist::Routing#api_version v2.1 :path :default => true should not route to the default when another configured version is given
     Failure/Error: match '/foos.(:format)' => 'foos#index', :via => :get
     ArgumentError:
       Invalid route name: '/v2.1'
     # ./spec/api_routing_spec.rb:465:in `block (9 levels) in <top (required)>'
     # ./lib/versionist/routing.rb:42:in `configure_path'
     # ./lib/versionist/routing.rb:19:in `api_version'
     # ./spec/api_routing_spec.rb:464:in `block (8 levels) in <top (required)>'
     # ./spec/api_routing_spec.rb:463:in `block (7 levels) in <top (required)>'

Finished in 11.75 seconds
625 examples, 6 failures

Failed examples:

rspec ./spec/api_routing_spec.rb:473 # Versionist::Routing#api_version v1 :path :default => true should route to the default when no version given
rspec ./spec/api_routing_spec.rb:485 # Versionist::Routing#api_version v1 :path :default => true should not route to the default when another configured version is given
rspec ./spec/api_routing_spec.rb:473 # Versionist::Routing#api_version v2 :path :default => true should route to the default when no version given
rspec ./spec/api_routing_spec.rb:485 # Versionist::Routing#api_version v2 :path :default => true should not route to the default when another configured version is given
rspec ./spec/api_routing_spec.rb:473 # Versionist::Routing#api_version v2.1 :path :default => true should route to the default when no version given
rspec ./spec/api_routing_spec.rb:485 # Versionist::Routing#api_version v2.1 :path :default => true should not route to the default when another configured version is given

phallguy closed this Jun 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment