Skip to content

Commit

Permalink
Add tests for endpoint comments
Browse files Browse the repository at this point in the history
  • Loading branch information
emilmelnikov committed Jul 24, 2012
1 parent 38650ab commit 1f1f4ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions spec/route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f1f4ac

Please sign in to comment.