useless-doc 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/lib/useless/doc/client.rb +62 -0
  2. data/lib/useless/doc/core/api.rb +6 -2
  3. data/lib/useless/doc/core/domain.rb +34 -0
  4. data/lib/useless/doc/dsl.rb +30 -0
  5. data/lib/useless/doc/rack/{stylesheet.rb → css.rb} +8 -8
  6. data/lib/useless/doc/rack/html.rb +26 -0
  7. data/lib/useless/doc/rack/subject.rb +40 -0
  8. data/lib/useless/doc/rack/ui.rb +12 -11
  9. data/lib/useless/doc/rack/url.rb +33 -0
  10. data/lib/useless/doc/rack.rb +46 -0
  11. data/lib/useless/doc/router.rb +62 -0
  12. data/lib/useless/doc/serialization/dump.rb +17 -0
  13. data/lib/useless/doc/serialization/load.rb +35 -0
  14. data/lib/useless/doc/sinatra.rb +4 -3
  15. data/lib/useless/doc/ui/godel/api.mustache +24 -24
  16. data/lib/useless/doc/ui/godel/domain.mustache +26 -0
  17. data/lib/useless/doc/ui/godel/resource.mustache +151 -155
  18. data/lib/useless/doc/ui/godel/stylesheet.css +156 -1
  19. data/lib/useless/doc/ui/godel.rb +54 -12
  20. data/lib/useless/doc/ui.rb +24 -0
  21. data/lib/useless/doc/version.rb +1 -1
  22. data/lib/useless/doc.rb +20 -2
  23. data/spec/config.ru +19 -0
  24. data/spec/documents/api.json +1 -0
  25. data/spec/documents/domain.json +17 -0
  26. data/spec/useless/doc/client_spec.rb +59 -0
  27. data/spec/useless/doc/dsl_spec.rb +28 -2
  28. data/spec/useless/doc/rack/{stylesheet_spec.rb → css_spec.rb} +3 -9
  29. data/spec/useless/doc/rack/html_spec.rb +39 -0
  30. data/spec/useless/doc/rack/subject_spec.rb +44 -0
  31. data/spec/useless/doc/rack/ui_spec.rb +1 -1
  32. data/spec/useless/doc/rack/url_spec.rb +35 -0
  33. data/spec/useless/doc/{rack/application_spec.rb → rack_spec.rb} +22 -11
  34. data/spec/useless/doc/router_spec.rb +38 -0
  35. data/spec/useless/doc/serialization/dump_spec.rb +29 -0
  36. data/spec/useless/doc/serialization/load_spec.rb +37 -0
  37. data/spec/useless/doc/sinatra_spec.rb +3 -1
  38. data/spec/useless/doc/ui/godel_spec.rb +136 -96
  39. data/useless-doc.gemspec +1 -1
  40. metadata +34 -21
  41. data/lib/useless/doc/rack/application.rb +0 -47
  42. data/lib/useless/doc/rack/proxy.rb +0 -62
  43. data/lib/useless/doc/rack/retriever.rb +0 -68
  44. data/lib/useless/doc/rack/transform.rb +0 -46
  45. data/spec/useless/doc/rack/proxy_spec.rb +0 -56
  46. data/spec/useless/doc/rack/retriever_spec.rb +0 -82
  47. data/spec/useless/doc/rack/transform_spec.rb +0 -57
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "Useless",
3
+ "url": "http://useless.io",
4
+ "description": "A collection of useless APIs.",
5
+ "apis": [
6
+ {
7
+ "name": "The Jah API",
8
+ "url": "http://jah.useless.io",
9
+ "description": "Jah, jah, jah."
10
+ },
11
+ {
12
+ "name": "The Twonk API",
13
+ "url": "http://twonk.useless.io",
14
+ "description": "TWONK!!!"
15
+ }
16
+ ]
17
+ }
@@ -0,0 +1,59 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ require 'useless/doc/client'
4
+
5
+ describe Useless::Doc::Client::Standard do
6
+ before(:each) do
7
+ @client = Useless::Doc::Client.standard
8
+ @client.instance_variable_set(:@cache, {})
9
+ end
10
+
11
+ it 'should make a normal request if the cache is empty.' do
12
+ Typhoeus.should_receive(:options).
13
+ with('http://some-api.granmal.com/some/resource', headers: { 'Accept' => 'application/json' }).
14
+ and_return(mock(:response, response_code: 200, response_body: load_document('twonk.json').read))
15
+
16
+ resource = @client.get('http://some-api.granmal.com/some/resource')
17
+ resource.path.should == '/twonks/:id'
18
+ end
19
+
20
+ it 'should return an API if that is what\'s returned' do
21
+ Typhoeus.should_receive(:options).
22
+ with('http://some-api.granmal.com/', headers: { 'Accept' => 'application/json' }).
23
+ and_return(mock(:response, response_code: 200, response_body: load_document('api.json').read))
24
+
25
+ api = @client.get('http://some-api.granmal.com/')
26
+ api.url.should == 'twonk.useless.io'
27
+ end
28
+
29
+ it 'should make a request with a cache control header if there is a cache hit.' do
30
+ now = Time.now
31
+ Time.should_receive(:now).once.and_return(now)
32
+
33
+ Typhoeus.should_receive(:options).once.
34
+ with('http://some-api.granmal.com/some/resource', headers: { 'Accept' => 'application/json' }).
35
+ and_return(mock(:response, response_code: 200, response_body: load_document('twonk.json').read))
36
+
37
+ Typhoeus.should_receive(:options).once.
38
+ with('http://some-api.granmal.com/some/resource', headers: { 'Accept' => 'application/json', 'If-Modified-Since' => now.httpdate}).
39
+ and_return(mock(:response, response_code: 304, response_body: ''))
40
+
41
+ @client.get('http://some-api.granmal.com/some/resource')
42
+ resource = @client.get('http://some-api.granmal.com/some/resource')
43
+ resource.path.should == '/twonks/:id'
44
+ end
45
+ end
46
+
47
+ describe Useless::Doc::Client::Stub do
48
+ it 'should serve files from the spec/documents directory' do
49
+ client = Useless::Doc::Client.stub
50
+ resource = client.get('http://anything.useless.io/twonk')
51
+ resource.path.should == '/twonks/:id'
52
+ end
53
+
54
+ it 'should return nil if the corresponding file doesn\'t exist' do
55
+ client = Useless::Doc::Client.stub
56
+ resource = client.get('http://anything.useless.io/nonexistant')
57
+ resource.should be_nil
58
+ end
59
+ end
@@ -5,10 +5,35 @@ require 'rack/test'
5
5
  require 'useless/doc'
6
6
  require 'useless/doc/dsl'
7
7
 
8
- describe Useless::Doc::DSL do
8
+ describe Useless::Doc::DSL::Domain do
9
+ describe '.build' do
10
+ it 'should provide a DSL for building a domain (through Useless::Doc.domain)' do
11
+ domain = Useless::Doc.domain 'useless.io' do
12
+ url 'http://useless.io'
13
+ description 'A collection of useless APIs.'
14
+
15
+ api 'Twonk' do
16
+ url 'twonk.useless.io'
17
+ description 'Twonk stuff'
18
+ end
19
+ end
20
+
21
+ domain.name.should == 'useless.io'
22
+ domain.url.should == 'http://useless.io'
23
+ domain.description.should == 'A collection of useless APIs.'
24
+
25
+ domain.apis.first.name.should == 'Twonk'
26
+ domain.apis.first.url.should == 'twonk.useless.io'
27
+ domain.apis.first.description.should == 'Twonk stuff'
28
+ end
29
+ end
30
+ end
31
+
32
+ describe Useless::Doc::DSL::API do
9
33
  describe '.build' do
10
34
  it 'should provide a terse DSL for building API documentation (through Useless::Doc.api)' do
11
- api = Useless::Doc.api 'widget.useless.io' do
35
+ api = Useless::Doc.api 'Widget API' do
36
+ url 'widget.useless.io'
12
37
  description 'The canonical source of worldwide widgets.'
13
38
 
14
39
  resource('/widgets').description 'The whole kit and kaboodle.'
@@ -64,6 +89,7 @@ describe Useless::Doc::DSL do
64
89
  timestamp '2013-01-12 12:44 AM'
65
90
  end
66
91
 
92
+ api.name.should == 'Widget API'
67
93
  api.url.should == 'widget.useless.io'
68
94
  api.description.should == 'The canonical source of worldwide widgets.'
69
95
  api.timestamp.should == Time.parse('2013-01-12 12:44 AM')
@@ -1,10 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  require 'rack/test'
4
- require 'useless/doc/rack/stylesheet'
4
+ require 'useless/doc/rack/css'
5
5
  require 'useless/doc/ui/godel'
6
6
 
7
- describe Useless::Doc::Rack::Stylesheet do
7
+ describe Useless::Doc::Rack::CSS do
8
8
  include Rack::Test::Methods
9
9
 
10
10
  def base_app
@@ -16,16 +16,10 @@ describe Useless::Doc::Rack::Stylesheet do
16
16
  def app
17
17
  @app ||= lambda do |env|
18
18
  env['useless.doc.ui'] = Useless::Doc::UI::Godel
19
- Useless::Doc::Rack::Stylesheet.new(base_app).call(env)
19
+ Useless::Doc::Rack::CSS.new(base_app).call(env)
20
20
  end
21
21
  end
22
22
 
23
- it 'should raise an error if a UI is not specified' do
24
- app = Useless::Doc::Rack::Stylesheet.new(base_app)
25
- request = Rack::MockRequest.new(app)
26
- lambda { request.get('http://some-api.granmal.com/doc.css') }.should raise_error(RuntimeError, 'No UI specified.')
27
- end
28
-
29
23
  it 'should proxy requests if the path is not doc.css' do
30
24
  get 'http://some-api.granmal.com/not/doc.css'
31
25
  last_response.body.should == 'Not a stylesheet request.'
@@ -0,0 +1,39 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ require 'rack/test'
4
+ require 'useless/doc/ui/godel'
5
+ require 'useless/doc/core/api'
6
+ require 'useless/doc/rack/html'
7
+
8
+ describe Useless::Doc::Rack::HTML do
9
+ include Rack::Test::Methods
10
+
11
+ before(:all) do
12
+ @ui = Useless::Doc::UI::Godel.new(nil)
13
+ @subject = Useless::Doc::Core::API.new
14
+ end
15
+
16
+ def app
17
+ @app ||= lambda do |env|
18
+ env['useless.doc.ui'] = @ui
19
+ env['useless.doc.subject'] = @subject
20
+
21
+ Useless::Doc::Rack::HTML.call(env)
22
+ end
23
+ end
24
+
25
+ it 'should transform the subject to HTML via the specified UI' do
26
+ @ui.should_receive(:html).with(@subject).and_return('html')
27
+
28
+ get 'http://some-api.doc.useless.io/some/resource'
29
+ last_response.should be_ok
30
+ last_response.body.should == 'html'
31
+ end
32
+
33
+ it 'should return a 404 if the UI cannot render the HTML' do
34
+ @ui.should_receive(:html).with(@subject).and_return(nil)
35
+
36
+ get 'http://some-api.doc.useless.io/some/resource'
37
+ last_response.should be_not_found
38
+ end
39
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ require 'rack/test'
4
+ require 'useless/doc/rack/subject'
5
+
6
+ describe Useless::Doc::Rack::Subject do
7
+ include Rack::Test::Methods
8
+
9
+ def app
10
+ @app ||= lambda do |env|
11
+ base_app = lambda do |env|
12
+ [200, {'Content-Type' => 'text/plain'}, [env['useless.doc.subject']]]
13
+ end
14
+
15
+ env['useless.doc.url'] = 'some.api.com'
16
+ Useless::Doc::Rack::Subject.new(base_app).call(env)
17
+ end
18
+ end
19
+
20
+ it 'should retrieve the subject from the stub client in a non-production environment' do
21
+ Useless::Doc::Client.stub.should_receive(:get).with('some.api.com').and_return('test subject')
22
+ get 'some.doc.api.com'
23
+ last_response.should be_ok
24
+ last_response.body.should == 'test subject'
25
+ end
26
+
27
+ it 'should retrieve the subject from the standard client in a production environment' do
28
+ begin
29
+ ENV['RACK_ENV'] = 'production'
30
+ Useless::Doc::Client.standard.should_receive(:get).with('some.api.com').and_return('production subject')
31
+ get 'some.doc.api.com'
32
+ last_response.should be_ok
33
+ last_response.body.should == 'production subject'
34
+ ensure
35
+ ENV['RACK_ENV'] = 'test'
36
+ end
37
+ end
38
+
39
+ it 'should return a 404 if no subject is returned' do
40
+ Useless::Doc::Client.stub.should_receive(:get).with('some.api.com').and_return(nil)
41
+ get 'some.doc.api.com'
42
+ last_response.should be_not_found
43
+ end
44
+ end
@@ -9,7 +9,7 @@ describe Useless::Doc::Rack::UI do
9
9
  def app
