Sha256: 13a98c2e6bfcfab925ea1206ffeb814f0a5e3cca260390f8d629bbd2c5fc1c06

Contents?: true

Size: 982 Bytes

Versions: 4

Compression:

Stored size: 982 Bytes

Contents

require 'lib/usher'

route_set = Usher.new

describe "Usher route adding" do

  before(:each) do
    route_set.reset!
  end

  it "should be empty after a reset" do
    route_set.add_route('/sample', :controller => 'sample')
    route_set.empty?.should == false
    route_set.reset!
    route_set.empty?.should == true
  end
  
  it "shouldn't care about routes without a controller" do
    proc { route_set.add_route('/bad/route') }.should_not raise_error
  end

  it "should add every kind of optional route possible" do
    route_set.add_route('/a/b(/c)(/d(/e))')
    route_set.routes.first.paths.collect{|a| a.parts }.should == [
      ["a", "b"],
      ["a", "b", "c", "d"], 
      ["a", "b", "d", "e"], 
      ["a", "b", "c"],
      ["a", "b", "d"],
      ["a", "b", "c", "d", "e"]
    ]
    
  end

  it "should allow named routes to be added" do
    route_set.add_named_route(:route, '/bad/route', :controller => 'sample').should == route_set.named_routes[:route]
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
joshbuddy-usher-0.2.0 spec/path_spec.rb
joshbuddy-usher-0.2.1 spec/path_spec.rb
joshbuddy-usher-0.2.2 spec/path_spec.rb
joshbuddy-usher-0.3.0 spec/path_spec.rb