Sha256: 2be7ecd937d898977528e1daf341ae6c7d00999f96d03b4a7319893fd16f6a09

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

require 'lib/compat'
require 'lib/usher'

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

describe "Usher (for rails) 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

5 entries across 5 versions & 1 rubygems

Version Path
joshbuddy-usher-0.0.2 spec/rails/generate_spec.rb
joshbuddy-usher-0.0.3 spec/rails/generate_spec.rb
joshbuddy-usher-0.1.0 spec/rails/generate_spec.rb
joshbuddy-usher-0.1.1 spec/rails/generate_spec.rb
joshbuddy-usher-0.1.2 spec/rails/generate_spec.rb