Skip to content

Commit

Permalink
Add support for coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 26, 2023
1 parent b03a6b7 commit 2321939
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 18 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Coverage

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm
COVERAGE: PartialSummary

jobs:
test:
name: ${{matrix.ruby}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest

strategy:
matrix:
os:
- ubuntu
- macos

ruby:
- "3.2"

steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
bundler-cache: true

- name: Run tests
timeout-minutes: 5
run: bundle exec bake test

- uses: actions/upload-artifact@v2
with:
name: coverage-${{matrix.os}}-${{matrix.ruby}}
path: .covered.db

validate:
needs: test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true

- uses: actions/download-artifact@v3

- name: Validate coverage
timeout-minutes: 5
run: bundle exec bake covered:validate --paths */.covered.db \;
1 change: 1 addition & 0 deletions multipart-post.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "bundler"
spec.add_development_dependency "rspec", "~> 3.4"
spec.add_development_dependency "covered"
end
5 changes: 5 additions & 0 deletions spec/multipart/post/parts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ def content_type; 'application/data'; end
part = Parts::FilePart.new("boundary", "afile", UploadIO.new(TEMP_FILE, "text/plain"), { "Content-Type" => "application/pdf" })
expect(part.to_io.read).to match(/Content-Type: application\/pdf/)
end

it "test_content_id" do
part = Parts::FilePart.new("boundary", "afile", UploadIO.new(TEMP_FILE, "text/plain"), { "Content-ID" => "id" })
expect(part.to_io.read).to match(/Content-ID: id/)
end
end

RSpec.describe Parts::ParamPart do
Expand Down
19 changes: 1 addition & 18 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,8 @@
# Copyright, 2017-2022, by Samuel Williams.
# Copyright, 2019, by Patrick Davey.

if ENV['COVERAGE']
begin
require 'simplecov'

SimpleCov.start do
add_filter "/spec/"
end

if ENV['TRAVIS']
require 'coveralls'
Coveralls.wear!
end
rescue LoadError
warn "Could not load simplecov: #{$!}"
end
end

require "bundler/setup"
require "multipart/post"
require "covered/rspec"

MULTIBYTE = File.join(__dir__, 'fixtures/multibyte.txt')
TEMP_FILE = "temp.txt"
Expand Down

0 comments on commit 2321939

Please sign in to comment.