Sha256: 1c1984c0a4f3ccf92ac81ca12f82a27b1694cd221afb4439123191c418229c8d

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
require File.expand_path(File.join(File.dirname(__FILE__), 'compat'))
require "usher"

route_set = Usher::Interface.for(:rails23)

describe "Usher (for rails 2.3) URL generation" do
  
  before(:each) do
    route_set.reset!
  end

  it "should fill in the controller from recall" do
    route_set.add_route('/:controller/:action/:id')
    route_set.generate({:action => 'thingy'}, {:controller => 'sample', :action => 'index', :id => 123}, :generate).should == '/sample/thingy'
  end

  it "should skip the action if not provided" do
    route_set.add_route('/:controller/:action/:id')
    route_set.generate({:controller => 'thingy'}, {:controller => 'sample', :action => 'index', :id => 123}, :generate).should == '/thingy'
  end

  it "should pick the correct param from optional parts" do
    route_set.add_route('/:controller/:action(.:format)')
    route_set.generate({:action => 'thingy', :format => 'html'}, {:controller => 'sample', :action => 'index', :id => 123}, :generate).should == '/sample/thingy.html'
    route_set.generate({:action => 'thingy'}, {:controller => 'sample', :action => 'index', :id => 123}, :generate).should == '/sample/thingy'
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
usher-0.6.8 spec/private/rails2_3/generate_spec.rb
usher-0.6.7 spec/private/rails2_3/generate_spec.rb
usher-0.6.6 spec/private/rails2_3/generate_spec.rb
usher-0.6.5 spec/private/rails2_3/generate_spec.rb
usher-0.6.4 spec/private/rails2_3/generate_spec.rb
usher-0.6.3 spec/private/rails2_3/generate_spec.rb
usher-0.6.2 spec/private/rails2_3/generate_spec.rb
usher-0.6.1 spec/private/rails2_3/generate_spec.rb
usher-0.6.0 spec/private/rails2_3/generate_spec.rb
usher-0.5.13 spec/private/rails2_3/generate_spec.rb
usher-0.5.12 spec/private/rails2_3/generate_spec.rb