Gemfile
gem 'committee'
gem 'committee-rails'
| # 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 |