diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..81f3c65 --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -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 \; diff --git a/multipart-post.gemspec b/multipart-post.gemspec index 525294f..e11dbd2 100644 --- a/multipart-post.gemspec +++ b/multipart-post.gemspec @@ -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 diff --git a/spec/multipart/post/parts_spec.rb b/spec/multipart/post/parts_spec.rb index 0f4a189..bbd076f 100644 --- a/spec/multipart/post/parts_spec.rb +++ b/spec/multipart/post/parts_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4196306..78a7e55 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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"