rspec-rails-api 0.2.0 → 0.2.2

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
  SHA256:
3
- metadata.gz: '0861008371cafa6cab0cda5c165acda54b5a3047f152713bb684ae0c7c7be0ff'
4
- data.tar.gz: d3c8877c5ef1e43c902010b68b9e483feefa6e57251d67aba325394a9682aee7
3
+ metadata.gz: df99a2088657641a87ec55c6159cdf7973d75863718f94aebef6cc70d7b4ac95
4
+ data.tar.gz: 4bf341e1fc70d6dfe760a531e43aec6c4c8002b3c1000fe83d1b2ae3cac3f3a0
5
5
  SHA512:
6
- metadata.gz: e1009f40d78187888e546c74e62e88d7557f45a4a3cfed78a27785d63b401f673ed1796928f1d32823a665694b86761653bb87edc68522418d6117c4b576e362
7
- data.tar.gz: 10ffebb4902456c4671b39b7dd707ea8ca870b9a27054c3139cae94bb3dcebfc3f88abd41a298ed870f98d7953c1195171cbf8f077db2dcd6530fe761e354a5a
6
+ metadata.gz: 42b42ba732de1383324dde829463f6a042289f184a959a9dc1c8ff727d8fd56699f7e97f40d215f184f724249517be826f5de4a66a5e684593a166ee25843624
7
+ data.tar.gz: 2daa6738912fcf4192e7c155a6744400420cabb5b1422de6dca77d34ece4dee59528d228b85af52fed0e5eaa17aebb4d14b06ca46e913a81c46318c8b11b67da
data/.gitlab-ci.yml CHANGED
@@ -35,9 +35,10 @@ rspec:
35
35
  dependencies:
36
36
  - bundle
37
37
 
38
- rspec-dummy:
38
+ dummy:
39
39
  stage: test
40
40
  script:
41
41
  - cd dummy
42
42
  - bundle install --path='vendor/bundle'
43
+ - bundle exec rubocop
43
44
  - bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ## Not released
5
5
 
6
+ ## 0.2.1/0.2.2 - 2019-11-03
7
+
8
+ _Version 0.2.1 was released and yanked by mistake. Version 0.2.2 is the exact
9
+ same one, with a version bump_
10
+
11
+ ### Changed
12
+
13
+ - `for_code` method now have its `description` optional. If none is provided,
14
+ the description will be set from the status code.
15
+
6
16
  ## 0.2.0 - 2019-11-02
7
17
 
8
18
  ### Added
@@ -40,7 +50,7 @@ of the fixtures.
40
50
  ### Added
41
51
 
42
52
  - Added ability to document API descriptions, servers, etc... from the RSpec helper files
43
-
53
+
44
54
  ## 0.1.2 - 2019-10-22
45
55
 
46
56
  ### Added
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RSpec-rails-api
2
2
 
3
- > An RSpec plugin to test Rails api responses and generate swagger
3
+ > An RSpec plugin to test Rails API responses and generate swagger
4
4
  > documentation
5
5
 
6
6
  **This is a work in progress** but you're welcome to help, test, submit
@@ -8,9 +8,6 @@ issues, ...
8
8
 
9
9
  ## Installation
10
10
 
11
- As the gem is not yet published, you have to specify its git repository
12
- in order to test it.
13
-
14
11
  Add this line to your application's Gemfile:
15
12
 
16
13
  ```ruby
@@ -381,7 +378,7 @@ on_post '/api/items' do
381
378
  end
382
379
  ```
383
380
 
384
- ##### `for_code(http_status, description, doc_only: false &block)`
381
+ ##### `for_code(http_status, description = nil, doc_only: false &block)`
385
382
 
386
383
  Describes the desired output for a precedently defined URL.
387
384
 
@@ -392,7 +389,8 @@ the metadatas.
392
389
  - `http_status` is an integer representing an
393
390
  [HTTP status](https://httpstat.us/)
394
391
  - `description` should be some valid
395
- [CommonMark](https://commonmark.org/)
392
+ [CommonMark](https://commonmark.org/). If not defined, a human readable
393
+ translation of the `http_status` will be used.
396
394
  - `doc_only` can be set to true to temporarily disable block execution
397
395
  and only create the documentation (without examples).
398
396
  - `block` where additional tests can be performed. If `visit()` is
@@ -74,17 +74,13 @@ module RSpec
74
74
  describe("#{action.upcase} #{url}", &block)
75
75
  end
76
76
 
77
- def for_code(status_code, description, doc_only: false, &block)
77
+ def for_code(status_code, description = nil, doc_only: false, &block)
78
+ description ||= Rack::Utils::HTTP_STATUS_CODES[status_code]
79
+
78
80
  metadata[:rrad].add_status_code(status_code, description)
79
81
 
80
82
  describe "-> #{status_code} - #{description}" do
81
- if (!ENV['DOC_ONLY'] || ENV['DOC_ONLY'] == 'false' || !doc_only) && block
82
- example 'Test and create documentation', caller: block.send(:caller) do
83
- instance_eval(&block) if block_given?
84
- end
85
- else
86
- document_only status_code
87
- end
83
+ execute_for_code_block(status_code, doc_only, block)
88
84
  end
89
85
  end
90
86
 
@@ -98,6 +94,16 @@ module RSpec
98
94
  set_request_example parent_example.metadata[:rrad], request_params, status_code
99
95
  end
100
96
  end
97
+
98
+ def execute_for_code_block(status_code, doc_only, callback_block)
99
+ if (!ENV['DOC_ONLY'] || ENV['DOC_ONLY'] == 'false' || !doc_only) && callback_block
100
+ example 'Test and create documentation', caller: callback_block.send(:caller) do
101
+ instance_eval(&callback_block) if callback_block
102
+ end
103
+ else
104
+ document_only status_code
105
+ end
106
+ end
101
107
  end
102
108
  end
103
109
  end
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Rails
5
5
  module Api
6
- VERSION = '0.2.0'
6
+ VERSION = '0.2.2'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Tancoigne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-02 00:00:00.000000000 Z
11
+ date: 2019-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport