autodoc 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 937c3ab0cd4c58a348027ba6b9a05d2c87d45e6b
4
- data.tar.gz: ee87c40f918c645971f3f14cdb7a26756557371f
3
+ metadata.gz: d93952ec85969ac234dbeb59363103d1587a06dd
4
+ data.tar.gz: 2f69882edbd84d12d0cd5c257858fa50a45d4a66
5
5
  SHA512:
6
- metadata.gz: 6da626b43eab6022fb1d434cd7800ecba703113be0246c6f5230618ee031a6168d8bf43d6250d23964ff19ba03d50321f6e0e1ebc7172e530ad108e3ff63b202
7
- data.tar.gz: c5c7e82c7915f3efcedda12a4d88365eeaceacd6c2d8cf8584780fae8808ec0b800fecc3d6b3d8804c2ec1a0bc80ad8e93c4deff51e99f0edb4978b4990fb93e
6
+ metadata.gz: 5ba609ac4bed6ac01df05fcaa3b1c6dcf1101e150d106016d4bcecc4850dc334a7074f785ce342df9cf6101e297e6673348b39c5cb9e985d6b325777b99b8b6e
7
+ data.tar.gz: 8af2b92831a033e1b9d189911b92ac379e4651d02f752a11d70e691b8d26d2b21565f8b7edaf6b1b1831082ca0395ff9e6e8d4b70264a5f8bf7400be111786bd
@@ -1,3 +1,6 @@
1
+ ## 0.3.3
2
+ * Fix ToC template for specs in sub-directory
3
+
1
4
  ## 0.3.2
2
5
  * Fix template & document bug
3
6
 
@@ -37,5 +37,9 @@ module Autodoc
37
37
  property :toc do
38
38
  false
39
39
  end
40
+
41
+ def pathname
42
+ Pathname.new(path)
43
+ end
40
44
  end
41
45
  end
@@ -18,7 +18,7 @@ module Autodoc
18
18
  def pathname
19
19
  @path ||= begin
20
20
  payload = @context.example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
21
- Pathname.new(Autodoc.configuration.path) + payload
21
+ Autodoc.configuration.pathname + payload
22
22
  end
23
23
  end
24
24
 
@@ -35,7 +35,7 @@ module Autodoc
35
35
  end
36
36
 
37
37
  def toc_path
38
- Pathname.new(Autodoc.configuration.path) + "toc.md"
38
+ Autodoc.configuration.pathname + "toc.md"
39
39
  end
40
40
  end
41
41
  end
@@ -1,11 +1,12 @@
1
1
  <%# coding: UTF-8 -%>
2
2
  ## Table of Contents
3
3
  <% @table.sort.each do |pathname, documents| -%>
4
- * [<%= pathname.basename %>](<%= pathname.basename %>)
4
+ <% relative_path = pathname.relative_path_from(Autodoc.configuration.pathname) -%>
5
+ * [<%= relative_path %>](<%= relative_path %>)
5
6
  <% documents.group_by(&:title).each do |title, documents| -%>
6
7
  <% documents.each_with_index do |document, index| -%>
7
8
  <% suffix = index == 0 ? "" : "-#{index}" -%>
8
- * [<%= title %>](<%= "#{pathname.basename}##{document.identifier}#{suffix}" %>)
9
+ * [<%= title %>](<%= "#{relative_path}##{document.identifier}#{suffix}" %>)
9
10
  <% end -%>
10
11
  <% end -%>
11
12
  <% end -%>
@@ -1,3 +1,3 @@
1
1
  module Autodoc
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -0,0 +1,67 @@
1
+ require "spec_helper"
2
+
3
+ describe Autodoc::Documents do
4
+ describe "#render_toc" do
5
+ before do
6
+ documents.append(context)
7
+ end
8
+
9
+ let(:documents) do
10
+ Autodoc::Documents.new
11
+ end
12
+
13
+ let(:context) do
14
+ mock = double(example: example, request: request)
15
+ mock.stub(clone: mock)
16
+ mock
17
+ end
18
+
19
+ let(:example) do
20
+ double(file_path: file_path, full_description: full_description)
21
+ end
22
+
23
+ let(:file_path) do
24
+ "spec/requests/recipes.md"
25
+ end
26
+
27
+ let(:request) do
28
+ double(method: method)
29
+ end
30
+
31
+ let(:method) do
32
+ "GET"
33
+ end
34
+
35
+ context "with GET /recipes spec" do
36
+ let(:full_description) do
37
+ "Recipe #{method} /recipes returns recipes"
38
+ end
39
+
40
+ let(:file_path) do
41
+ "./spec/requests/recipes_spec.rb"
42
+ end
43
+
44
+ it "includes links to recipes.md" do
45
+ toc = documents.send(:render_toc)
46
+ toc.should include("[recipes.md](recipes.md)")
47
+ toc.should include("[GET /recipes](recipes.md#get-recipes)")
48
+ end
49
+ end
50
+
51
+ context "with GET /admin/recipes spec" do
52
+ let(:full_description) do
53
+ "Admin::Recipe #{method} /admin/recipes returns recipes for administrator"
54
+ end
55
+
56
+ let(:file_path) do
57
+ "./spec/requests/admin/recipes_spec.rb"
58
+ end
59
+
60
+ it "includes links to admin/recipes.md" do
61
+ toc = documents.send(:render_toc)
62
+ toc.should include("[admin/recipes.md](admin/recipes.md)")
63
+ toc.should include("[GET /admin/recipes](admin/recipes.md#get-adminrecipes)")
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,23 @@
1
+ ## GET /admin/entries
2
+ Returns entries.
3
+
4
+ ### Example
5
+ ```
6
+ GET /admin/entries HTTP/1.1
7
+ Accept: application/json
8
+ Content-Length: 0
9
+ Host: example.org
10
+ ```
11
+
12
+ ```
13
+ HTTP/1.1 200
14
+ Content-Length: 45
15
+ Content-Type: application/json
16
+
17
+ [
18
+ {
19
+ "title": "Test Title",
20
+ "body": "Lorem Ipsum"
21
+ }
22
+ ]
23
+ ```
@@ -14,11 +14,11 @@ HTTP/1.1 200
14
14
  Cache-Control: max-age=0, private, must-revalidate
15
15
  Content-Length: 111
16
16
  Content-Type: application/json; charset=utf-8
17
- ETag: "817f9446a34cdb5179ee09b555b507f8"
17
+ ETag: "d2bb4f3624c215dcc71b683ec7d58ebd"
18
18
  X-Content-Type-Options: nosniff
19
19
  X-Frame-Options: SAMEORIGIN
20
- X-Request-Id: a1723cc5-c4f7-4779-8382-5dbf879687e5
21
- X-Runtime: 0.017503
20
+ X-Request-Id: 5f84d51d-9709-4a8f-a02c-77732902252b
21
+ X-Runtime: 0.013851
22
22
  X-UA-Compatible: chrome=1
23
23
  X-XSS-Protection: 1; mode=block
24
24
 
@@ -26,8 +26,8 @@ X-XSS-Protection: 1; mode=block
26
26
  "id": 1,
27
27
  "name": "test",
28
28
  "type": 2,
29
- "created_at": "2013-12-18T06:33:23.129Z",
30
- "updated_at": "2013-12-18T06:33:23.129Z"
29
+ "created_at": "2013-12-29T14:22:59.625Z",
30
+ "updated_at": "2013-12-29T14:22:59.625Z"
31
31
  }
32
32
  ```
33
33
 
@@ -61,12 +61,12 @@ HTTP/1.1 201
61
61
  Cache-Control: max-age=0, private, must-revalidate
62
62
  Content-Length: 111
63
63
  Content-Type: application/json; charset=utf-8
64
- ETag: "9a32ff7207d60c4e3eca833ed83320f9"
64
+ ETag: "0d698f869368039f2145c92927b36720"
65
65
  Location: http://www.example.com/recipes/1
66
66
  X-Content-Type-Options: nosniff
67
67
  X-Frame-Options: SAMEORIGIN
68
- X-Request-Id: 06f2dfe3-3085-419a-b2a8-db3abd1d3156
69
- X-Runtime: 0.006099
68
+ X-Request-Id: 84349101-dc40-4416-83a0-a767242881f9
69
+ X-Runtime: 0.003861
70
70
  X-UA-Compatible: chrome=1
71
71
  X-XSS-Protection: 1; mode=block
72
72
 
@@ -74,7 +74,7 @@ X-XSS-Protection: 1; mode=block
74
74
  "id": 1,
75
75
  "name": "name",
76
76
  "type": 1,
77
- "created_at": "2013-12-18T06:33:23.195Z",
78
- "updated_at": "2013-12-18T06:33:23.195Z"
77
+ "created_at": "2013-12-29T14:22:59.676Z",
78
+ "updated_at": "2013-12-29T14:22:59.676Z"
79
79
  }
80
80
  ```
