Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More primitive routing has been added
- Loading branch information
Showing
2 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
module RoutingExample | ||
nsurl 'http://strokedb.com/zoid/spec#routing' | ||
remove_const(:SomeName) if defined?(SomeName) | ||
SomeName = StrokeDB::Meta.new | ||
end | ||
|
||
|
||
describe Zoid::Application, "router" do | ||
|
||
before(:each) do | ||
setup_default_store | ||
@module = Module.new do | ||
nsurl 'http://strokedb.com/zoid/spec#routing' | ||
SomeName = StrokeDB::Meta.new | ||
end | ||
@app = Zoid::Application.create!(:name => 'Routing Application', :nsurl => @module.nsurl) | ||
@app = Zoid::Application.create!(:name => 'Routing Application', :nsurl => RoutingExample.nsurl) | ||
end | ||
|
||
# GET | ||
it "should route GET + /name(/)? to a named entity within application module" do | ||
@app.route_for('GET', '/some_name').should == @module.const_get('SomeName') | ||
@app.route_for('GET', '/some_name/').should == @module.const_get('SomeName') | ||
@app.route_for('GET', '/some_name').should == RoutingExample::SomeName | ||
@app.route_for('GET', '/some_name/').should ==RoutingExample::SomeName | ||
end | ||
|
||
it "should route GET + /name/uuid to a named entity with specified UUID" do | ||
doc = RoutingExample::SomeName.create! | ||
@app.route_for('GET', "/some_name/#{doc.uuid}").should == doc | ||
end | ||
|
||
it "should route GET + /name/uuid.version to a named entity with specified UUID" do | ||
doc = RoutingExample::SomeName.create!.versions.current | ||
@app.route_for('GET', "/some_name/#{doc.uuid}.#{doc.version}").should == doc | ||
end | ||
|
||
end |