10
10
  @app ||= begin
11
11
  base_app = lambda do |env|
12
- [200, {'Content-Type' => 'text/plain'}, [env['useless.doc.ui'].name]]
12
+ [200, {'Content-Type' => 'text/plain'}, [env['useless.doc.ui'].class.name]]
13
13
  end
14
14
 
15
15
  Useless::Doc::Rack::UI.new(base_app)
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ require 'rack/test'
4
+ require 'useless/doc/router'
5
+ require 'useless/doc/rack/url'
6
+
7
+ describe Useless::Doc::Rack::URL do
8
+ include Rack::Test::Methods
9
+
10
+ def app
11
+ @app ||= lambda do |env|
12
+ base_app = lambda do |env|
13
+ [200, {'Content-Type' => 'text/plain'}, [env['useless.doc.url']]]
14
+ end
15
+
16
+ env['useless.doc.router'] = Useless::Doc::Router.default
17
+ Useless::Doc::Rack::URL.new(base_app).call(env)
18
+ end
19
+ end
20
+
21
+ it 'should ask the router for the api URL' do
22
+ Useless::Doc::Router.default.should_receive(:api_for_doc).
23
+ with('http://some.doc.api.com/').and_return('http://some.api.com/')
24
+ get 'http://some.doc.api.com/'
25
+ last_response.should be_ok
26
+ last_response.body.should == 'http://some.api.com/'
27
+ end
28
+
29
+ it 'should return a 404 if the URL could not be determined' do
30
+ Useless::Doc::Router.default.should_receive(:api_for_doc).
31
+ with('http://some.doc.api.com/').and_return(nil)
32
+ get 'http://some.doc.api.com/'
33
+ last_response.should be_not_found
34
+ end
35
+ end
@@ -1,18 +1,19 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
3
  require 'rack/test'
4
- require 'useless/doc/rack/application'
5
- require 'useless/doc/rack/retriever'
4
+ require 'useless/doc'
5
+ require 'useless/doc/rack'
6
+ require 'useless/doc/client'
6
7
 
7
- describe Useless::Doc::Rack::Application do
8
+ describe Useless::Doc::Rack do
8
9
  include Rack::Test::Methods
9
10
 
10
11
  def app
11
- @app ||= Useless::Doc::Rack::Application.new('some-api')
12
+ Useless::Doc::Rack.new
12
13
  end
13
14
 
14
15
  it 'should return a 404 if the JSON cannot be retrieved' do
15
- Useless::Doc::Rack::Retriever::Stub.should_receive(:retrieve).
16
+ Useless::Doc::Client.stub.should_receive(:get).
16
17
  with('http://some-api.useless.io/some/non-existant/resource').
17
18
  and_return(nil)
18
19
 
@@ -25,20 +26,30 @@ describe Useless::Doc::Rack::Application do
25
26
  last_response.should be_not_found
26
27
  end
27
28
 
29
+ it 'should return domain HTML for the root path' do
30
+ Useless::Doc::Client.stub.should_receive(:get).
31
+ with('http://useless.io/').
32
+ and_return(Useless::Doc.load.domain(load_document('domain.json').read))
33
+
34
+ get 'http://doc.useless.io/'
35
+ last_response.should be_ok
36
+ last_response.body.should =~ /<h1>Useless<\/h1>/
37
+ end
38
+
28
39
  it 'should return API HTML if proper JSON is retrieved' do
29
- Useless::Doc::Rack::Retriever::Stub.should_receive(:retrieve).
40
+ Useless::Doc::Client.stub.should_receive(:get).
30
41
  with('http://some-api.useless.io/').
