Sha256: 1892fcdca3e4ca353083065a710099cdba5a3227e4926c4463f0b2fc13c4b02e

Contents?: true

Size: 1.39 KB

Versions: 26

Compression:

Stored size: 1.39 KB

Contents

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

route_set = Usher::Interface.for(:rack)
route_set.extend(CallWithMockRequestMixin)

describe "Usher (for rack) route generation" do
  before(:each) do
    route_set.reset!
    @app = MockApp.new("Hello World!")
    route_set.add("/fixed").name(:fixed)
    route_set.add("/simple/:simple_var")
    route_set.add("/named/simple/:named_simple_var").name(:simple)
    route_set.add("/optional(/:optional_var)")
    route_set.add("/named/optional(/:named_optional_var)").name(:optional)
  end
  
  describe "named routes" do
    it "should generate a fixed path" do
      route_set.generate(:fixed).should == "/fixed"
    end
    
    it "should generate a basic path route" do
      route_set.generate(nil, :simple_var => "simple_var").should == "/simple/simple_var"
    end

    it "should generate a named path route" do
      route_set.generate(:simple, :named_simple_var => "the_var").should == "/named/simple/the_var"
    end

    it "should generate a route with options" do
      route_set.generate(nil, :optional_var => "var").should == "/optional/var"
    end

    it "should generate a named route with options" do
      route_set.generate(:optional).should == "/named/optional"
      route_set.generate(:optional, :named_optional_var => "the_var").should == "/named/optional/the_var"
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

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