From d81558dca93d5a3e8444eaf8cdfbefe7c4ed004b Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 9 Sep 2017 19:44:08 +0200 Subject: [PATCH] Setup test coverage with CodeClimate. --- .travis.yml | 17 ++++++++++++++++- jsonapi-rails.gemspec | 1 + spec/spec_helper.rb | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fc7bfd7..aa9bb36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,26 @@ language: ruby sudo: false before_install: - bundle update +env: + global: + - CC_TEST_REPORTER_ID=98c9b3070ea9ac0e8f7afb6570f181506c3a06372b1db5c7deb8e46089fdf132 + - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi) rvm: - 2.2.2 - 2.3.3 - ruby-head - matrix: allow_failures: - rvm: ruby-head +before_script: + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build +after_script: + # Preferably you will run test-reporter on branch update events. But + # if you setup travis to build PR updates only, you don't need to run + # the line below + - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi + # In the case where travis is setup to build PR updates only, + # uncomment the line below + # - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/jsonapi-rails.gemspec b/jsonapi-rails.gemspec index 2a6e859..b618573 100644 --- a/jsonapi-rails.gemspec +++ b/jsonapi-rails.gemspec @@ -21,4 +21,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'sqlite3' spec.add_development_dependency 'rake', '~> 11.3' spec.add_development_dependency 'rspec-rails', '~> 3.5' + spec.add_development_dependency 'simplecov' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8f698be..fa7d5b5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,6 @@ +require 'simplecov' +SimpleCov.start + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause