Skip to content

Instantly share code, notes, and snippets.

@taketo1113
Last active January 1, 2018 14:11
Show Gist options
  • Save taketo1113/49d82ab0b574503651f58cd6e488fb29 to your computer and use it in GitHub Desktop.
Save taketo1113/49d82ab0b574503651f58cd6e488fb29 to your computer and use it in GitHub Desktop.
Usage Committee
# spec/requests/sample_spec.rb
require 'rails_helper'
RSpec.describe "Tickets", type: :request do
context "API" do
include Committee::Rails::Test::Methods
def committee_schema
@committee_schema ||=
begin
driver = Committee::Drivers::OpenAPI2.new
driver.parse(schema_hash)
end
end
def schema_hash
schema_file = File.read(schema_path)
if schema_path.extname == '.yaml'
schema_hash = YAML::load(schema_file)
else
schema_hash = JSON.parse(schema_file)
end
end
# yaml or json file path
def schema_path
schema_path = Rails.root.join('docs/swagger.yaml')
#schema_path = Rails.root.join('docs/swagger.json')
end
describe "GET /tickets.json" do
it "works!" do
get tickets_path(format: :json)
assert_schema_conform
end
end
end
end

Usage Committee

Gemfile

  gem 'committee'
  gem 'committee-rails'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment