fictium 0.2.0 → 0.3.0
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 +4 -4
 - data/.travis.yml +9 -0
 - data/CHANGELOG.md +9 -0
 - data/Gemfile.lock +1 -1
 - data/README.md +1 -0
 - data/lib/fictium/configurations/configuration.rb +2 -1
 - data/lib/fictium/configurations/postman.rb +29 -0
 - data/lib/fictium/evaluators/postman_evaluator.rb +59 -0
 - data/lib/fictium/exporters/postman/schemas/2.1.0.json +1174 -0
 - data/lib/fictium/exporters/postman/v2_exporter/action_formatter.rb +40 -0
 - data/lib/fictium/exporters/postman/v2_exporter/body_formatter.rb +15 -0
 - data/lib/fictium/exporters/postman/v2_exporter/folder_formatter.rb +27 -0
 - data/lib/fictium/exporters/postman/v2_exporter/header_formatter.rb +15 -0
 - data/lib/fictium/exporters/postman/v2_exporter/info_formatter.rb +26 -0
 - data/lib/fictium/exporters/postman/v2_exporter/item_formatter.rb +29 -0
 - data/lib/fictium/exporters/postman/v2_exporter/metadata_formatter.rb +17 -0
 - data/lib/fictium/exporters/postman/v2_exporter/request_formatter.rb +89 -0
 - data/lib/fictium/exporters/postman/v2_exporter/response_formatter.rb +50 -0
 - data/lib/fictium/exporters/postman/v2_exporter.rb +61 -0
 - data/lib/fictium/loader.rb +5 -0
 - data/lib/fictium/poros/model.rb +3 -0
 - data/lib/fictium/poros/postman_metadata.rb +5 -0
 - data/lib/fictium/rspec/autocomplete/example.rb +12 -6
 - data/lib/fictium/rspec/resources.rb +5 -0
 - data/lib/fictium/version.rb +1 -1
 - metadata +15 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3030636739bbc598cfa705f9708eb907a8c5bbe8d8937758ff89ef1550437d5a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9a835767818e69d27fec2eb97ba86a222186226c59a32416d06deea61db36714
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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
    
    
    
        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
         
     |