Skip to content

Commit

Permalink
ci: coverage config (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego authored Jun 28, 2023
1 parent fd34940 commit 0c92c20
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .simplecov_spawn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
require 'simplecov'
require 'simplecov-cobertura'

SimpleCov.command_name 'spawn'
SimpleCov.at_fork.call(Process.pid)
SimpleCov.formatter SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::CoberturaFormatter,
])
SimpleCov.start do
add_filter '/spec/'
add_filter '/scripts/'
end
end
6 changes: 2 additions & 4 deletions scripts/rspec_with_simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ begin
require 'simplecov'

SimpleCov.start do
add_filter './bundle/'
add_filter './tmp/'
add_filter './spec/'
minimum_coverage(RUBY_PLATFORM == 'java' ? 94 : 97)
# Flaky :(
# enable_coverage :branch
end
end
rescue LoadError
Expand Down
4 changes: 4 additions & 0 deletions spec/rails/app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def show
render json: find_user(params[:id])
end

def active
render json: find_user(params[:id]).present?
end

private

def find_user(id = nil)
Expand Down
4 changes: 3 additions & 1 deletion spec/rails/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
post 'upload_multiple'
end
end
resources :users, only: [:show, :create]
resources :users, only: [:show, :create] do
get 'active'
end

get '/test_block' => ->(_env) { [200, { 'Content-Type' => 'text/plain' }, ['A TEST']] }
end
Expand Down
20 changes: 20 additions & 0 deletions spec/rails/doc/smart/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,26 @@ paths:
schema:
type: integer
example: 2
"/users/{user_id}/active":
get:
responses:
"200":
description: "returns a boolean"
content:
"application/json":
schema:
type: boolean
example: true
summary: active
tags:
- User
parameters:
- name: user_id
in: path
required: true
schema:
type: integer
example: 1
components:
securitySchemes:
Scheme1:
Expand Down
7 changes: 7 additions & 0 deletions spec/requests/rails_smart_merge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,11 @@
expect(response.status).to eq(200)
end
end

describe '#active' do
it 'returns a boolean' do
get '/users/1/active'
expect(response.status).to eq(200)
end
end
end
5 changes: 5 additions & 0 deletions spec/requests/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
get '/tables/2', headers: { authorization: 'k0kubun' }
expect(response.status).to eq(404)
end

it 'does not return a table if not found (openapi: false)', openapi: false do
get '/tables/3', headers: { authorization: 'k0kubun' }
expect(response.status).to eq(404)
end
end

describe '#create' do
Expand Down

0 comments on commit 0c92c20

Please sign in to comment.