我正在尝试将 Code Climate Test Reporter 添加到我使用 CircleCI 的 Rails 应用程序中。
当 CircleCI 运行构建时,我已按照设置说明以及收到的错误消息进行操作,但是,我现在有点卡住了。我的测试全部通过(本地和 CircleCI 中),但我仍然遇到错误。
有没有人见过这样的错误?如果是这样,有什么建议可以让 Code Climate Test Reporter 与 CircleCI 一起正常工作?正如错误输出所暗示的那样,我已经在我的 spec_helper.rb 中删除了响应。
谢谢你的帮助。如果我需要包含更多信息,请告诉我。
以下是 Code Climate 所说的与错误输出一起完成的步骤:
添加代码气候宝石
宝石列表 codeclimate-test-reporter
codeclimate-test-reporter (0.5.0)
在 spec_helper.rb 中添加测试报告器(您还可以从底部 config.before(:each) 块中的错误消息中看到 stub_request。这是我的 spec_helper.rb。
需要“codeclimate-test-reporter”
CodeClimate::TestReporter.start
ENV['RAILS_ENV'] = '测试'
需要 File.expand_path('../../config/environment', FILE )
需要'rspec/rails'需要'should/matchers
'
需要'webmock/rspec'目录[Rails.root.join('spec/support/**/*.rb')].each { |file| 需要文件}
RSpec.configure 做 |config|
config.expect_with :rspec 做 |c|
c.syntax = :expect
endconfig.include 特征,类型::feature config.include Formulaic::Dsl,类型::feature
config.infer_base_class_for_anonymous_controllers = false
config.order = '随机'
config.treat_symbols_as_metadata_keys_with_true_values = true
config.use_transactional_fixtures = falseconfig.before(:each) 做
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 endActiveRecord::Migration.maintain_test_schema!Capybara.javascript_driver = :webkit
WebMock.disable_net_connect!(allow_localhost: true)代码气候测试报告者令牌(我将其从代码气候测试报告者设置屏幕复制到 CircleCI 环境变量屏幕中)
CODECLIMATE_REPO_TOKEN xxxxb0c8
这是我从 CircleCI 输出的错误:
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\����8��1j�N��d}A (WebMock::NetConnectNotAllowedError)
*{UP�:Z��P]TӰ��Ҵ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�=���xO���� �@��' 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\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-?Hii\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\xA2G\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 '
((bundle exec rspec "--color" "" "spec" --format "progress")) returned exit code 1