Skip to content

Commit

Permalink
Merge pull request #74 from k0kubun/rubocop-test
Browse files Browse the repository at this point in the history
Setup RuboCop
  • Loading branch information
exoego committed Oct 21, 2022
2 parents 55d022d + 464db2d commit fb50316
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Rubocop"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
rubocop:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Install dependencies
run: bundle install

- name: Rubocop run
run: |
bash -c "
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
[[ $? -ne 2 ]]
"
- name: Upload Sarif output
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: rubocop.sarif
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ end

group :development do
gem 'pry'
gem "code-scanning-rubocop"
end
2 changes: 1 addition & 1 deletion lib/rspec/openapi/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

RSpec.configuration.after(:each) do |example|
if RSpec::OpenAPI.example_types.include?(example.metadata[:type]) && example.metadata[:openapi] != false
path = RSpec::OpenAPI.path.yield_self { |path| path.is_a?(Proc) ? path.call(example) : path }
path = RSpec::OpenAPI.path.yield_self { |p| p.is_a?(Proc) ? p.call(example) : p }
record = RSpec::OpenAPI::RecordBuilder.build(self, example: example)
path_records[path] << record if record
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/openapi/record.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec::OpenAPI::Record = Struct.new(
:method, # @param [String] - "GET"
:http_method, # @param [String] - "GET"
:path, # @param [String] - "/v1/status/:id"
:path_params, # @param [Hash] - {:controller=>"v1/statuses", :action=>"create", :id=>"1"}
:query_params, # @param [Hash] - {:query=>"string"}
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/openapi/record_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def build(context, example:)
end

RSpec::OpenAPI::Record.new(
method: request.request_method,
http_method: request.method,
path: path,
path_params: raw_path_params(request),
query_params: request.query_parameters,
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/openapi/schema_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def build(record)
{
paths: {
normalize_path(record.path) => {
record.method.downcase => {
record.http_method.downcase => {
summary: record.summary,
tags: record.tags,
parameters: build_parameters(record),
Expand Down

0 comments on commit fb50316

Please sign in to comment.