coverband 0.1.0.preRC9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/coverband.gemspec +0 -1
- data/lib/coverband/base.rb +0 -4
- data/lib/coverband/reporter.rb +23 -1
- data/lib/coverband/version.rb +1 -1
- data/test/test_helper.rb +13 -1
- data/test/unit/base_test.rb +10 -5
- data/test/unit/middleware_test.rb +8 -8
- data/test/unit/redis_store_test.rb +46 -38
- data/test/unit/reporter_test.rb +96 -12
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 577f3ba7a0b16748ac4ea09192da659ec70a2e9a
|
4
|
+
data.tar.gz: 2a56294e904a385080a97970830c23652f6323d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3feecaf7cf2c268f03a23090f341b0102654ad546c2df8f5a47b6d0f7a807a67af70d6e357d8f4134b848b272afb7ee725d905728a501ade5acda02b18a2daa7
|
7
|
+
data.tar.gz: 9af8b91ba39ea2759cb59c97b8fd52f8fa803ec46566c49ac6bdcdfb3bc576b366c3379538531214bcb548f862238b96710238ba9115c0b418427a7240b535a8
|
data/coverband.gemspec
CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "mocha", "~> 0.14.0"
|
24
|
-
spec.add_development_dependency "shoulda"
|
25
24
|
spec.add_development_dependency "rack"
|
26
25
|
spec.add_runtime_dependency "simplecov"
|
27
26
|
spec.add_runtime_dependency "json"
|
data/lib/coverband/base.rb
CHANGED
@@ -126,10 +126,6 @@ module Coverband
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
def add_from_tracepoint(trace_point)
|
130
|
-
add_file(trace_point.path, trace_point.lineno)
|
131
|
-
end
|
132
|
-
|
133
129
|
def add_file(file, line)
|
134
130
|
if !file.match(/(\/gems\/|internal\:prelude)/) && file.match(@project_directory) && !@ignore_patterns.any?{|pattern| file.match(/#{pattern}/) }
|
135
131
|
add_file_without_checks(file, line)
|
data/lib/coverband/reporter.rb
CHANGED
@@ -63,6 +63,27 @@ module Coverband
|
|
63
63
|
fixed_report
|
64
64
|
end
|
65
65
|
|
66
|
+
# [0,0,1,0,1]
|
67
|
+
# [nil,0,1,0,0]
|
68
|
+
# merge to
|
69
|
+
# [0,0,1,0,1]
|
70
|
+
def self.merge_arrays(first, second)
|
71
|
+
merged = []
|
72
|
+
longest = if first.length > second.length
|
73
|
+
first
|
74
|
+
else
|
75
|
+
second
|
76
|
+
end
|
77
|
+
longest.each_with_index do |line, index|
|
78
|
+
if first[index] || second[index]
|
79
|
+
merged[index] = (first[index].to_i + second[index].to_i >= 1 ? 1 : 0)
|
80
|
+
else
|
81
|
+
merged[index] = nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
merged
|
85
|
+
end
|
86
|
+
|
66
87
|
def self.report_scov(redis, existing_coverage, roots, open_report)
|
67
88
|
scov_style_report = {}
|
68
89
|
redis.smembers('coverband').each do |key|
|
@@ -73,7 +94,8 @@ module Coverband
|
|
73
94
|
line_key = line_data.keys.first
|
74
95
|
previous_line_hash = scov_style_report[line_key]
|
75
96
|
if previous_line_hash
|
76
|
-
|
97
|
+
|
98
|
+
line_data[line_key] = merge_arrays(line_data[line_key], previous_line_hash)
|
77
99
|
end
|
78
100
|
scov_style_report.merge!(line_data)
|
79
101
|
end
|
data/lib/coverband/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'simplecov'
|
3
3
|
require 'test/unit'
|
4
|
-
require 'shoulda'
|
5
4
|
require 'mocha/setup'
|
6
5
|
require 'ostruct'
|
7
6
|
require 'json'
|
@@ -16,6 +15,19 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
16
15
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
16
|
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
18
17
|
|
18
|
+
def test(name, &block)
|
19
|
+
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
20
|
+
defined = instance_method(test_name) rescue false
|
21
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
22
|
+
if block_given?
|
23
|
+
define_method(test_name, &block)
|
24
|
+
else
|
25
|
+
define_method(test_name) do
|
26
|
+
flunk "No implementation provided for #{name}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
19
31
|
require 'coverband'
|
20
32
|
|
21
33
|
unless File.exist?('./tmp/coverband_baseline.json')
|
data/test/unit/base_test.rb
CHANGED
@@ -2,15 +2,20 @@ require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
2
|
|
3
3
|
class BaseTest < Test::Unit::TestCase
|
4
4
|
|
5
|
-
|
5
|
+
test "start should enable coverage" do
|
6
6
|
coverband = Coverband::Base.instance.reset_instance
|
7
7
|
assert_equal false, coverband.instance_variable_get("@enabled")
|
8
8
|
coverband.expects(:record_coverage).once
|
9
9
|
coverband.start
|
10
10
|
assert_equal true, coverband.instance_variable_get("@enabled")
|
11
11
|
end
|
12
|
+
|
13
|
+
test "extended should default to false" do
|
14
|
+
coverband = Coverband::Base.instance.reset_instance
|
15
|
+
assert_equal false, coverband.extended?
|
16
|
+
end
|
12
17
|
|
13
|
-
|
18
|
+
test "stop should disable coverage" do
|
14
19
|
coverband = Coverband::Base.instance.reset_instance
|
15
20
|
assert_equal false, coverband.instance_variable_get("@enabled")
|
16
21
|
coverband.expects(:record_coverage).once
|
@@ -21,7 +26,7 @@ class BaseTest < Test::Unit::TestCase
|
|
21
26
|
assert_equal false, coverband.instance_variable_get("@tracer_set")
|
22
27
|
end
|
23
28
|
|
24
|
-
|
29
|
+
test "allow for sampling with a block and enable when 100 percent sample" do
|
25
30
|
logger = Logger.new(STDOUT)
|
26
31
|
coverband = Coverband::Base.instance.reset_instance
|
27
32
|
coverband.instance_variable_set("@sample_percentage", 100.0)
|
@@ -34,7 +39,7 @@ class BaseTest < Test::Unit::TestCase
|
|
34
39
|
assert_equal true, coverband.instance_variable_get("@enabled")
|
35
40
|
end
|
36
41
|
|
37
|
-
|
42
|
+
test "allow reporting with start stop save" do
|
38
43
|
logger = Logger.new(STDOUT)
|
39
44
|
coverband = Coverband::Base.instance.reset_instance
|
40
45
|
coverband.instance_variable_set("@sample_percentage", 100.0)
|
@@ -49,7 +54,7 @@ class BaseTest < Test::Unit::TestCase
|
|
49
54
|
coverband.save
|
50
55
|
end
|
51
56
|
|
52
|
-
|
57
|
+
test "allow reporting to redis start stop save" do
|
53
58
|
coverband = Coverband::Base.instance.reset_instance
|
54
59
|
coverband.instance_variable_set("@sample_percentage", 100.0)
|
55
60
|
coverband.instance_variable_set("@verbose", true)
|
@@ -3,7 +3,7 @@ require 'rack'
|
|
3
3
|
|
4
4
|
class MiddlewareTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
|
6
|
+
test "call app" do
|
7
7
|
request = Rack::MockRequest.env_for("/anything.json")
|
8
8
|
Coverband::Base.instance.reset_instance
|
9
9
|
middleware = Coverband::Middleware.new(fake_app)
|
@@ -11,14 +11,14 @@ class MiddlewareTest < Test::Unit::TestCase
|
|
11
11
|
assert_equal "/anything.json", results.last
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
test 'pass all rack lint checks' do
|
15
15
|
Coverband::Base.instance.reset_instance
|
16
16
|
app = Rack::Lint.new(Coverband::Middleware.new(fake_app))
|
17
17
|
env = Rack::MockRequest.env_for('/hello')
|
18
18
|
app.call(env)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
test 'always be enabled with sample percentage of 100' do
|
22
22
|
request = Rack::MockRequest.env_for("/anything.json")
|
23
23
|
Coverband::Base.instance.reset_instance
|
24
24
|
middleware = Coverband::Middleware.new(fake_app)
|
@@ -28,7 +28,7 @@ class MiddlewareTest < Test::Unit::TestCase
|
|
28
28
|
assert_equal true, Coverband::Base.instance.instance_variable_get("@enabled")
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
test 'never be enabled with sample percentage of 0' do
|
32
32
|
request = Rack::MockRequest.env_for("/anything.json")
|
33
33
|
Coverband::Base.instance.reset_instance
|
34
34
|
middleware = Coverband::Middleware.new(fake_app)
|
@@ -38,7 +38,7 @@ class MiddlewareTest < Test::Unit::TestCase
|
|
38
38
|
assert_equal false, Coverband::Base.instance.instance_variable_get("@enabled")
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
test 'always unset function when sampling' do
|
42
42
|
request = Rack::MockRequest.env_for("/anything.json")
|
43
43
|
Coverband::Base.instance.reset_instance
|
44
44
|
middleware = Coverband::Middleware.new(fake_app)
|
@@ -48,7 +48,7 @@ class MiddlewareTest < Test::Unit::TestCase
|
|
48
48
|
assert_equal false, Coverband::Base.instance.instance_variable_get("@tracer_set")
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
test 'always unset function when not sampling' do
|
52
52
|
request = Rack::MockRequest.env_for("/anything.json")
|
53
53
|
Coverband::Base.instance.reset_instance
|
54
54
|
middleware = Coverband::Middleware.new(fake_app)
|
@@ -58,7 +58,7 @@ class MiddlewareTest < Test::Unit::TestCase
|
|
58
58
|
assert_equal false, Coverband::Base.instance.instance_variable_get("@tracer_set")
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
test 'always record coverage, set trace func, and add_files when sampling' do
|
62
62
|
request = Rack::MockRequest.env_for("/anything.json")
|
63
63
|
Coverband::Base.instance.reset_instance
|
64
64
|
middleware = Coverband::Middleware.new(fake_app)
|
@@ -69,7 +69,7 @@ class MiddlewareTest < Test::Unit::TestCase
|
|
69
69
|
assert_equal true, Coverband::Base.instance.instance_variable_get("@enabled")
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
test 'always report coverage when sampling' do
|
73
73
|
request = Rack::MockRequest.env_for("/anything.json")
|
74
74
|
Coverband::Base.instance.reset_instance
|
75
75
|
|
@@ -1,8 +1,20 @@
|
|
1
1
|
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
|
3
|
+
class RedisTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def test_data
|
8
|
+
{
|
9
|
+
"/Users/danmayer/projects/cover_band_server/app.rb"=>[54, 55],
|
10
|
+
"/Users/danmayer/projects/cover_band_server/server.rb"=>[5]
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class RedisStoreTestV3 < RedisTest
|
16
|
+
|
17
|
+
def setup
|
6
18
|
@redis = Redis.current.tap { |redis|
|
7
19
|
redis.stubs(:sadd).with(anything, anything)
|
8
20
|
redis.stubs(:info).returns({'redis_version' => 3.0})
|
@@ -11,7 +23,7 @@ class RedisStoreTest < Test::Unit::TestCase
|
|
11
23
|
@store = Coverband::RedisStore.new(@redis)
|
12
24
|
end
|
13
25
|
|
14
|
-
|
26
|
+
test "it stores the files into coverband" do
|
15
27
|
@redis.expects(:sadd).with('coverband', [
|
16
28
|
'/Users/danmayer/projects/cover_band_server/app.rb',
|
17
29
|
'/Users/danmayer/projects/cover_band_server/server.rb'
|
@@ -20,7 +32,7 @@ class RedisStoreTest < Test::Unit::TestCase
|
|
20
32
|
@store.store_report(test_data)
|
21
33
|
end
|
22
34
|
|
23
|
-
|
35
|
+
test "it stores the file lines of the file app.rb" do
|
24
36
|
@redis.expects(:sadd).with(
|
25
37
|
'coverband./Users/danmayer/projects/cover_band_server/app.rb',
|
26
38
|
[54, 55]
|
@@ -29,7 +41,7 @@ class RedisStoreTest < Test::Unit::TestCase
|
|
29
41
|
@store.store_report(test_data)
|
30
42
|
end
|
31
43
|
|
32
|
-
|
44
|
+
test "it stores the file lines of the file server.rb" do
|
33
45
|
@redis.expects(:sadd).with(
|
34
46
|
'coverband./Users/danmayer/projects/cover_band_server/server.rb',
|
35
47
|
[5]
|
@@ -38,46 +50,42 @@ class RedisStoreTest < Test::Unit::TestCase
|
|
38
50
|
@store.store_report(test_data)
|
39
51
|
end
|
40
52
|
|
41
|
-
|
42
|
-
setup do
|
43
|
-
@redis.stubs(:info).returns("redis_version"=>"2.2.3")
|
44
|
-
end
|
53
|
+
end
|
45
54
|
|
46
|
-
|
47
|
-
@redis.expects(:sadd).with('coverband', '/Users/danmayer/projects/cover_band_server/app.rb')
|
48
|
-
@redis.expects(:sadd).with('coverband', '/Users/danmayer/projects/cover_band_server/server.rb')
|
55
|
+
class RedisStoreTestV223 < RedisTest
|
49
56
|
|
50
|
-
|
51
|
-
|
57
|
+
def setup
|
58
|
+
@redis = Redis.current.tap { |redis|
|
59
|
+
redis.stubs(:sadd).with(anything, anything)
|
60
|
+
redis.stubs(:info).returns({'redis_version' => "2.2.3"})
|
61
|
+
}
|
62
|
+
|
63
|
+
@store = Coverband::RedisStore.new(@redis)
|
52
64
|
end
|
53
65
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
Redis.send(:remove_const, :VERSION)
|
58
|
-
Redis::VERSION = '2.2.2'
|
59
|
-
end
|
66
|
+
test "it store the files with separate calls into coverband" do
|
67
|
+
@redis.expects(:sadd).with('coverband', '/Users/danmayer/projects/cover_band_server/app.rb')
|
68
|
+
@redis.expects(:sadd).with('coverband', '/Users/danmayer/projects/cover_band_server/server.rb')
|
60
69
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
70
|
+
@store.store_report(test_data)
|
71
|
+
end
|
72
|
+
end
|
65
73
|
|
66
|
-
|
67
|
-
@redis.expects(:sadd).with('coverband', '/Users/danmayer/projects/cover_band_server/app.rb')
|
68
|
-
@redis.expects(:sadd).with('coverband', '/Users/danmayer/projects/cover_band_server/server.rb')
|
74
|
+
class RedisStoreTestV222 < RedisTest
|
69
75
|
|
70
|
-
|
71
|
-
|
76
|
+
def setup
|
77
|
+
@redis = Redis.current.tap { |redis|
|
78
|
+
redis.stubs(:sadd).with(anything, anything)
|
79
|
+
redis.stubs(:info).returns({'redis_version' => "2.2.2"})
|
80
|
+
}
|
81
|
+
|
82
|
+
@store = Coverband::RedisStore.new(@redis)
|
72
83
|
end
|
73
|
-
end
|
74
84
|
|
75
|
-
|
85
|
+
test "it store the files with separate calls into coverband" do
|
86
|
+
@redis.expects(:sadd).with('coverband', '/Users/danmayer/projects/cover_band_server/app.rb')
|
87
|
+
@redis.expects(:sadd).with('coverband', '/Users/danmayer/projects/cover_band_server/server.rb')
|
76
88
|
|
77
|
-
|
78
|
-
|
79
|
-
"/Users/danmayer/projects/cover_band_server/app.rb"=>[54, 55],
|
80
|
-
"/Users/danmayer/projects/cover_band_server/server.rb"=>[5]
|
81
|
-
}
|
82
|
-
end
|
89
|
+
@store.store_report(test_data)
|
90
|
+
end
|
83
91
|
end
|
data/test/unit/reporter_test.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
2
|
|
3
3
|
class ReporterTest < Test::Unit::TestCase
|
4
4
|
|
5
|
-
|
5
|
+
test "record baseline" do
|
6
6
|
Coverage.expects(:start).at_least_once
|
7
7
|
Coverage.expects(:result).returns({'fake' => [0,1]}).at_least_once
|
8
8
|
File.expects(:open).once
|
@@ -14,7 +14,7 @@ class ReporterTest < Test::Unit::TestCase
|
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
test "report data" do
|
18
18
|
Coverband.configure do |config|
|
19
19
|
config.redis = fake_redis
|
20
20
|
config.reporter = 'std_out'
|
@@ -44,7 +44,7 @@ class ReporterTest < Test::Unit::TestCase
|
|
44
44
|
# shows that it has become a disaster of self methods relying on side effects.
|
45
45
|
# Fix to standard class and methods.
|
46
46
|
####
|
47
|
-
|
47
|
+
test "filename_from_key fix filename from a key with a swappable path" do
|
48
48
|
Coverband.configure do |config|
|
49
49
|
config.redis = fake_redis
|
50
50
|
config.reporter = 'std_out'
|
@@ -52,19 +52,43 @@ class ReporterTest < Test::Unit::TestCase
|
|
52
52
|
end
|
53
53
|
|
54
54
|
key = "/app/is/a/path.rb"
|
55
|
-
#the code takes config.root expands and adds a '/'
|
55
|
+
#the code takes config.root expands and adds a '/' for the final path in roots
|
56
56
|
roots = ["/app/", '/full/remote_app/path/']
|
57
57
|
|
58
58
|
assert_equal "/full/remote_app/path/is/a/path.rb", Coverband::Reporter.filename_from_key(key, roots)
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
test "filename_from_key fix filename a changing deploy path with double quotes" do
|
62
|
+
Coverband.configure do |config|
|
63
|
+
config.redis = fake_redis
|
64
|
+
config.reporter = 'std_out'
|
65
|
+
config.root = '/full/remote_app/path'
|
66
|
+
end
|
67
|
+
|
68
|
+
key = "/box/apps/app_name/releases/20140725203539/app/models/user.rb"
|
69
|
+
# the code takes config.root expands and adds a '/' for the final path in roots
|
70
|
+
# note to get regex to work for changing deploy directories it must be double escaped in double quotes or use single qoutes
|
71
|
+
roots = ["/box/apps/app_name/releases/\\d+/", '/full/remote_app/path/']
|
72
|
+
|
73
|
+
assert_equal "/full/remote_app/path/app/models/user.rb", Coverband::Reporter.filename_from_key(key, roots)
|
74
|
+
end
|
75
|
+
|
76
|
+
test "filename_from_key fix filename a changing deploy path with single quotes" do
|
77
|
+
Coverband.configure do |config|
|
78
|
+
config.redis = fake_redis
|
79
|
+
config.reporter = 'std_out'
|
80
|
+
config.root = '/full/remote_app/path'
|
81
|
+
end
|
82
|
+
|
83
|
+
key = "/box/apps/app_name/releases/20140725203539/app/models/user.rb"
|
84
|
+
# the code takes config.root expands and adds a '/' for the final path in roots
|
85
|
+
# note to get regex to work for changing deploy directories it must be double escaped in double quotes or use single qoutes
|
86
|
+
roots = ['/box/apps/app_name/releases/\d+/', '/full/remote_app/path/']
|
87
|
+
|
88
|
+
assert_equal "/full/remote_app/path/app/models/user.rb", Coverband::Reporter.filename_from_key(key, roots)
|
89
|
+
end
|
90
|
+
|
91
|
+
test "filename_from_key leave filename from a key with a local path" do
|
68
92
|
Coverband.configure do |config|
|
69
93
|
config.redis = fake_redis
|
70
94
|
config.reporter = 'std_out'
|
@@ -72,12 +96,72 @@ class ReporterTest < Test::Unit::TestCase
|
|
72
96
|
end
|
73
97
|
|
74
98
|
key = "/full/remote_app/path/is/a/path.rb"
|
75
|
-
#the code takes config.root expands and adds a '/'
|
99
|
+
#the code takes config.root expands and adds a '/' for the final path in roots
|
76
100
|
roots = ["/app/", '/full/remote_app/path/']
|
77
101
|
|
78
102
|
assert_equal "/full/remote_app/path/is/a/path.rb", Coverband::Reporter.filename_from_key(key, roots)
|
79
103
|
end
|
80
104
|
|
105
|
+
test "line_hash gets correct hash entry for a line key" do
|
106
|
+
Coverband.configure do |config|
|
107
|
+
config.redis = fake_redis
|
108
|
+
config.reporter = 'std_out'
|
109
|
+
config.root = '/full/remote_app/path'
|
110
|
+
end
|
111
|
+
|
112
|
+
key = "/full/remote_app/path/is/a/path.rb"
|
113
|
+
#the code takes config.root expands and adds a '/'
|
114
|
+
roots = ["/app/", '/full/remote_app/path/']
|
115
|
+
|
116
|
+
current_redis = fake_redis
|
117
|
+
lines_hit = ['1','3','6']
|
118
|
+
current_redis.stubs(:smembers).returns(lines_hit)
|
119
|
+
#expects to show hit counts on 1,3,6
|
120
|
+
expected = {"/full/remote_app/path/is/a/path.rb" => [1,0,1,0,0,1]}
|
121
|
+
File.stubs(:exists?).returns(true)
|
122
|
+
File.stubs(:foreach).returns(['line 1','line2','line3','line4','line5','line6'])
|
123
|
+
|
124
|
+
assert_equal expected, Coverband::Reporter.line_hash(current_redis, key, roots)
|
125
|
+
end
|
126
|
+
|
127
|
+
test "line_hash adjusts relative paths" do
|
128
|
+
Coverband.configure do |config|
|
129
|
+
config.redis = fake_redis
|
130
|
+
config.reporter = 'std_out'
|
131
|
+
config.root = '/full/remote_app/path'
|
132
|
+
end
|
133
|
+
|
134
|
+
key = "./is/a/path.rb"
|
135
|
+
#the code takes config.root expands and adds a '/'
|
136
|
+
roots = ["/app/", '/full/remote_app/path/']
|
137
|
+
|
138
|
+
current_redis = fake_redis
|
139
|
+
lines_hit = ['1','3','6']
|
140
|
+
current_redis.stubs(:smembers).returns(lines_hit)
|
141
|
+
#expects to show hit counts on 1,3,6
|
142
|
+
expected = {"/full/remote_app/path/is/a/path.rb" => [1,0,1,0,0,1]}
|
143
|
+
File.stubs(:exists?).returns(true)
|
144
|
+
File.stubs(:foreach).returns(['line 1','line2','line3','line4','line5','line6'])
|
145
|
+
|
146
|
+
assert_equal expected, Coverband::Reporter.line_hash(current_redis, key, roots)
|
147
|
+
end
|
148
|
+
|
149
|
+
test "#merge_arrays basic merge preserves order and counts" do
|
150
|
+
first = [0,0,1,0,1]
|
151
|
+
second = [nil,0,1,0,0]
|
152
|
+
expects = [0,0,1,0,1]
|
153
|
+
|
154
|
+
assert_equal expects, Coverband::Reporter.merge_arrays(first, second)
|
155
|
+
end
|
156
|
+
|
157
|
+
test "#merge_arrays basic merge preserves order and counts different lenths" do
|
158
|
+
first = [0,0,1,0,1]
|
159
|
+
second = [nil,0,1,0,0,0,0,1]
|
160
|
+
expects = [0,0,1,0,1,0,0,1]
|
161
|
+
|
162
|
+
assert_equal expects, Coverband::Reporter.merge_arrays(first, second)
|
163
|
+
end
|
164
|
+
|
81
165
|
private
|
82
166
|
|
83
167
|
def fake_redis
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coverband
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.14.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: shoulda
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rack
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,9 +153,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
153
|
version: '0'
|
168
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
155
|
requirements:
|
170
|
-
- - "
|
156
|
+
- - ">="
|
171
157
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
158
|
+
version: '0'
|
173
159
|
requirements: []
|
174
160
|
rubyforge_project:
|
175
161
|
rubygems_version: 2.2.2
|