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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1a3b176d6aa9f963f08ec8c08c31b339c155c5c
4
- data.tar.gz: 6f06ff04224ea790295f69bf40032856cd9f5b53
3
+ metadata.gz: f054c99b4001c7140761188519330f9171da9739
4
+ data.tar.gz: 8cb4384257257f9fc78c8ea102b85f49a6103143
5
5
  SHA512:
6
- metadata.gz: 14f4de722da14a0c747ceb26e8ddbbfc3e22c521182f078440b6cd81d3056f96f5b168f18413fa882350fc36a935524bc1efa7305316cfaaddd10385ee497136
7
- data.tar.gz: a2d4754f50257b51009047582fcbe101f71a799db5ba7c69c00fe102f03aaa8f145a98565404b495bc753da897a4af5701b8fdaa38c77fb2854b5cabd5b1db3b
6
+ metadata.gz: 104578c24c698cd2dcf4f43a04ea0228a74d922294febbf59b29aef717c65f942f892a3e90a9e972bb39b2dc9450dc286611e18fb358a0afc2624fced8fab3ba
7
+ data.tar.gz: 293abadf0e4ddf420ba2bd2447df878f8bccae1fd8817021f0c81961ac4eebe54fe5c2bc789e419bf834ec93cac9fb86c589f35021c8add616815b8177e9647d
@@ -1,3 +1,6 @@
1
+ ## 0.4.0
2
+ * Support RSpec 3
3
+
1
4
  ## 0.3.6
2
5
  * Show dummy message if Content-Type might be BINARY
3
6
 
data/Gemfile CHANGED
@@ -4,7 +4,11 @@ gemspec
4
4
 
5
5
  group :test do
6
6
  gem "pry-rails"
7
- gem "rspec-rails"
7
+ if ENV['RSPEC2']
8
+ gem "rspec-rails", "~> 2.14.1"
9
+ else
10
+ gem "rspec-rails"
11
+ end
8
12
  gem "weak_parameters"
9
13
  gem "protected_attributes"
10
14
  gem "rack-test"
@@ -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 = @context.example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
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
- "#{@context.example.description.capitalize}."
188
+ "#{example.description.capitalize}."
180
189
  end
181
190
  end
182
191
 
183
192
  def path
184
- @context.example.full_description[%r<(GET|POST|PATCH|PUT|DELETE) ([^ ]+)>, 2]
193
+ example.full_description[%r<(GET|POST|PATCH|PUT|DELETE) ([^ ]+)>, 2]
185
194
  end
186
195
 
187
196
  def parameters_section
@@ -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
 
@@ -1,7 +1,7 @@
1
1
  require "rspec"
2
2
 
3
- RSpec.configuration.after(:each, autodoc: true) do
4
- Autodoc.documents.append(self)
3
+ RSpec.configuration.after(:each, autodoc: true) do |example|
4
+ Autodoc.documents.append(self, example)
5
5
  end
6
6
 
7
7
  RSpec.configuration.after(:suite) do
@@ -1,3 +1,3 @@
1
1
  module Autodoc
2
- VERSION = "0.3.6"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -3,7 +3,11 @@ require "spec_helper"
3
3
  describe Autodoc::Documents do
4
4
  describe "#render_toc" do
5
5
  before do
6
- documents.append(context)
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
- mock = double(example: example, request: request)
15
- mock.stub(clone: mock)
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.should include("[recipes.md](recipes.md)")
47
- toc.should include("[GET /recipes](recipes.md#get-recipes)")
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.should include("[admin/recipes.md](admin/recipes.md)")
63
- toc.should include("[GET /admin/recipes](admin/recipes.md#get-adminrecipes)")
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
@@ -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 to check this file into your version control system.
12
+ # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20130607075126) do
14
+ ActiveRecord::Schema.define(version: 20130607075126) do
15
15
 
16
- create_table "recipes", :force => true do |t|
16
+ create_table "recipes", force: true do |t|
17
17
  t.string "name"
18
18
  t.integer "type"
19
- t.datetime "created_at", :null => false
20
- t.datetime "updated_at", :null => false
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", :autodoc do
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.should == 200
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", :autodoc do
32
+ context "with Rack::Test", autodoc: true do
33
33
  it "returns entries" do
34
34
  get "/entries", params, env
35
- last_response.status.should == 200
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)", :autodoc do
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.should == 200
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.should == 400
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.should == 400
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.should == 201
66
+ expect(response.status).to eq(201)
67
67
  end
68
68
  end
69
69
 
70
- context "with valid condition", :autodoc do
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.should == 201
82
+ expect(response.status).to eq(201)
83
83
  end
84
84
  end
85
85
  end
@@ -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.3.6
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-05-19 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport