Code Climate test reporter failing in CircleCI

I am trying to add the Code Climate Test Reporter to a Rails app where I am using CircleCI.

I have followed the setup instructions along with the error messages I am getting when CircleCI runs the build, however, I am a bit stuck now. My tests all pass (locally and in CircleCI) but I am still getting an error.

Have anyone seen an error like this? If so, any suggestions for getting the Code Climate Test Reporter to work correctly with CircleCI? As the error output suggests, I have stubbed out the response in my spec_helper.rb.

Thanks for your help. Please let me know if I need to include more information.

Here are the steps Code Climate said to complete along with the error output:

  1. add the code climate gem
    gem list codeclimate-test-reporter
    *** LOCAL GEMS ***

     codeclimate-test-reporter (0.5.0)
    
  2. add test reporter in spec_helper.rb (you can also see the stub_request from the error message in the config.before(:each) block at the bottom
    require "codeclimate-test-reporter"
    CodeClimate::TestReporter.start

    ENV[‘RAILS_ENV’] = ‘test’

    require File.expand_path(’…/…/config/environment’, FILE)
    require 'rspec/rails’
    require 'shoulda/matchers’
    require ‘webmock/rspec’

    Dir[Rails.root.join(‘spec/support/**/*.rb’)].each { |file| require file }

    RSpec.configure do |config|
    config.expect_with :rspec do |c|
    c.syntax = :expect
    end

    config.include Features, type: :feature
    config.include Formulaic::Dsl, type: :feature

    config.infer_base_class_for_anonymous_controllers = false
    config.order = 'random’
    config.treat_symbols_as_metadata_keys_with_true_values = true
    config.use_transactional_fixtures = false

    config.before(:each) do   
     stub_request(:post, "https://codeclimate.com/test_reports").    
       with(:body => "\u001F\x8B\b\u0000\xE0\xC1\u0012W\........
         :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Encoding'=>'gzip', 'Content-Type'=>'application/json', 'User-Agent'=>'Code Climate (Ruby Test Reporter v0.5.0)'}).  
        to_return(:status => 200, :body => "", :headers => {})·  
     end
    

    end

    ActiveRecord::Migration.maintain_test_schema!
    Capybara.javascript_driver = :webkit
    WebMock.disable_net_connect!(allow_localhost: true)

  3. Code Climate test reporter token (i copied this into the CircleCI environment variables screen from the code climate test reporter setup screen)
    CODECLIMATE_REPO_TOKEN xxxxb0c8

  4. Error output from Circle CI

    bundle exec rspec --color spec --format progress
    I, [2016-04-18T05:16:18.343024 #12231] INFO – : Reporting coverage data to Code Climate.
    /home/ubuntu/msd-redux/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.1/lib/active_support/values/time_zone.rb:285: warning: circular argument reference - now
    [Simple Form] Simple Form is not configured in the application and will use the default values. Use rails generate simple_form:install to generate the Simple Form configuration.

    Finished in 1.24 seconds
    13 examples, 0 failures

    Randomized with seed 45226

    Coverage = 100.0%. Sending report to https://codeclimate.com for branch contact_form… /home/ubuntu/msd-redux/vendor/bundle/ruby/2.2.0/gems/webmock-1.24.0/lib/webmock/http_lib_adapters/net_http.rb:114:in request': Real HTTP connections are disabled. Unregistered request: POST https://codeclimate.com/test_reports with body '���mW��X�n�8�=g�/����á#DC�����5m�X�s���"%��3g�P���y�������h\����8e��1j�N��d}A (WebMock::NetConnectNotAllowedError) *{UP�:Z��P]TӰe��Ҵ4U�_�:�W�v{�C?�C��8]�}� ������c�w�vHu�yU�EA2Ep)��"xk�JK# L �E8����[_�E�kۧ���?gP���;���Z q)�ǧy�~3���e�mz�����<T�0C[]�_�kuQu�4-�����(�-�-�l:T�D&�(�ǐ���+�iހ��)�� �>�?��Z��@-�H�D$��R, ����&.��ȂYO�"z�U�D,�����p���ĕ�7��u��Pa�-�8|���Yx��� :��c���p,��\|0����20�B 9����WG��/���K���� �T��z#t�Fert��d��z�6��� �}F2�/I�8��� Ğ�M�s*�����b�]�S1���y���}��h� {qt�#�3�O<��6���F�@��$��<� w�dn��G�-.@2K��D������W�|���adڮ�3h�X�m���J��K�X��m���C�~��>E��(_/�q�װ��8��A�+�q�ڸ�ዊ��P��.�NtQm�yY{C��D2x�BK��D,1��J"‘�W�K�g����k�w���X��4B�7O�4�uƮ�o�5>��˭O]��-��-!�z{����f��j���?�g���дS=r�{j��t[.r�ݫ37���E4x����b�-6�C�k����d^3b��B�]�ff�iJC#?�KU�=���exO��a�� �@��’ with headers {‘Accept’=>’/’, ‘Accept-Encoding’=>‘gzip;q=1.0,deflate;q=0.6,identity;q=0.3’, ‘Content-Encoding’=>‘gzip’, ‘Content-Type’=>‘application/json’, ‘User-Agent’=>‘Code Climate (Ruby Test Reporter v0.5.0)’}

    You can stub this request with the following snippet:

    stub_request(:post, “https://codeclimate.com/test_reports”).
    with(:body => “\u001F\x8B\b\u0000\xA5m\u0014W\u0000\u0003\xCDX\xDBn\xDB8\u0010\xFD\u0017=g\u0013\xDE/\xF9\x95\xA2\u0010\x86á#D\u0017C\x92\x93\xEE\u0006\xF9\xF7\u001D5m\xE3X\xB5s\x81\x83\u0016\u0001\f\x89”%\x9E\xE1\x993g\xF2P\x8D\xB4\u001D\xEAy\xB8\xA5\xBE\xBA\xAE\x82\xA1h\\x88\x94\u001D\x99\u0012\xD08\e\x8B\xD71j\x90N\x89\u0000d}A \n*{\u0011UP\u000E\x92\u0017:Z\xE7\x93\xC0P]TӰ\e\x91\xEAҴ4U\xD7_\u001E\xAA\u001E:\xE2W\xC3v{\x85C?\x8FC\xDB\xD28]\xF1}\xDB \xCC\xCD\xD0\xD7\xCF\xE3\x97c\xE2w\xA4vHu\x93yU\u000E\xDAEA2Ep)\xE7\u0000"xk\x92\u000EJK\u001F# \u0015L\n\x96E8\xDC\xD1\b\x9B\xE5[\xE4E\xBFkۧ\x9F\xA7\xEB\xAF?gP\xAE\xB7\xC4;\xEC\xE7\xEAZ\nq)\x9Eǧy\xA4~3\xDF\xF0\x83e\xB8mz\xE2\xAD\xED\xFA\x99\x81<T\xF30C[]\xDB\xF3\xABkuQu\xCD4-\x97\xE2\xF1\xF1\xE2(\xD6-\xE0-\xEFl:\u0001T\xC5D&\xA1(\xC1ǐ\xB4\xCC\xCE+\xE9\u0012i\fހ\u0000\xE9)\u0005\xAD\xCB\n\xE8>\xD4?\u000E\xF4\x9EZ\u001C\xBA\x93@-\xB3H\xE5D$\xB4\xC4R,\nT!&\xA9\x9D\xC6b\xB2\xCBI\xA5\xE0\xD2\xFAD\xFF8\xD0\ej\xB7\x87\xCC}\u001A[\xB1\x96\xF8\xE4|4\u0016\u001D\xD8\xC8\aJI0U\xA5\xF7\xB9萄\xA5\u0018P\u0015\xF1[֞\r\x97\xDA\xC3%\x8F\xE0\xE2s*\xCDf\u001F\xD2!\u0016’]\u0006#|\xC9%\xBAཊ\x85\xF7P4)\x95Ddq\xC8Y#\x9C\xCC\xC0翗g\xB8\x9F\xA1\xFB\u0013\xE4z\xE1\xB1\xC5\u001F\xFB9[\x90\x8D\xD9g\x8F8\u001D\xE64\f\xF3*\u001F\xC8\u0016\x81\xB2\u0000\x8A\x84\x99l\x88\xDAY-\x80\x83^2\xE7JB(\u0016\x9C9\x88\xEF\x8B0\x9D\u000F\xCD\eR\xE1\a\u0016\xEA\xEF\x9Aq\xE8;\xFE\xD6!$.\u000F9\x8A\x8C\xCE\xCAh\xB8D\xC4\"9\xA5c\xB4\xBA\u0014a\xBC7\xE4\xB5\xD7\u009F\x80tf\\oI\xF15\xAE\xE9j\xA6i\x85.g\f\u0010\xB5\xB2V\u0014\xCFUR\u0018k#\xA7D\x88^\u0014祱\xB2PR\x87\a\xF6\u001A{O\xA6Ưl8~\xF7\xBE7\u001D\x9Fq>.\xC9}\xFDy%\xEAM\xDF\xCC\r\xB4\xCD\u007F\x8B\xC0&.\x97\xF3ȂYO\xEC\"z\xE4\xB1U\xD6D\u001D,\xB2\x9A\xFA\x98\xB2p\u0010\xB2\xD2\xCAĕ\xB57\xF3\u0013\x9Bu\xB1\xE9Pa\xCF-\f\xE28|\xBF\x87\xFE\u0015Yx\u0001\u001E\x87\xE1\xB6\xE1\n:\xD1\xF8c\xEC\u0010\xBB\x87\u0005p,\xA2\xC4\\|0\x89\x8D\x99\xCF20\xE7B\t9\xA0\xF7\x82\x92WG\xB1\x9F/\xAF\xF4\xDBK\xCC\v\x90\xB9\x99 \xB5T\u007F\xEB\xDAz\v#t\xAB\u0003Fert\xEC\xFA\u001Cd\xAB\u0014\b\xE5\u0005z\x926\x82\x8F\xD2\t\x91}F2\xF6/\u0006I\xE38\xAC\x99\xEB\x93\nĞ\x80M\xB3s*\xB3\xB6\x87\u0000\xD2\u0006b\xE9\xB0]\xC2S1\xF4\xAA\xFFy\xAF\x94\xBC}\xD2\xE7h\xB0\n{qt\xEF\x88#\xB7\u00123\x8DO<\xA1\xE5\xAA\u001D6\x9B\xA6\xDF\u001CF\xD6@\x8C\x86$\xF9\x94<\x92\n\xCC\u000Fd/\r\xD9\u0004n\u001FB\x94L\u0019B+Ok\xC2\xE7\u0014\xD3\xF7\xF0\xA6\xE9KK\xB8x\xB1\u0015y\xD8$h\x9D8\xEF1\u0018'\x85\xD4Jd\x8F\x89\u0014X.S\xE0\eB\u0011ûe\xEF\u0013\xCD\xD3\t\x8D\x94\xEE\x83"\xD95\u001D\xD5\xF3\xBF[ZE(\xA3\f\x91\x8D*[S\x89\u001A\u001C\x8B\x88\xD7\u0005\x8A7\x8E\x94\xB6%9S\xD0\xE4\xE3\xE2x~\x94\xE6\x83 \xB9\u0002\xDE\xD63#\u001Dv+\u0013\u0002Ƹ\xC51j\x8A9\b\u0015ـ\x8B\xA0،(\u001F\b\xB5WY\x92TJ\u001F\xAA\xC8\xD9\xC8-?Hii\x9C\xA6y\u0018\xE9\u0010U\xC8Fr)/`ML1\xB1\xC2s\xF7+\x8CJ\x890\xE5\u0014Q\xA2/E\u001E\xF6\u001A\u007F\x93\xE8ߏ\xB0}\x96\xAA\u0015=5\u001F\rw\u007F\xB6dn\x9E\xA2`G\xEC-\u0015.\u0004\u000E@2K\x83\xA4D\xD1\xFC\xD6\u001A\x9F\xD0\xEBW\u0014\xFF|\xA7\xFE\x8E\u0006adڮ\xF33h\xE7X\x8Fm\u0006\x9F\xBD\xF1J\x98\x94K\xF1\u0005X\xD5\u0002\u001A\xB6m\x8B\x9D\x81C\x91~\xEE\xFF>E\x9E\xF5\v(_/\xAAq\xD7װ\xBC\xD88\u0011\xAD\xB3A\x9E+\x82q\xBF\fڸ\xFFዊ\x89\xB3P\xA9\xBA.\xD0NtQm\x9AyY{C\xF0\xFD\u007FD2x\xCCBK\u0003\xE4\xC0D,1\xA5\xECJ\"’\u0012\xB7W\x85K\u0000g\x88\xFB\u001E\xA1\xAEk\xE6\x99w\xB5\x87\xC2X\xD6\xDB4B\x8F7O\xC74\u0003\xCEu\u0019Ʈ\xE2o\xEF5>\xDF\xF7˭O]\u0016\u001E\xDF\u000F\xE3-\xCF\u001F\xA7-!\xBFz{\xBF\xEC\xE5\xEAf\xE8\xE8j\x97\u0018\xDE\xF2?\x8Cg\xF7\x8D\u001F\x8FдS=r\xA7{j\xD6\xD4t[.r\xC3ݫ37\xD4\xD5\u001C\xADE4x\x9A\xB8\xB4\x97b\xD9-6\x8BC\xBEk\x90\x96\xCD\xFEd^3b\x8B\xCDB\xB8]\xD3ff\u001C\x83iJC#?\x94KU\xFC=\xFA\x9F\xF1\xAA\xA7\exO\x9C\u001F\u001F\xFF\a\x94\xB3\t\xA6@\u0015\u0000\u0000",
    :headers => {‘Accept’=>’/’, ‘Accept-Encoding’=>‘gzip;q=1.0,deflate;q=0.6,identity;q=0.3’, ‘Content-Encoding’=>‘gzip’, ‘Content-Type’=>‘application/json’, ‘User-Agent’=>‘Code Climate (Ruby Test Reporter v0.5.0)’}).
    to_return(:status => 200, :body => “”, :headers => {})

    ============================================================
    from /home/ubuntu/msd-redux/vendor/bundle/ruby/2.2.0/gems/codeclimate-test-reporter-0.5.0/lib/code_climate/test_reporter/client.rb:67:in post_results' from /home/ubuntu/msd-redux/vendor/bundle/ruby/2.2.0/gems/codeclimate-test-reporter-0.5.0/lib/code_climate/test_reporter/formatter.rb:29:informat’
    from /home/ubuntu/msd-redux/vendor/bundle/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/result.rb:47:in format!' from /home/ubuntu/msd-redux/vendor/bundle/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/configuration.rb:172:inblock in at_exit’
    from /home/ubuntu/msd-redux/vendor/bundle/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/defaults.rb:67:in call' from /home/ubuntu/msd-redux/vendor/bundle/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/defaults.rb:67:inblock in <top (required)>’

    ((bundle exec rspec “–color” “” “spec” --format “progress”)) returned exit code 1