Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rspec-matchers-adhere_to_schema

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rspec-matchers-adhere_to_schema

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

RSpec Matcher adhere_to_schema

Gem Version Code Climate GPA Code Climate Coverage Gemnasium Status Travis CI Status

Table of Contents

Features

  • Test if some data adheres to specified json schema
  • Define json schema in a schemas directory and they will be automatically picked

Requirements

  1. MRI 2.2.3
  2. RSpec 3.x

Setup

To install, type the following:

gem install rspec-matchers-adhere_to_schema

Add the following to your Gemfile:

gem "rspec-matchers-adhere_to_schema"

This gem is signed. Use pekhee.pem as public key.

Usage

RSpec.describe "a user document" do
  subject do
    JSON.parse <<-JSON_DOC
      {
        firstName: "Pooyan",
        lastName: "Khosravi"
      }
    JSON_DOC
  end

  let :user_schema do
    JSON.parse <<-JSON_SCHEMA
      {
        "title": "User Schema",
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "age": {
            "description": "Age in years",
            "type": "integer",
            "minimum": 0
          }
        },
        "required": ["firstName", "lastName"]
      }
    JSON_SCHEMA
  end

  it "adheres to user schema" do
    expect(subject).to adhere_to_schema user_schema
    expect(subject).to adhere_to_schema :user # spec/schemas/user.json
  end
end

Tests

To test, run:

bundle exec rake

Versioning

Read Semantic Versioning for details. Briefly, it means:

  • Patch (x.y.Z) - Incremented for small, backwards compatible bug fixes.
  • Minor (x.Y.z) - Incremented for new, backwards compatible public API enhancements and/or bug fixes.
  • Major (X.y.z) - Incremented for any backwards incompatible public API changes.

Code of Conduct

Please note that this project is released with a CODE OF CONDUCT. By participating in this project you agree to abide by its terms.

Contributions

Read CONTRIBUTING for details.

License

Copyright (c) 2016 Pooyan Khosravi. Read the LICENSE for details.

History

Read the CHANGELOG for details. Built with Gemsmith.

Credits

Developed by Pooyan Khosravi.

FAQs

Package last updated on 11 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc