fictium 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: 421d8ab0b9aa1bb7982edf6cf39a156179f2ec1f02c72b7b79bb96e8cfc33f05
4
- data.tar.gz: 936e8e3849fe1ef47f5c4af212cb7b3985def25284c1f755188f0b42a545b4e7
3
+ metadata.gz: 3030636739bbc598cfa705f9708eb907a8c5bbe8d8937758ff89ef1550437d5a
4
+ data.tar.gz: 9a835767818e69d27fec2eb97ba86a222186226c59a32416d06deea61db36714
5
5
  SHA512:
6
- metadata.gz: 0cc22b7038a90471b18054314feaa182d558fcf29c6f79926ec9c1ccdce4267b69e1fda8b416b1605abbf3b0395c7210c1a17e11c29939fb86ef68e7a491f371
7
- data.tar.gz: 29044b70d6d0ad7ad05f08eaa565979d43f0827dc554ab81c3c87926bede9b3ecd4b06c171e0071970c76017a5d0b7bfc0b43ca31a10b9b231b3d289614df54a
6
+ metadata.gz: 83902c23aae9e3851f5051127c563f47852c09b0a344ec7b7fd839c24ffa11bcc1a860d0fab60e5e9a21a47aa8a8a2d1c1e80ab5da97df66da3f8eeb47166d55
7
+ data.tar.gz: 893041779f809d490a110b2f6106c839f59633a01413673b2e4ebfa8ec112f15a726f58e665110cf2c7938825bf45960db09c82d6e3ff30f58337746d4346351
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  ---
2
+ env:
3
+ global:
4
+ - CC_TEST_REPORTER_ID=ABC532a889d0bb9f79e63dd72a6c99b669b5349b81a7defb42cdde4f0dc5684e874
2
5
  sudo: false
3
6
  language: ruby
4
7
  cache: bundler
@@ -10,4 +13,10 @@ rvm:
10
13
  before_install:
11
14
  - gem install bundler -v 2.0.2
12
15
  - bundle install
16
+ before_script:
17
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
18
+ - chmod +x ./cc-test-reporter
19
+ - ./cc-test-reporter before-build
13
20
  script: bundle exec rake travis:analyze
21
+ after_script:
22
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md CHANGED
@@ -17,6 +17,15 @@
17
17
 
18
18
  ## LOG
19
19
 
20
+ ### 0.3.0 (2019-11-12)
21
+
22
+ New exporter: Postman.
23
+
24
+ #### Changes
25
+
26
+ - Allow to export the documentation as a Postman collection. (Even with examples)
27
+ - Added code climate's integration for test coverage.
28
+
20
29
  ### 0.2.0 (2019-11-12)
21
30
 
22
31
  New exporter: API Blueprint.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fictium (0.2.0)
4
+ fictium (0.3.0)
5
5
  activesupport (>= 5.3, < 6.2)
6
6
  json-schema (~> 2.8)
7
7
  verbs (~> 2.1.4)
data/README.md CHANGED
@@ -13,6 +13,7 @@ The current Gem version allows to export into the following formats:
13
13
  |--- |--- |--- |
14
14
  | [OpenApi 3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md) | `Fictium::OpenApi::V3Exporter` | The default exporter for the current Gem version. It doesn't include 100% of the OpenAPI specification, but it works for the most common use cases. It's the format [Swagger](https://swagger.io/) uses for documentation. |
15
15
  | [API Blueprint](https://apiblueprint.org/documentation/specification.html) | `Fictium::ApiBlueprintExporter`| Used by [Apiary](https://apiary.io/). A superset of Markdown with special keywords and controls. |
16
+ | [Postman Collection](https://schema.getpostman.com/json/collection/v2.1.0/docs/index.html) | `Fictium::Postman::V2Exporter` | Export your test as a [Postman](https://www.getpostman.com/) collection for easy creation of mock APIs and quick debugging. |
16
17
 
17
18
  Future versions may provide:
18
19
 
@@ -12,7 +12,7 @@ module Fictium
12
12
  ].freeze
13
13
  private_constant :VOWEL
14
14
 
15
- attr_reader :info, :api_blueprint
15
+ attr_reader :info, :api_blueprint, :postman
16
16
  attr_accessor :exporters, :summary_format, :default_action_descriptors,
17
17
  :unknown_action_descriptor, :default_subject, :fixture_path,
18
18
  :export_path, :default_response_content_type, :pretty_print,
@@ -21,6 +21,7 @@ module Fictium
21
21
  def initialize
22
22
  @info = Fictium::Configuration::Info.new
23
23
  @api_blueprint = Fictium::Configuration::ApiBlueprint.new
24
+ @postman = Fictium::Configuration::Postman.new
24
25
  @exporters = [Fictium::OpenApi::V3Exporter.new]
25
26
 
26
27
  @summary_format = method(:default_summary_format)
@@ -0,0 +1,29 @@
1
+ module Fictium
2
+ class Configuration
3
+ class Postman
4
+ attr_accessor :id, :api_url, :default_status_names, :unknown_status_name, :example_formatter
5
+
6
+ def initialize
7
+ @api_url = '{{API_URL}}'
8
+ @example_formatter = method(:format_example)
9
+ @default_status_names = {}
10
+ @unknown_status_name = method(:format_unknown_status_name)
11
+ end
12
+
13
+ private
14
+
15
+ def format_example(status, example)
16
+ "[#{status}] #{status_name_for(status, example)}"
17
+ end
18
+
19
+ def status_name_for(status, example)
20
+ method = default_status_names[status] || unknown_status_name
21
+ method.call(status, example)
22
+ end
23
+
24
+ def format_unknown_status_name(_status, example)
25
+ example.summary
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,59 @@
1
+ module Fictium
2
+ class PostmanEvaluator
3
+ attr_reader :subject
4
+
5
+ delegate :postman, to: :subject
6
+
7
+ def initialize(subject)
8
+ @subject = subject
9
+ end
10
+
11
+ def evaluate(&block)
12
+ instance_eval(&block)
13
+ end
14
+
15
+ private
16
+
17
+ def pre_request(script:, disabled: false)
18
+ postman.event ||= []
19
+ postman.event << {
20
+ listen: :pre_request,
21
+ disabled: disabled,
22
+ script: {
23
+ exec: script.to_s.lines
24
+ }
25
+ }
26
+ end
27
+
28
+ def test(script:, disabled: false)
29
+ postman.event ||= []
30
+ postman.event << {
31
+ listen: :test,
32
+ disabled: disabled,
33
+ script: {
34
+ exec: script.to_s.lines
35
+ }
36
+ }
37
+ end
38
+
39
+ def variable(name:, value: '', type: :string, disabled: false)
40
+ postman.variable ||= []
41
+ postman.variable << { name: name, value: value, type: type, disabled: disabled }
42
+ end
43
+
44
+ def auth(**kwargs)
45
+ raise NoMethodError unless resource? || document?
46
+
47
+ key = kwargs.keys.first
48
+ postman.auth = { type: key, key => kwargs[key] }
49
+ end
50
+
51
+ def resource?
52
+ subject.is_a?(Fictium::Resource)
53
+ end
54
+
55
+ def document?
56
+ subject.is_a?(Fictium::Document)
57
+ end
58
+ end
59
+ end