Sha256: e2cb90731c11bf05c59d144ccea08017f3e336058239c08dfbe259aad36f0305

Contents?: true

Size: 1.43 KB

Versions: 26

Compression:

Stored size: 1.43 KB

Contents

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

describe "Usher grapher" do

  before(:each) do
    @route_set = Usher.new(:generator => Usher::Util::Generators::URL.new)
    @route_set.reset!
  end

  it "should find a simple path" do
    @route_set.add_route('/:a/:b/:c')
    @route_set.generator.generate(nil, {:a => 'A', :b => 'B', :c => 'C'}).should == '/A/B/C'
  end

  it "should pick a more specific route" do
    @route_set.add_route('/:a/:b')
    @route_set.add_route('/:a/:b/:c')
    @route_set.generator.generate(nil, {:a => 'A', :b => 'B', :c => 'C'}).should == '/A/B/C'
  end

  it "should fail to generate a route when none matches" do
    @route_set.add_route('/:a/:b')
    proc {@route_set.generator.generate(nil, {:c => 'C', :d => 'D'}) }.should raise_error Usher::UnrecognizedException
  end

  it "should find the most specific route and append extra parts on as a query string" do
    @route_set.add_route('/:a/:b/:c')
    @route_set.add_route('/:a/:b')
    @route_set.generator.generate(nil, {:a => 'A', :b => 'B', :d => 'C'}).should == '/A/B?d=C'
  end
  
  # FIXME
  #it "should do a validity check against the incoming variables when asked to" do
  #  route_set.add_route('/:a/:b', :b => /\d+/)
  #  route_set.generate_url(nil, {:a => 'A', :b => 'B'}).should == '/A/B'
  #  proc{ route_set.generate_url(nil, {:a => 'A', :b => 'B'})}.should raise_error Usher::ValidationException
  #end

end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
joshbuddy-usher-0.5.7 spec/private/grapher_spec.rb
usher-0.8.3 spec/private/grapher_spec.rb
usher-0.8.2 spec/private/grapher_spec.rb
usher-0.8.1 spec/private/grapher_spec.rb
usher-0.8.0 spec/private/grapher_spec.rb
usher-0.7.5 spec/private/grapher_spec.rb
usher-0.7.4 spec/private/grapher_spec.rb
usher-0.7.3 spec/private/grapher_spec.rb
usher-0.7.2 spec/private/grapher_spec.rb
usher-0.7.1 spec/private/grapher_spec.rb
usher-0.7.0 spec/private/grapher_spec.rb
usher-0.6.8 spec/private/grapher_spec.rb
usher-0.6.7 spec/private/grapher_spec.rb
usher-0.6.6 spec/private/grapher_spec.rb
usher-0.6.5 spec/private/grapher_spec.rb
usher-0.6.4 spec/private/grapher_spec.rb
usher-0.6.3 spec/private/grapher_spec.rb
usher-0.6.2 spec/private/grapher_spec.rb
usher-0.6.1 spec/private/grapher_spec.rb
usher-0.6.0 spec/private/grapher_spec.rb