@@ -1,4 +1,6 @@
1
1
  ## Table of Contents
2
+ * [admin/entries.md](admin/entries.md)
3
+ * [GET /admin/entries](admin/entries.md#get-adminentries)
2
4
  * [entries.md](entries.md)
3
5
  * [GET /entries](entries.md#get-entries)
4
6
  * [recipes.md](recipes.md)
@@ -0,0 +1,39 @@
1
+ require "spec_helper"
2
+
3
+ describe "Admin::Entries" do
4
+ include Rack::Test::Methods
5
+
6
+ let(:env) do
7
+ { "HTTP_ACCEPT" => "application/json" }
8
+ end
9
+
10
+ let(:params) do
11
+ {}
12
+ end
13
+
14
+ let(:app) do
15
+ lambda do |env|
16
+ [
17
+ 200,
18
+ { "Content-Type" => "application/json" },
19
+ [
20
+ [
21
+ {
22
+ title: "Test Title",
23
+ body: "Lorem Ipsum",
24
+ },
25
+ ].to_json,
26
+ ],
27
+ ]
28
+ end
29
+ end
30
+
31
+ describe "GET /admin/entries" do
32
+ context "with Rack::Test", :autodoc do
33
+ it "returns entries" do
34
+ get "/admin/entries", params, env
35
+ last_response.status.should == 200
36
+ end
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-18 00:00:00.000000000 Z
11
+ date: 2013-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -130,6 +130,7 @@ files:
130
130
  - lib/autodoc/templates/document.md.erb
131
131
  - lib/autodoc/templates/toc.md.erb
132
132
  - lib/autodoc/version.rb
133
+ - spec/autodoc/documents_spec.rb
133
134
  - spec/dummy/Rakefile
134
135
  - spec/dummy/app/assets/javascripts/application.js
135
136
  - spec/dummy/app/assets/stylesheets/application.css
@@ -158,6 +159,7 @@ files:
158
159
  - spec/dummy/config/routes.rb
159
160
  - spec/dummy/db/migrate/20130607075126_create_recipes.rb
160
161
  - spec/dummy/db/schema.rb
162
+ - spec/dummy/doc/admin/entries.md
161
163
  - spec/dummy/doc/entries.md
162
164
  - spec/dummy/doc/recipes.md
163
165
  - spec/dummy/doc/toc.md
@@ -168,6 +170,7 @@ files:
168
170
  - spec/dummy/public/500.html
169
171
  - spec/dummy/public/favicon.ico
170
172
  - spec/dummy/script/rails
173
+ - spec/requests/admin/entries_spec.rb
171
174
  - spec/requests/entries_spec.rb
172
175
  - spec/requests/recipes_spec.rb
173
176
  - spec/spec_helper.rb
@@ -196,6 +199,7 @@ signing_key:
196
199
  specification_version: 4
197
200
  summary: Auto-generate JSON API documents from your request-specs.
198
201
  test_files:
202
+ - spec/autodoc/documents_spec.rb
199
203
  - spec/dummy/Rakefile
200
204
  - spec/dummy/app/assets/javascripts/application.js
201
205
  - spec/dummy/app/assets/stylesheets/application.css
@@ -224,6 +228,7 @@ test_files:
224
228
  - spec/dummy/config/routes.rb
225
229
  - spec/dummy/db/migrate/20130607075126_create_recipes.rb
226
230
  - spec/dummy/db/schema.rb
231
+ - spec/dummy/doc/admin/entries.md
227
232
  - spec/dummy/doc/entries.md
228
233
  - spec/dummy/doc/recipes.md
229
234
  - spec/dummy/doc/toc.md
@@ -234,6 +239,8 @@ test_files:
234
239
  - spec/dummy/public/500.html
235
240
  - spec/dummy/public/favicon.ico
236
241
  - spec/dummy/script/rails
242
+ - spec/requests/admin/entries_spec.rb
237
243
  - spec/requests/entries_spec.rb
238
244
  - spec/requests/recipes_spec.rb
239
245
  - spec/spec_helper.rb
246
+ has_rdoc: