Skip to content

Commit

Permalink
more dynamic path tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lori Holden committed May 28, 2010
1 parent f703d6a commit 732a303
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion spec/generate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
@router.add("/:var").name(:test).compile
@router.url(:test, 'test', :query => 'string').should == '/test?query=string'
end

it "should generate with multiple dynamics" do
@router.add("/:var/:baz").name(:test).compile
@router.url(:test, 'one', 'two').should == '/one/two'
@router.url(:test, :var => 'one', :baz => 'two').should == '/one/two'
end

context "with a :format" do
it "should generate with a format" do
Expand Down Expand Up @@ -65,6 +71,20 @@
@router.url(:test, 'var').should == '/var'
@router.url(:test, 'var', :format => 'html').should == '/var.html'
end

it "should generate multiple dynamics and a format" do
@router.add("/:foo/:bar.:format").name(:test).compile
@router.url(:test, 'var', 'baz', 'html').should == '/var/baz.html'
@router.url(:test, :foo => 'var', :bar => 'baz', :format => 'html').should == '/var/baz.html'
end

it "should generate multiple dynamics and an optional format" do
@router.add("/:foo/:bar(.:format)").name(:test).compile
@router.url(:test, 'var', 'baz').should == '/var/baz'
@router.url(:test, 'var', 'baz', 'html').should == '/var/baz.html'
@router.url(:test, :foo => 'var', :bar => 'baz').should == '/var/baz'
@router.url(:test, :foo => 'var', :bar => 'baz', :format => 'html').should == '/var/baz.html'
end
end

context "with optional parts" do
Expand Down Expand Up @@ -108,7 +128,7 @@
# However, url generated with:
# url(:test, :var1 => 'blah', :var3 => 'more')
# would be recognized as /:var1(/:var2) instead of /:var1(/:var3)
# Might want to throw ane error when generating a route thats broken like this.
# Might want to throw an error when generating a route thats broken like this.
it "should be smart about multiple optionals"
end
end
Expand Down

0 comments on commit 732a303

Please sign in to comment.