autodoc 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +5 -1
- data/lib/autodoc/document.rb +13 -4
- data/lib/autodoc/documents.rb +2 -2
- data/lib/autodoc/rspec.rb +2 -2
- data/lib/autodoc/version.rb +1 -1
- data/spec/autodoc/documents_spec.rb +20 -7
- data/spec/dummy/db/schema.rb +5 -5
- data/spec/requests/admin/entries_spec.rb +3 -3
- data/spec/requests/entries_spec.rb +3 -3
- data/spec/requests/recipes_spec.rb +8 -8
- data/spec/spec_helper.rb +0 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f054c99b4001c7140761188519330f9171da9739
|
4
|
+
data.tar.gz: 8cb4384257257f9fc78c8ea102b85f49a6103143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 104578c24c698cd2dcf4f43a04ea0228a74d922294febbf59b29aef717c65f942f892a3e90a9e972bb39b2dc9450dc286611e18fb358a0afc2624fced8fab3ba
|
7
|
+
data.tar.gz: 293abadf0e4ddf420ba2bd2447df878f8bccae1fd8817021f0c81961ac4eebe54fe5c2bc789e419bf834ec93cac9fb86c589f35021c8add616815b8177e9647d
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/lib/autodoc/document.rb
CHANGED
@@ -11,13 +11,14 @@ module Autodoc
|
|
11
11
|
new(*args).render
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize(context)
|
14
|
+
def initialize(context, example)
|
15
15
|
@context = context
|
16
|
+
@example = example
|
16
17
|
end
|
17
18
|
|
18
19
|
def pathname
|
19
20
|
@path ||= begin
|
20
|
-
payload =
|
21
|
+
payload = example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
|
21
22
|
Autodoc.configuration.pathname + payload
|
22
23
|
end
|
23
24
|
end
|
@@ -36,6 +37,14 @@ module Autodoc
|
|
36
37
|
|
37
38
|
private
|
38
39
|
|
40
|
+
def example
|
41
|
+
if ::RSpec::Core::Version::STRING.split('.').first == "3"
|
42
|
+
@example
|
43
|
+
else
|
44
|
+
@context.example
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
39
48
|
def request
|
40
49
|
@request ||= begin
|
41
50
|
if using_rack_test?
|
@@ -176,12 +185,12 @@ module Autodoc
|
|
176
185
|
if @context.respond_to?(:description)
|
177
186
|
@context.description.strip_heredoc
|
178
187
|
else
|
179
|
-
"#{
|
188
|
+
"#{example.description.capitalize}."
|
180
189
|
end
|
181
190
|
end
|
182
191
|
|
183
192
|
def path
|
184
|
-
|
193
|
+
example.full_description[%r<(GET|POST|PATCH|PUT|DELETE) ([^ ]+)>, 2]
|
185
194
|
end
|
186
195
|
|
187
196
|
def parameters_section
|
data/lib/autodoc/documents.rb
CHANGED
@@ -6,8 +6,8 @@ module Autodoc
|
|
6
6
|
@table = Hash.new {|table, key| table[key] = [] }
|
7
7
|
end
|
8
8
|
|
9
|
-
def append(context)
|
10
|
-
document = Autodoc::Document.new(context.clone)
|
9
|
+
def append(context, example)
|
10
|
+
document = Autodoc::Document.new(context.clone, example.clone)
|
11
11
|
@table[document.pathname] << document
|
12
12
|
end
|
13
13
|
|
data/lib/autodoc/rspec.rb
CHANGED
data/lib/autodoc/version.rb
CHANGED
@@ -3,7 +3,11 @@ require "spec_helper"
|
|
3
3
|
describe Autodoc::Documents do
|
4
4
|
describe "#render_toc" do
|
5
5
|
before do
|
6
|
-
|
6
|
+
if ::RSpec::Core::Version::STRING.split('.').first == "3"
|
7
|
+
documents.append(context, example)
|
8
|
+
else
|
9
|
+
documents.append(context, double)
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
let(:documents) do
|
@@ -11,8 +15,17 @@ describe Autodoc::Documents do
|
|
11
15
|
end
|
12
16
|
|
13
17
|
let(:context) do
|
14
|
-
|
15
|
-
|
18
|
+
if ::RSpec::Core::Version::STRING.split('.').first == "3"
|
19
|
+
mock = double(example: example, request: request, file_path: file_path, full_description: full_description)
|
20
|
+
else
|
21
|
+
mock = double(example: example, request: request)
|
22
|
+
end
|
23
|
+
|
24
|
+
if ::RSpec::Core::Version::STRING.split('.').first == "3"
|
25
|
+
allow(mock).to receive_messages(clone: mock)
|
26
|
+
else
|
27
|
+
mock.stub(clone: mock)
|
28
|
+
end
|
16
29
|
mock
|
17
30
|
end
|
18
31
|
|
@@ -43,8 +56,8 @@ describe Autodoc::Documents do
|
|
43
56
|
|
44
57
|
it "includes links to recipes.md" do
|
45
58
|
toc = documents.send(:render_toc)
|
46
|
-
toc.
|
47
|
-
toc.
|
59
|
+
expect(toc).to include("[recipes.md](recipes.md)")
|
60
|
+
expect(toc).to include("[GET /recipes](recipes.md#get-recipes)")
|
48
61
|
end
|
49
62
|
end
|
50
63
|
|
@@ -59,8 +72,8 @@ describe Autodoc::Documents do
|
|
59
72
|
|
60
73
|
it "includes links to admin/recipes.md" do
|
61
74
|
toc = documents.send(:render_toc)
|
62
|
-
toc.
|
63
|
-
toc.
|
75
|
+
expect(toc).to include("[admin/recipes.md](admin/recipes.md)")
|
76
|
+
expect(toc).to include("[GET /admin/recipes](admin/recipes.md#get-adminrecipes)")
|
64
77
|
end
|
65
78
|
end
|
66
79
|
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -9,15 +9,15 @@
|
|
9
9
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
10
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
11
|
#
|
12
|
-
# It's strongly recommended
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:
|
14
|
+
ActiveRecord::Schema.define(version: 20130607075126) do
|
15
15
|
|
16
|
-
create_table "recipes", :
|
16
|
+
create_table "recipes", force: true do |t|
|
17
17
|
t.string "name"
|
18
18
|
t.integer "type"
|
19
|
-
t.datetime "created_at"
|
20
|
-
t.datetime "updated_at"
|
19
|
+
t.datetime "created_at"
|
20
|
+
t.datetime "updated_at"
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "Admin::Entries" do
|
3
|
+
describe "Admin::Entries", type: :request do
|
4
4
|
include Rack::Test::Methods
|
5
5
|
|
6
6
|
let(:env) do
|
@@ -29,10 +29,10 @@ describe "Admin::Entries" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "GET /admin/entries" do
|
32
|
-
context "with Rack::Test", :
|
32
|
+
context "with Rack::Test", autodoc: true do
|
33
33
|
it "returns entries" do
|
34
34
|
get "/admin/entries", params, env
|
35
|
-
last_response.status.
|
35
|
+
expect(last_response.status).to eq(200)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "Entries" do
|
3
|
+
describe "Entries", type: :request do
|
4
4
|
include Rack::Test::Methods
|
5
5
|
|
6
6
|
let(:env) do
|
@@ -29,10 +29,10 @@ describe "Entries" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "GET /entries" do
|
32
|
-
context "with Rack::Test", :
|
32
|
+
context "with Rack::Test", autodoc: true do
|
33
33
|
it "returns entries" do
|
34
34
|
get "/entries", params, env
|
35
|
-
last_response.status.
|
35
|
+
expect(last_response.status).to eq(200)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "Recipes" do
|
3
|
+
describe "Recipes", type: :request do
|
4
4
|
let(:env) do
|
5
5
|
{ "ACCEPT" => "application/json", "CONTENT_TYPE" => "application/json" }
|
6
6
|
end
|
@@ -14,7 +14,7 @@ describe "Recipes" do
|
|
14
14
|
Recipe.create(name: "test", type: 2)
|
15
15
|
end
|
16
16
|
|
17
|
-
context "with valid condition (using Rack::Test)", :
|
17
|
+
context "with valid condition (using Rack::Test)", autodoc: true do
|
18
18
|
before do
|
19
19
|
env["Content-Type"] = "application/json"
|
20
20
|
end
|
@@ -23,7 +23,7 @@ describe "Recipes" do
|
|
23
23
|
|
24
24
|
it "returns the recipe" do
|
25
25
|
get "/recipes/#{recipe.id}", params, env
|
26
|
-
last_response.status.
|
26
|
+
expect(last_response.status).to eq(200)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -41,7 +41,7 @@ describe "Recipes" do
|
|
41
41
|
|
42
42
|
it "returns 400" do
|
43
43
|
post "/recipes", params.to_json, env
|
44
|
-
response.status.
|
44
|
+
expect(response.status).to eq(400)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -52,7 +52,7 @@ describe "Recipes" do
|
|
52
52
|
|
53
53
|
it "returns 400" do
|
54
54
|
post "/recipes", params.to_json, env
|
55
|
-
response.status.
|
55
|
+
expect(response.status).to eq(400)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -63,11 +63,11 @@ describe "Recipes" do
|
|
63
63
|
|
64
64
|
it "creates a new recipe" do
|
65
65
|
post "/recipes", params.to_json, env
|
66
|
-
response.status.
|
66
|
+
expect(response.status).to eq(201)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
context "with valid condition", :
|
70
|
+
context "with valid condition", autodoc: true do
|
71
71
|
let(:description) do
|
72
72
|
<<-EOS
|
73
73
|
Creates
|
@@ -79,7 +79,7 @@ describe "Recipes" do
|
|
79
79
|
|
80
80
|
it "creates a new recipe" do
|
81
81
|
post "/recipes", params.to_json, env
|
82
|
-
response.status.
|
82
|
+
expect(response.status).to eq(201)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
ENV["RAILS_ENV"] ||= "test"
|
2
2
|
require File.expand_path("../../spec/dummy/config/environment", __FILE__)
|
3
3
|
require "rspec/rails"
|
4
|
-
require "rspec/autorun"
|
5
4
|
|
6
5
|
Autodoc.configuration.toc = true
|
7
6
|
Autodoc.configuration.path = "spec/dummy/doc"
|
@@ -16,6 +15,4 @@ RSpec.configure do |config|
|
|
16
15
|
# automatically. This will be the default behavior in future versions of
|
17
16
|
# rspec-rails.
|
18
17
|
config.infer_base_class_for_anonymous_controllers = false
|
19
|
-
|
20
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
21
18
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|