diff --git a/spec/mapper_spec.rb b/spec/mapper_spec.rb index 89be029..9ccbf1e 100644 --- a/spec/mapper_spec.rb +++ b/spec/mapper_spec.rb @@ -46,6 +46,7 @@ module ApiTaster before(:all) do ApiTaster.routes do + desc "Dummy user ID" get '/dummy_users/:id', :id => 1 post '/dummy_users' post '/dummy_users', { :hello => 'world' } @@ -79,5 +80,17 @@ module ApiTaster Route.supplied_params[route[:id]].should == [{ :id => 3 }] end + + it "describes a route" do + route = Route.find_by_verb_and_path(:get, '/dummy_users/:id') + + Route.comment_for(route[:id]).should == "Dummy user ID" + end + + it "don't describe a route" do + route = Route.find_by_verb_and_path(:post, '/dummy_users') + + Route.comment_for(route[:id]).should be_nil + end end end diff --git a/spec/route_spec.rb b/spec/route_spec.rb index dfbc95f..89a5d26 100644 --- a/spec/route_spec.rb +++ b/spec/route_spec.rb @@ -96,6 +96,12 @@ module ApiTaster end end + it "#comment_for" do + markdown_comment = "Heading\n=======\n * List item 1\n * List item 2" + Route.comments[42] = markdown_comment + Route.comment_for(42).should eq(markdown) + end + it "#missing_definitions and #defined_definitions" do routes = ActionDispatch::Routing::RouteSet.new routes.draw do