codeclimate-test-reporter 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22d029fe509088ab5ffbcce0d1a1202a495fa24e
4
- data.tar.gz: b34685362aea43b419ef122cdbd2eade83cc386a
3
+ metadata.gz: d6cb4bd493e9044da7771edbc3eb80ac49035b29
4
+ data.tar.gz: af1b2bfb800eea09cf7488dedc1f3c61e5615e40
5
5
  SHA512:
6
- metadata.gz: 51a86e51b0c27fedbe4a0b58f841aa51f2a4dae0a46032c2d9aeebd6a97a351ecbd60a973d02029956d425d125dcd0b0dfee519b713d746bf7d5714ab4aeff19
7
- data.tar.gz: 7d3918264d16672122d763e8a6b988278289897d9ddad831f9f92a57f8a3f5062c87a2f4ed263c15d5eefb8e0027e1c40664a8fd8e407261d2a8336d745ff024
6
+ metadata.gz: ac5031cb96a6ac7deda24bbb6d029e28bf096dec535a911e16cdfd3a846087e28db1f9f652e7f9de7e7299d3f37f0d6d3479e26981073663fca5ef51d47e47dd
7
+ data.tar.gz: b932b84c1c80fb03abd9297604caa1c038ecc442904481189af49d0e644b02838c70c736b3d13f22182460b5aa26a7e675d3561c1752eb04940aeae24c3a1ffe
@@ -80,8 +80,8 @@ module CodeClimate
80
80
  http.ca_file = File.expand_path('../../../../config/cacert.pem', __FILE__)
81
81
  http.verify_depth = 5
82
82
  end
83
- http.open_timeout = DEFAULT_TIMEOUT # in seconds
84
- http.read_timeout = DEFAULT_TIMEOUT # in seconds
83
+ http.open_timeout = CodeClimate::TestReporter.configuration.timeout
84
+ http.read_timeout = CodeClimate::TestReporter.configuration.timeout
85
85
  end
86
86
  end
87
87
 
@@ -19,7 +19,9 @@ module CodeClimate
19
19
  end
20
20
 
21
21
  class Configuration
22
- attr_accessor :branch, :logger, :profile, :path_prefix, :gzip_request, :git_dir
22
+ attr_accessor :branch, :path_prefix, :gzip_request, :git_dir
23
+
24
+ attr_writer :logger, :profile, :timeout
23
25
 
24
26
  def initialize
25
27
  @gzip_request = true
@@ -37,6 +39,10 @@ module CodeClimate
37
39
  @skip_token ||= "nocov"
38
40
  end
39
41
 
42
+ def timeout
43
+ @timeout ||= Client::DEFAULT_TIMEOUT
44
+ end
45
+
40
46
  private
41
47
 
42
48
  def default_logger
@@ -49,17 +49,20 @@ module CodeClimate
49
49
  end
50
50
 
51
51
  def git_dir
52
- return CodeClimate::TestReporter.configuration.git_dir unless CodeClimate::TestReporter.configuration.git_dir.nil?
53
-
54
- root = "."
52
+ return configured_git_dir unless configured_git_dir.nil?
53
+ rails_git_dir_present? ? Rails.root : '.'
54
+ end
55
55
 
56
- if defined?(Rails) && File.directory?(File.expand_path(".git", Rails.root))
57
- root = Rails.root
58
- end
56
+ def configured_git_dir
57
+ CodeClimate::TestReporter.configuration.git_dir
58
+ end
59
59
 
60
- root
60
+ def rails_git_dir_present?
61
+ defined?(Rails) && !Rails.root.nil? &&
62
+ File.directory?(File.expand_path('.git', Rails.root))
61
63
  end
62
64
  end
63
65
  end
64
66
  end
65
67
  end
68
+
@@ -1,5 +1,5 @@
1
1
  module CodeClimate
2
2
  module TestReporter
3
- VERSION = "0.4.5"
3
+ VERSION = "0.4.6"
4
4
  end
5
5
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ module CodeClimate::TestReporter
4
+ describe Client do
5
+ it 'sets the http timeout per configuration' do
6
+ new_timeout = 969
7
+ CodeClimate::TestReporter.configure do |config|
8
+ config.timeout = new_timeout
9
+ end
10
+
11
+ response = double(:response, code: 200)
12
+ net_http = double(:net_http, request: response)
13
+ allow(Net::HTTP).to receive(:new).
14
+ and_return(net_http)
15
+
16
+ expect(net_http).to receive(:open_timeout=).
17
+ with(new_timeout)
18
+ expect(net_http).to receive(:read_timeout=).
19
+ with(new_timeout)
20
+
21
+ Client.new.post_results("")
22
+ end
23
+ end
24
+ end
@@ -15,6 +15,7 @@ module CodeClimate::TestReporter
15
15
  expect(CodeClimate::TestReporter.configuration.profile).to eq('test_frameworks')
16
16
  expect(CodeClimate::TestReporter.configuration.path_prefix).to be_nil
17
17
  expect(CodeClimate::TestReporter.configuration.skip_token).to eq('nocov')
18
+ expect(CodeClimate::TestReporter.configuration.timeout).to eq(Client::DEFAULT_TIMEOUT)
18
19
  end
19
20
  end
20
21
 
@@ -60,7 +61,14 @@ module CodeClimate::TestReporter
60
61
  CodeClimate::TestReporter.configure do |config|
61
62
  config.path_prefix = nil
62
63
  end
64
+ end
65
+
66
+ it 'stores timeout' do
67
+ CodeClimate::TestReporter.configure do |config|
68
+ config.timeout = 666
69
+ end
63
70
 
71
+ expect(CodeClimate::TestReporter.configuration.timeout).to eq(666)
64
72
  end
65
73
  end
66
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate-test-reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -134,6 +134,7 @@ files:
134
134
  - spec/fixtures/encoding_test_iso.rb
135
135
  - spec/lib/calculate_blob_spec.rb
136
136
  - spec/lib/ci_spec.rb
137
+ - spec/lib/client_spec.rb
137
138
  - spec/lib/configuration_spec.rb
138
139
  - spec/lib/formatter_spec.rb
139
140
  - spec/lib/git_spec.rb
@@ -169,6 +170,7 @@ test_files:
169
170
  - spec/fixtures/encoding_test_iso.rb
170
171
  - spec/lib/calculate_blob_spec.rb
171
172
  - spec/lib/ci_spec.rb
173
+ - spec/lib/client_spec.rb
172
174
  - spec/lib/configuration_spec.rb
173
175
  - spec/lib/formatter_spec.rb
174
176
  - spec/lib/git_spec.rb