31
- and_return(load_document('api.json'))
42
+ and_return(Useless::Doc.load.api(load_document('api.json').read))
32
43
 
33
44
  get 'http://some-api.doc.useless.io/'
34
45
  last_response.should be_ok
35
- last_response.body.should =~ /<h1>twonk\.useless\.io<\/h1>/
46
+ last_response.body.should =~ /<h1>Twonk API<\/h1>/
36
47
  end
37
48
 
38
49
  it 'should return resource HTML if proper JSON is retrieved' do
39
- Useless::Doc::Rack::Retriever::Stub.should_receive(:retrieve).
50
+ Useless::Doc::Client.stub.should_receive(:get).
40
51
  with('http://some-api.useless.io/some/resource').
41
- and_return(load_document('twonk.json'))
52
+ and_return(Useless::Doc.load.resource(load_document('twonk.json').read))
42
53
 
43
54
  get 'http://some-api.doc.useless.io/some/resource'
44
55
  last_response.should be_ok
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ require 'rack/test'
4
+ require 'useless/doc'
5
+ require 'useless/doc/router'
6
+
7
+ describe Useless::Doc::Router::Default do
8
+ before(:all) do
9
+ @router = Useless::Doc::Router::Default.new('api.domain.com', 'useless.io')
10
+ end
11
+
12
+ describe '.doc_for_api' do
13
+ it 'should add a \'doc\' subdomain before the existing subdomain' do
14
+ @router.doc_for_api('http://api.domain.com/some/path').
15
+ should == 'http://api.doc.domain.com/some/path'
16
+ end
17
+
18
+ it 'should return nil if the specified URL is not part of the domain' do
19
+ @router.doc_for_api('http://nonexistant.domain.com/some/path').should be_nil
20
+ end
21
+ end
22
+
23
+ describe '.api_for_doc' do
24
+ it 'should remove the \'doc\' subdomain' do
25
+ @router.api_for_doc('http://api.doc.domain.com/some/path').
26
+ should == 'http://api.domain.com/some/path'
27
+ end
28
+
29
+ it 'should remove the \'doc\' subdomain, even if it\'s the only subdomain' do
30
+ @router.api_for_doc('http://doc.useless.io').
31
+ should == 'http://useless.io'
32
+ end
33
+
34
+ it 'should return nil if the resulting URL is not part of the domain' do
35
+ @router.api_for_doc('http://nonexistant.doc.domain.com/some/path').should be_nil
36
+ end
37
+ end
38
+ end
@@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  require 'useless/doc/core/api'
4
4
  require 'useless/doc/core/body'
5
+ require 'useless/doc/core/domain'
5
6
  require 'useless/doc/core/header'
6
7
  require 'useless/doc/core/request'
7
8
  require 'useless/doc/core/resource'
@@ -22,6 +23,32 @@ describe Useless::Doc::Serialization::Dump do
22
23
  end
23
24
  end
24
25
 
26
+ describe '.domain' do
27
+ it 'should convert the specified Core::Domain instance to JSON' do
28
+ api = Useless::Doc::Core::API.new \
29
+ name: 'Twiddles API',
30
+ url: 'twiddles.useless.io',
31
+ description: 'Pretty much, like, everything you\'re looking for'
32
+
33
+ domain = Useless::Doc::Core::Domain.new \
34
+ name: 'Useless',
35
+ url: 'http://useless.io',
36
+ description: 'A collection of useless APIs.',
37
+ apis: [api]
38
+
39
+ json = Useless::Doc::Serialization::Dump.domain(domain)
40
+ hash = Useless::Doc::Serialization::Load.json_to_hash(json)
41
+ hash['name'].should == 'Useless'
42
+ hash['url'].should == 'http://useless.io'
43
+ hash['description'].should == 'A collection of useless APIs.'
44
+
45
+ api_hash = Useless::Doc::Serialization::Load.json_to_hash(hash['apis'][0])
46
+ api_hash['name'].should == 'Twiddles API'
47
+ api_hash['url'].should == 'twiddles.useless.io'
48
+ api_hash['description'].should == 'Pretty much, like, everything you\'re looking for'
49
+ end
50
+ end
51
+
25
52
  describe '.api' do
26
53
  it 'should convert the specified Core::API instance to JSON' do
27
54
  resource = Useless::Doc::Core::Resource.new \
@@ -30,12 +57,14 @@ describe Useless::Doc::Serialization::Dump do
30
57
  requests: []
31
58
 
32
59
  api = Useless::Doc::Core::API.new \
60
+ name: 'Twiddles API',
33
61
  url: 'twiddles.useless.io',
34
62
  description: 'Pretty much, like, everything you\'re looking for',
35
63
  resources: [resource]
36
64
 
37
65
  json = Useless::Doc::Serialization::Dump.api(api)
38
66
  hash = Useless::Doc::Serialization::Load.json_to_hash(json)
67
+ hash['name'].should == 'Twiddles API'
39
68
  hash['url'].should == 'twiddles.useless.io'
40
69
  hash['description'].should == 'Pretty much, like, everything you\'re looking for'
41
70
 
@@ -1,6 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  require 'useless/doc/serialization/load'
4
+ require 'useless/doc/core/domain'
5
+ require 'useless/doc/core/api'
6
+ require 'useless/doc/core/resource'
4
7
 
5
8
  describe Useless::Doc::Serialization::Load do
6
9
  describe '.json_to_hash' do
@@ -16,10 +19,44 @@ describe Useless::Doc::Serialization::Load do
16
19
  end
17
20
  end
18
21
 
22
+ describe '.load' do
23
+ it 'should return a Domain instance if domain JSON is provided' do
24
+ document = load_document('domain.json')
25
+ api = Useless::Doc::Serialization::Load.load document.read
26
+ api.should be_an_instance_of(Useless::Doc::Core::Domain)
27
+ end
28
+
29
+ it 'should return an API instance if API JSON is provided' do
30
+ document = load_document('api.json')
31
+ api = Useless::Doc::Serialization::Load.load document.read
32
+ api.should be_an_instance_of(Useless::Doc::Core::API)
33
+ end
34
+
35
+ it 'should return a Resource instance if resource JSON is provided' do
36
+ document = load_document('twonk.json')
37
+ resource = Useless::Doc::Serialization::Load.load document.read
38
+ resource.should be_an_instance_of(Useless::Doc::Core::Resource)
39
+ end
40
+ end
41
+
42
+ describe '.domain' do
43
+ it 'should parse the specified JSON into a Domain instance' do
44
+ document = load_document('domain.json')
45
+ domain = Useless::Doc::Serialization::Load.domain document.read
46
+ domain.name.should == 'Useless'
47
+ domain.url.should == 'http://useless.io'
48
+ domain.description.should == 'A collection of useless APIs.'
49
+ domain.apis.first.name.should == 'The Jah API'
50
+ domain.apis.first.url.should == 'http://jah.useless.io'
51
+ domain.apis.first.description.should == 'Jah, jah, jah.'
52
+ end
53
+ end
54
+
19
55
  describe '.api' do
20
56
  it 'should parse the specified JSON into an API instance' do
21
57
  document = load_document('api.json')
22
58
  api = Useless::Doc::Serialization::Load.api document.read
59
+ api.name.should == 'Twonk API'
23
60
  api.url.should == 'twonk.useless.io'
24
61
  api.description.should == 'Twonk information. Duh.'
25
62
  api.resources.first.path.should == '/twonks/:id'
@@ -9,7 +9,8 @@ describe Useless::Doc::Sinatra do
9
9
  class DocApp < Sinatra::Base
10
10
  register Useless::Doc::Sinatra
11
11
 
12
- doc 'resource.useless.io' do
12
+ doc 'Resoruce API' do
13
+ url 'resource.useless.io'
13
14
  description 'A resource repository'
14
15
  timestamp '2013-01-01 12:00 PM'
15
16
  end
@@ -69,6 +70,7 @@ describe Useless::Doc::Sinatra do
69
70
  options 'http://some-api.granmal.com/'
70
71
  api = Useless::Doc::Serialization::Load.api(last_response.body)
71
72
 
73
+ api.name.should == 'Resoruce API'
72
74
  paths = api.resources.map { |resource| resource.path }
73
75
  paths.length.should == 2
74
76
  paths.should include '/some-resources'