slather 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ //
2
+ // Branches.h
3
+ // fixtures
4
+ //
5
+ // Created by Julian Krumow on 11.10.14.
6
+ // Copyright (c) 2014 marklarr. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ @interface Branches : NSObject
12
+
13
+ - (void)branches:(BOOL)goIf skipBranches:(BOOL)skipBranches;
14
+
15
+ @end
@@ -0,0 +1,45 @@
1
+ //
2
+ // Branches.m
3
+ // fixtures
4
+ //
5
+ // Created by Julian Krumow on 11.10.14.
6
+ // Copyright (c) 2014 marklarr. All rights reserved.
7
+ //
8
+
9
+ #import "Branches.h"
10
+
11
+ @implementation Branches
12
+
13
+ - (void)branches:(BOOL)goIf skipBranches:(BOOL)skipBranches
14
+ {
15
+ if (goIf) {
16
+ NSLog(@"foo.");
17
+
18
+ if (!skipBranches) {
19
+ NSLog(@"not skipped.");
20
+ }
21
+ } else {
22
+ NSLog(@"bar.");
23
+ }
24
+
25
+ int i = 5;
26
+ if (i == 5) {
27
+ return;
28
+ }
29
+ switch (i) {
30
+ case 0:
31
+ NSLog(@"0");
32
+ break;
33
+
34
+ case 1:
35
+ NSLog(@"1");
36
+ break;
37
+ case 5:
38
+ NSLog(@"5");
39
+ break;
40
+ default:
41
+ break;
42
+ }
43
+ }
44
+
45
+ @end
@@ -0,0 +1,38 @@
1
+ //
2
+ // BranchesTests.m
3
+ // fixtures
4
+ //
5
+ // Created by Julian Krumow on 11.10.14.
6
+ // Copyright (c) 2014 marklarr. All rights reserved.
7
+ //
8
+
9
+ #import <XCTest/XCTest.h>
10
+ #import "Branches.h"
11
+
12
+ @interface BranchesTests : XCTestCase
13
+
14
+ @end
15
+
16
+ @implementation BranchesTests
17
+
18
+ - (void)setUp {
19
+ [super setUp];
20
+ // Put setup code here. This method is called before the invocation of each test method in the class.
21
+ }
22
+
23
+ - (void)tearDown {
24
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
25
+ [super tearDown];
26
+ }
27
+
28
+ - (void)testBranchesNoBranches {
29
+ Branches *branches = [[Branches alloc] init];
30
+ [branches branches:NO skipBranches:NO];
31
+ }
32
+
33
+ - (void)testBranchesFirstBranchAndSkip {
34
+ Branches *branches = [[Branches alloc] init];
35
+ [branches branches:YES skipBranches:YES];
36
+ }
37
+
38
+ @end
@@ -1 +1 @@
1
- {"meta":{"timestamp":"2014-09-19 11:21:36.112110"},"symbols_by_file":{"spec/fixtures/fixtures/fixtures.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":16,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"-"},{"line":20,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":21,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"}],"spec/fixtures/fixtures/more_files/peekaview.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":16,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":19,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":20,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":21,"long_text":"","short_text":"-"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"-"},{"line":27,"long_text":"","short_text":"-"},{"line":28,"long_text":"","short_text":"-"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"-"}],"spec/fixtures/fixturesTests/fixturesTests.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"-"},{"line":16,"long_text":"","short_text":"-"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"-"},{"line":20,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":21,"long_text":"","short_text":"-"},{"line":22,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"-"},{"line":27,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":28,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"-"},{"line":32,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":33,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":34,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":35,"long_text":"","short_text":"-"},{"line":36,"long_text":"","short_text":"-"}],"spec/fixtures/fixturesTests/peekaviewTests.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"-"},{"line":16,"long_text":"","short_text":"-"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":20,"long_text":"","short_text":"-"},{"line":21,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":27,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":28,"long_text":"","short_text":"-"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":32,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":33,"long_text":"","short_text":"-"},{"line":34,"long_text":"","short_text":"-"}]}}
1
+ {"meta":{"timestamp":"2014-10-12 15:21:21.865519"},"symbols_by_file":{"spec/fixtures/fixtures/more_files/Branches.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":16,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":19,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":20,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":21,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":22,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":26,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":27,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":28,"long_text":"","short_text":"-"},{"line":29,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":32,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":33,"long_text":"","short_text":"-"},{"line":34,"long_text":"","short_text":"-"},{"line":35,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":36,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":37,"long_text":"","short_text":"-"},{"line":38,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":39,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":40,"long_text":"","short_text":"-"},{"line":41,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":42,"long_text":"","short_text":"-"},{"line":43,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":44,"long_text":"","short_text":"-"},{"line":45,"long_text":"","short_text":"-"}],"spec/fixtures/fixtures/fixtures.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":16,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"-"},{"line":20,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":21,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"}],"spec/fixtures/fixtures/more_files/peekaview.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":16,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":19,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":20,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":21,"long_text":"","short_text":"-"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"-"},{"line":27,"long_text":"","short_text":"-"},{"line":28,"long_text":"","short_text":"-"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"-"}],"spec/fixtures/fixturesTests/BranchesTests.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"-"},{"line":16,"long_text":"","short_text":"-"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":20,"long_text":"","short_text":"-"},{"line":21,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":26,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":27,"long_text":"","short_text":"-"},{"line":28,"long_text":"","short_text":"-"},{"line":29,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":30,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":31,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":32,"long_text":"","short_text":"-"},{"line":33,"long_text":"","short_text":"-"},{"line":34,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":35,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":36,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":37,"long_text":"","short_text":"-"},{"line":38,"long_text":"","short_text":"-"}],"spec/fixtures/fixturesTests/fixturesTests.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"-"},{"line":16,"long_text":"","short_text":"-"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"-"},{"line":20,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":21,"long_text":"","short_text":"-"},{"line":22,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"-"},{"line":27,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":28,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"-"},{"line":32,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":33,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":34,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":35,"long_text":"","short_text":"-"},{"line":36,"long_text":"","short_text":"-"}],"spec/fixtures/fixturesTests/peekaviewTests.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"-"},{"line":16,"long_text":"","short_text":"-"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":20,"long_text":"","short_text":"-"},{"line":21,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":27,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":28,"long_text":"","short_text":"-"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":32,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":33,"long_text":"","short_text":"-"},{"line":34,"long_text":"","short_text":"-"}]}}
@@ -77,65 +77,193 @@ describe Slather::CoverageFile do
77
77
  OBJC
78
78
  expect(coverage_file.source_data).to eq(expected)
79
79
  end
80
+ end
81
+
82
+ describe "source_file_basename" do
83
+ it "returns the base name of the source file" do
84
+ expect(coverage_file.source_file_basename).to eq("fixtures")
85
+ end
86
+ end
80
87
 
81
- describe "source_file_pathname_relative_to_repo_root" do
82
- it "should return a pathname to the source_file, relative to the root of the repo" do
83
- expect(coverage_file.source_file_pathname_relative_to_repo_root).to eq(Pathname("spec/fixtures/fixtures/fixtures.m"))
84
- end
88
+ describe "source_file_pathname_relative_to_repo_root" do
89
+ it "should return a pathname to the source_file, relative to the root of the repo" do
90
+ expect(coverage_file.source_file_pathname_relative_to_repo_root).to eq(Pathname("spec/fixtures/fixtures/fixtures.m"))
85
91
  end
92
+ end
86
93
 
87
- describe "#coverage_for_line" do
88
- it "should return nil if the line is not relevant to coverage" do
89
- expect(coverage_file.coverage_for_line(" -: 75: }")).to be_nil
90
- end
94
+ describe "#ignored" do
95
+ it "should return true if the source_file_pathname globs against anything in the project.ignore_list" do
96
+ coverage_file.project.ignore_list = ["*spec*", "*test*"]
97
+ expect(coverage_file.ignored?).to be_truthy
98
+ end
91
99
 
92
- it "should return the number of times the line was executed if the line is relevant to coverage" do
93
- expect(coverage_file.coverage_for_line(" 1: 75: }")).to eq(1)
94
- expect(coverage_file.coverage_for_line(" 15: 75: }")).to eq(15)
95
- expect(coverage_file.coverage_for_line(" ####: 75: }")).to eq(0)
96
- end
100
+ it "should return false if the source_file_pathname does not glob against anything in the project.ignore_list" do
101
+ coverage_file.project.ignore_list = ["*test*", "*XCTest*"]
102
+ expect(coverage_file.ignored?).to be_falsy
97
103
  end
104
+ end
98
105
 
99
- describe "#ignored" do
100
- it "should return true if the source_file_pathname globs against anything in the project.ignore_list" do
101
- coverage_file.project.ignore_list = ["*spec*", "*test*"]
102
- expect(coverage_file.ignored?).to be_truthy
103
- end
106
+ describe "gcov_data" do
107
+ it "should process the gcno file with gcov and return the contents of the file" do
108
+ expect(coverage_file.gcov_data.include?("1: 15: NSLog(@\"tested\");")).to be_truthy
109
+ end
110
+ end
104
111
 
105
- it "should return false if the source_file_pathname does not glob against anything in the project.ignore_list" do
106
- coverage_file.project.ignore_list = ["*test*", "*XCTest*"]
107
- expect(coverage_file.ignored?).to be_falsy
108
- end
112
+ describe "line coverage" do
113
+
114
+ let(:line_coverage_file) do
115
+ fixtures_project.send(:coverage_files).detect { |cf| cf.source_file_pathname.basename.to_s == "fixtures.m" }
109
116
  end
110
117
 
111
- describe "gcov_data" do
112
- it "should process the gcno file with gcov and return the contents of the file" do
113
- expect(coverage_file.gcov_data.include?("1: 15: NSLog(@\"tested\");")).to be_truthy
118
+ describe "#coverage_for_line" do
119
+ it "should return nil if the line is not relevant to coverage" do
120
+ expect(line_coverage_file.coverage_for_line(" -: 75: }")).to be_nil
121
+ end
122
+
123
+ it "should return the number of times the line was executed if the line is relevant to coverage" do
124
+ expect(line_coverage_file.coverage_for_line(" 1: 75: }")).to eq(1)
125
+ expect(line_coverage_file.coverage_for_line(" 15: 75: }")).to eq(15)
126
+ expect(line_coverage_file.coverage_for_line(" ####: 75: }")).to eq(0)
114
127
  end
115
128
  end
116
129
 
117
130
  describe "num_lines_tested" do
118
131
  it "should return the correct number of lines tested" do
119
- expect(coverage_file.num_lines_tested).to eq(2)
132
+ expect(line_coverage_file.num_lines_tested).to eq(2)
120
133
  end
121
134
  end
122
135
 
123
136
  describe "num_lines_testable" do
124
137
  it "should return the correct number of lines that are testable" do
125
- expect(coverage_file.num_lines_testable).to eq(4)
138
+ expect(line_coverage_file.num_lines_testable).to eq(4)
126
139
  end
127
140
  end
128
141
 
129
142
  describe "percentage_lines_tested" do
130
143
  it "should return the correct percentage of lines that are tested" do
131
- expect(coverage_file.percentage_lines_tested).to eq(50)
144
+ expect(line_coverage_file.percentage_lines_tested).to eq(50)
132
145
  end
133
146
 
134
147
  it "should return 0" do
135
- coverage_file.stub(:num_lines_testable).and_return(0)
136
- expect(coverage_file.percentage_lines_tested).to eq(0)
148
+ line_coverage_file.stub(:num_lines_testable).and_return(0)
149
+ expect(line_coverage_file.percentage_lines_tested).to eq(0)
150
+ end
151
+ end
152
+ end
153
+
154
+ describe "branch coverage" do
155
+
156
+ let(:branch_coverage_file) do
157
+ fixtures_project.send(:coverage_files).detect { |cf| cf.source_file_pathname.basename.to_s == "Branches.m" }
158
+ end
159
+
160
+ describe "branch_coverage_data" do
161
+ it "should return a hash with keys representing the line number of a branch statement" do
162
+ expect(branch_coverage_file.branch_coverage_data.keys[0]).to eq(15)
163
+ expect(branch_coverage_file.branch_coverage_data.keys[1]).to eq(18)
164
+ expect(branch_coverage_file.branch_coverage_data.keys[2]).to eq(26)
165
+ expect(branch_coverage_file.branch_coverage_data.keys[3]).to eq(29)
166
+ end
167
+
168
+ it "should store an array for each line number which contains the hit count for each branch" do
169
+ data = branch_coverage_file.branch_coverage_data[15]
170
+ expect(data.length).to eq(2)
171
+ expect(data[0]).to eq(1)
172
+ expect(data[1]).to eq(1)
173
+
174
+ data = branch_coverage_file.branch_coverage_data[18]
175
+ expect(data.length).to eq(2)
176
+ expect(data[0]).to eq(0)
177
+ expect(data[1]).to eq(1)
178
+
179
+ data = branch_coverage_file.branch_coverage_data[26]
180
+ expect(data.length).to eq(2)
181
+ expect(data[0]).to eq(2)
182
+ expect(data[1]).to eq(0)
183
+
184
+ data = branch_coverage_file.branch_coverage_data[29]
185
+ expect(data.length).to eq(4)
186
+ expect(data[0]).to eq(0)
187
+ expect(data[1]).to eq(0)
188
+ expect(data[2]).to eq(0)
189
+ expect(data[3]).to eq(0)
190
+ end
191
+ end
192
+
193
+ describe "branch_coverage_data_for_statement_on_line" do
194
+ it "return the array with branch hit counts for statement at a given line number" do
195
+ data = branch_coverage_file.branch_coverage_data[15]
196
+ expect(data.length).to eq(2)
197
+ expect(data[0]).to eq(1)
198
+ expect(data[1]).to eq(1)
199
+
200
+ data = branch_coverage_file.branch_coverage_data[18]
201
+ expect(data.length).to eq(2)
202
+ expect(data[0]).to eq(0)
203
+ expect(data[1]).to eq(1)
204
+
205
+ data = branch_coverage_file.branch_coverage_data[26]
206
+ expect(data.length).to eq(2)
207
+ expect(data[0]).to eq(2)
208
+ expect(data[1]).to eq(0)
209
+
210
+ data = branch_coverage_file.branch_coverage_data[29]
211
+ expect(data.length).to eq(4)
212
+ expect(data[0]).to eq(0)
213
+ expect(data[1]).to eq(0)
214
+ expect(data[2]).to eq(0)
215
+ expect(data[3]).to eq(0)
216
+ end
217
+ end
218
+
219
+ describe "num_branch_hits_for_statement_on_line" do
220
+ it "returns the number of branches executed below the statement at a given line number" do
221
+ expect(branch_coverage_file.num_branch_hits_for_statement_on_line(15)).to eq(2)
222
+ expect(branch_coverage_file.num_branch_hits_for_statement_on_line(18)).to eq(1)
223
+ expect(branch_coverage_file.num_branch_hits_for_statement_on_line(26)).to eq(1)
224
+ expect(branch_coverage_file.num_branch_hits_for_statement_on_line(29)).to eq(0)
225
+ end
226
+ end
227
+
228
+ describe "rate_branch_coverage_for_statement_on_line" do
229
+ it "returns the ratio between number of executed and number of total branches at a given line number" do
230
+ expect(branch_coverage_file.rate_branch_coverage_for_statement_on_line(15)).to eq(1.0)
231
+ expect(branch_coverage_file.rate_branch_coverage_for_statement_on_line(18)).to eq(0.5)
232
+ expect(branch_coverage_file.rate_branch_coverage_for_statement_on_line(26)).to eq(0.5)
233
+ expect(branch_coverage_file.rate_branch_coverage_for_statement_on_line(29)).to eq(0.0)
234
+ end
235
+
236
+ it "return 0.0 for a line without branch data" do
237
+ expect(branch_coverage_file.rate_branch_coverage_for_statement_on_line(1)).to eq(0.0)
238
+ end
239
+ end
240
+
241
+ describe "percentage_branch_coverage_for_statement_on_line" do
242
+ it "returns the average hit percentage of all branches below the statement at a given line number" do
243
+ expect(branch_coverage_file.percentage_branch_coverage_for_statement_on_line(15)).to eq(100)
244
+ expect(branch_coverage_file.percentage_branch_coverage_for_statement_on_line(18)).to eq(50)
245
+ expect(branch_coverage_file.percentage_branch_coverage_for_statement_on_line(26)).to eq(50)
246
+ expect(branch_coverage_file.percentage_branch_coverage_for_statement_on_line(29)).to eq(0)
247
+ end
248
+ end
249
+
250
+ describe "num_branches_testable" do
251
+ it "returns the number of testable branches inside the class" do
252
+ expect(branch_coverage_file.num_branches_testable).to eq(10)
253
+ end
254
+ end
255
+
256
+ describe "num_branches_tested" do
257
+ it "returns the number of tested branches inside the class" do
258
+ expect(branch_coverage_file.num_branches_tested).to eq(4)
137
259
  end
138
260
  end
139
261
 
262
+ describe "rate_branches_tested" do
263
+ it "returns the ratio between tested and testable branches inside the class" do
264
+ expect(branch_coverage_file.rate_branches_tested).to eq(0.4)
265
+ end
266
+ end
140
267
  end
268
+
141
269
  end
@@ -0,0 +1,38 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+ require 'json'
3
+
4
+ describe Slather::CoverageService::CoberturaXmlOutput do
5
+
6
+ let(:fixtures_project) do
7
+ proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
8
+ proj.extend(Slather::CoverageService::CoberturaXmlOutput)
9
+ end
10
+
11
+ describe '#coverage_file_class' do
12
+ it "should return CoverageFile" do
13
+ expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::CoverageFile)
14
+ end
15
+ end
16
+
17
+ describe '#post' do
18
+ it "should create an XML report spanning all coverage files" do
19
+ fixtures_project.post
20
+
21
+ file = File.open(FIXTURES_XML_PATH)
22
+ fixture_xml_doc = Nokogiri::XML(file)
23
+ file.close
24
+
25
+ file = File.open('cobertura.xml')
26
+ current_xml_doc = Nokogiri::XML(file)
27
+ file.close
28
+ current_xml_doc.root['timestamp'] = ''
29
+ current_xml_doc.root['version'] = ''
30
+ source_node = current_xml_doc.at_css "source"
31
+ source_node.content = ''
32
+
33
+ expect(current_xml_doc.to_xml).to eq(fixture_xml_doc.to_xml)
34
+
35
+ File.unlink('cobertura.xml')
36
+ end
37
+ end
38
+ end
@@ -27,7 +27,7 @@ describe Slather::CoverageService::Coveralls do
27
27
 
28
28
  it "should return valid json for coveralls coverage data" do
29
29
  fixtures_project.stub(:travis_job_id).and_return("9182")
30
- expect(fixtures_project.send(:coveralls_coverage_data)).to eq("{\"service_job_id\":\"9182\",\"service_name\":\"travis-ci\",\"source_files\":[{\"name\":\"spec/fixtures/fixtures/fixtures.m\",\"source\":\"//\\n// fixtures.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/24/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"fixtures.h\\\"\\n\\n@implementation fixtures\\n\\n- (void)testedMethod\\n{\\n NSLog(@\\\"tested\\\");\\n}\\n\\n- (void)untestedMethod\\n{\\n NSLog(@\\\"untested\\\");\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,null,null,null,0,0,null,null]},{\"name\":\"spec/fixtures/fixtures/more_files/peekaview.m\",\"source\":\"//\\n// peekaview.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/25/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"peekaview.h\\\"\\n\\n@implementation peekaview\\n\\n- (id)initWithFrame:(CGRect)frame\\n{\\n self = [super initWithFrame:frame];\\n if (self) {\\n // Initialization code\\n }\\n return self;\\n}\\n\\n/*\\n// Only override drawRect: if you perform custom drawing.\\n// An empty implementation adversely affects performance during animation.\\n- (void)drawRect:(CGRect)rect\\n{\\n // Drawing code\\n}\\n*/\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,0,null,0,0,null,0,0,0,null,null,null,null,null,null,null,null,null,null,null]},{\"name\":\"spec/fixtures/fixturesTests/fixturesTests.m\",\"source\":\"//\\n// fixturesTests.m\\n// fixturesTests\\n//\\n// Created by Mark Larsen on 6/24/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n#import \\\"fixtures.h\\\"\\n\\n@interface fixturesTests : XCTestCase\\n\\n@end\\n\\n@implementation fixturesTests\\n\\n- (void)setUp\\n{\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown\\n{\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testExample\\n{\\n fixtures *f = [[fixtures alloc] init];\\n [f testedMethod];\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,null,null,null,null,1,1,null,null,null,1,1,1,null,null]},{\"name\":\"spec/fixtures/fixturesTests/peekaviewTests.m\",\"source\":\"//\\n// peekaviewTests.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/25/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n\\n@interface peekaviewTests : XCTestCase\\n\\n@end\\n\\n@implementation peekaviewTests\\n\\n- (void)setUp\\n{\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown\\n{\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testExample\\n{\\n XCTAssert(YES, @\\\"woot\\\");\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,null,null,null,null,1,1,null,null,null,2,1,null,null]}]}")
30
+ expect(fixtures_project.send(:coveralls_coverage_data)).to eq("{\"service_job_id\":\"9182\",\"service_name\":\"travis-ci\",\"source_files\":[{\"name\":\"spec/fixtures/fixtures/more_files/Branches.m\",\"source\":\"//\\n// Branches.m\\n// fixtures\\n//\\n// Created by Julian Krumow on 11.10.14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"Branches.h\\\"\\n\\n@implementation Branches\\n\\n- (void)branches:(BOOL)goIf skipBranches:(BOOL)skipBranches\\n{\\n if (goIf) {\\n NSLog(@\\\"foo.\\\");\\n \\n if (!skipBranches) {\\n NSLog(@\\\"not skipped.\\\");\\n }\\n } else {\\n NSLog(@\\\"bar.\\\");\\n }\\n \\n int i = 5;\\n if (i == 5) {\\n return;\\n }\\n switch (i) {\\n case 0:\\n NSLog(@\\\"0\\\");\\n break;\\n \\n case 1:\\n NSLog(@\\\"1\\\");\\n break;\\n case 5:\\n NSLog(@\\\"5\\\");\\n break;\\n default:\\n break;\\n }\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,2,null,2,1,null,1,0,0,1,1,null,null,2,2,2,null,0,null,0,0,null,null,0,0,null,0,0,null,0,null,2,null,null]},{\"name\":\"spec/fixtures/fixtures/fixtures.m\",\"source\":\"//\\n// fixtures.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/24/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"fixtures.h\\\"\\n\\n@implementation fixtures\\n\\n- (void)testedMethod\\n{\\n NSLog(@\\\"tested\\\");\\n}\\n\\n- (void)untestedMethod\\n{\\n NSLog(@\\\"untested\\\");\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,null,null,null,0,0,null,null]},{\"name\":\"spec/fixtures/fixtures/more_files/peekaview.m\",\"source\":\"//\\n// peekaview.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/25/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"peekaview.h\\\"\\n\\n@implementation peekaview\\n\\n- (id)initWithFrame:(CGRect)frame\\n{\\n self = [super initWithFrame:frame];\\n if (self) {\\n // Initialization code\\n }\\n return self;\\n}\\n\\n/*\\n// Only override drawRect: if you perform custom drawing.\\n// An empty implementation adversely affects performance during animation.\\n- (void)drawRect:(CGRect)rect\\n{\\n // Drawing code\\n}\\n*/\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,0,null,0,0,null,0,0,0,null,null,null,null,null,null,null,null,null,null,null]},{\"name\":\"spec/fixtures/fixturesTests/BranchesTests.m\",\"source\":\"//\\n// BranchesTests.m\\n// fixtures\\n//\\n// Created by Julian Krumow on 11.10.14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n#import \\\"Branches.h\\\"\\n\\n@interface BranchesTests : XCTestCase\\n\\n@end\\n\\n@implementation BranchesTests\\n\\n- (void)setUp {\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown {\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testBranchesNoBranches {\\n Branches *branches = [[Branches alloc] init];\\n [branches branches:NO skipBranches:NO];\\n}\\n\\n- (void)testBranchesFirstBranchAndSkip {\\n Branches *branches = [[Branches alloc] init];\\n [branches branches:YES skipBranches:YES];\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,2,null,2,null,null,null,2,2,null,null,1,1,1,null,null,1,1,1,null,null]},{\"name\":\"spec/fixtures/fixturesTests/fixturesTests.m\",\"source\":\"//\\n// fixturesTests.m\\n// fixturesTests\\n//\\n// Created by Mark Larsen on 6/24/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n#import \\\"fixtures.h\\\"\\n\\n@interface fixturesTests : XCTestCase\\n\\n@end\\n\\n@implementation fixturesTests\\n\\n- (void)setUp\\n{\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown\\n{\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testExample\\n{\\n fixtures *f = [[fixtures alloc] init];\\n [f testedMethod];\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,null,null,null,null,1,1,null,null,null,1,1,1,null,null]},{\"name\":\"spec/fixtures/fixturesTests/peekaviewTests.m\",\"source\":\"//\\n// peekaviewTests.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/25/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n\\n@interface peekaviewTests : XCTestCase\\n\\n@end\\n\\n@implementation peekaviewTests\\n\\n- (void)setUp\\n{\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown\\n{\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testExample\\n{\\n XCTAssert(YES, @\\\"woot\\\");\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,null,null,null,null,1,1,null,null,null,2,1,null,null]}]}")
31
31
  end
32
32
 
33
33
  it "should raise an error if there is no TRAVIS_JOB_ID" do
@@ -47,7 +47,7 @@ describe Slather::CoverageService::Coveralls do
47
47
  fixtures_project.stub(:travis_job_id).and_return("9182")
48
48
  expect(fixtures_project).to receive(:`) do |cmd|
49
49
  expect(cmd).to eq("curl -s --form json_file=@coveralls_json_file https://coveralls.io/api/v1/jobs")
50
- expect(File.open('coveralls_json_file', 'r').read).to eq("{\"service_job_id\":\"9182\",\"service_name\":\"travis-ci\",\"source_files\":[{\"name\":\"spec/fixtures/fixtures/fixtures.m\",\"source\":\"//\\n// fixtures.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/24/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"fixtures.h\\\"\\n\\n@implementation fixtures\\n\\n- (void)testedMethod\\n{\\n NSLog(@\\\"tested\\\");\\n}\\n\\n- (void)untestedMethod\\n{\\n NSLog(@\\\"untested\\\");\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,null,null,null,0,0,null,null]},{\"name\":\"spec/fixtures/fixtures/more_files/peekaview.m\",\"source\":\"//\\n// peekaview.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/25/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"peekaview.h\\\"\\n\\n@implementation peekaview\\n\\n- (id)initWithFrame:(CGRect)frame\\n{\\n self = [super initWithFrame:frame];\\n if (self) {\\n // Initialization code\\n }\\n return self;\\n}\\n\\n/*\\n// Only override drawRect: if you perform custom drawing.\\n// An empty implementation adversely affects performance during animation.\\n- (void)drawRect:(CGRect)rect\\n{\\n // Drawing code\\n}\\n*/\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,0,null,0,0,null,0,0,0,null,null,null,null,null,null,null,null,null,null,null]},{\"name\":\"spec/fixtures/fixturesTests/fixturesTests.m\",\"source\":\"//\\n// fixturesTests.m\\n// fixturesTests\\n//\\n// Created by Mark Larsen on 6/24/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n#import \\\"fixtures.h\\\"\\n\\n@interface fixturesTests : XCTestCase\\n\\n@end\\n\\n@implementation fixturesTests\\n\\n- (void)setUp\\n{\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown\\n{\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testExample\\n{\\n fixtures *f = [[fixtures alloc] init];\\n [f testedMethod];\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,null,null,null,null,1,1,null,null,null,1,1,1,null,null]},{\"name\":\"spec/fixtures/fixturesTests/peekaviewTests.m\",\"source\":\"//\\n// peekaviewTests.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/25/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n\\n@interface peekaviewTests : XCTestCase\\n\\n@end\\n\\n@implementation peekaviewTests\\n\\n- (void)setUp\\n{\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown\\n{\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testExample\\n{\\n XCTAssert(YES, @\\\"woot\\\");\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,null,null,null,null,1,1,null,null,null,2,1,null,null]}]}")
50
+ expect(File.open('coveralls_json_file', 'r').read).to eq("{\"service_job_id\":\"9182\",\"service_name\":\"travis-ci\",\"source_files\":[{\"name\":\"spec/fixtures/fixtures/more_files/Branches.m\",\"source\":\"//\\n// Branches.m\\n// fixtures\\n//\\n// Created by Julian Krumow on 11.10.14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"Branches.h\\\"\\n\\n@implementation Branches\\n\\n- (void)branches:(BOOL)goIf skipBranches:(BOOL)skipBranches\\n{\\n if (goIf) {\\n NSLog(@\\\"foo.\\\");\\n \\n if (!skipBranches) {\\n NSLog(@\\\"not skipped.\\\");\\n }\\n } else {\\n NSLog(@\\\"bar.\\\");\\n }\\n \\n int i = 5;\\n if (i == 5) {\\n return;\\n }\\n switch (i) {\\n case 0:\\n NSLog(@\\\"0\\\");\\n break;\\n \\n case 1:\\n NSLog(@\\\"1\\\");\\n break;\\n case 5:\\n NSLog(@\\\"5\\\");\\n break;\\n default:\\n break;\\n }\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,2,null,2,1,null,1,0,0,1,1,null,null,2,2,2,null,0,null,0,0,null,null,0,0,null,0,0,null,0,null,2,null,null]},{\"name\":\"spec/fixtures/fixtures/fixtures.m\",\"source\":\"//\\n// fixtures.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/24/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"fixtures.h\\\"\\n\\n@implementation fixtures\\n\\n- (void)testedMethod\\n{\\n NSLog(@\\\"tested\\\");\\n}\\n\\n- (void)untestedMethod\\n{\\n NSLog(@\\\"untested\\\");\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,null,null,null,0,0,null,null]},{\"name\":\"spec/fixtures/fixtures/more_files/peekaview.m\",\"source\":\"//\\n// peekaview.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/25/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"peekaview.h\\\"\\n\\n@implementation peekaview\\n\\n- (id)initWithFrame:(CGRect)frame\\n{\\n self = [super initWithFrame:frame];\\n if (self) {\\n // Initialization code\\n }\\n return self;\\n}\\n\\n/*\\n// Only override drawRect: if you perform custom drawing.\\n// An empty implementation adversely affects performance during animation.\\n- (void)drawRect:(CGRect)rect\\n{\\n // Drawing code\\n}\\n*/\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,0,null,0,0,null,0,0,0,null,null,null,null,null,null,null,null,null,null,null]},{\"name\":\"spec/fixtures/fixturesTests/BranchesTests.m\",\"source\":\"//\\n// BranchesTests.m\\n// fixtures\\n//\\n// Created by Julian Krumow on 11.10.14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n#import \\\"Branches.h\\\"\\n\\n@interface BranchesTests : XCTestCase\\n\\n@end\\n\\n@implementation BranchesTests\\n\\n- (void)setUp {\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown {\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testBranchesNoBranches {\\n Branches *branches = [[Branches alloc] init];\\n [branches branches:NO skipBranches:NO];\\n}\\n\\n- (void)testBranchesFirstBranchAndSkip {\\n Branches *branches = [[Branches alloc] init];\\n [branches branches:YES skipBranches:YES];\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,2,null,2,null,null,null,2,2,null,null,1,1,1,null,null,1,1,1,null,null]},{\"name\":\"spec/fixtures/fixturesTests/fixturesTests.m\",\"source\":\"//\\n// fixturesTests.m\\n// fixturesTests\\n//\\n// Created by Mark Larsen on 6/24/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n#import \\\"fixtures.h\\\"\\n\\n@interface fixturesTests : XCTestCase\\n\\n@end\\n\\n@implementation fixturesTests\\n\\n- (void)setUp\\n{\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown\\n{\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testExample\\n{\\n fixtures *f = [[fixtures alloc] init];\\n [f testedMethod];\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,null,null,null,null,1,1,null,null,null,1,1,1,null,null]},{\"name\":\"spec/fixtures/fixturesTests/peekaviewTests.m\",\"source\":\"//\\n// peekaviewTests.m\\n// fixtures\\n//\\n// Created by Mark Larsen on 6/25/14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import <XCTest/XCTest.h>\\n\\n@interface peekaviewTests : XCTestCase\\n\\n@end\\n\\n@implementation peekaviewTests\\n\\n- (void)setUp\\n{\\n [super setUp];\\n // Put setup code here. This method is called before the invocation of each test method in the class.\\n}\\n\\n- (void)tearDown\\n{\\n // Put teardown code here. This method is called after the invocation of each test method in the class.\\n [super tearDown];\\n}\\n\\n- (void)testExample\\n{\\n XCTAssert(YES, @\\\"woot\\\");\\n}\\n\\n@end\\n\",\"coverage\":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,null,null,null,null,1,1,null,null,null,2,1,null,null]}]}")
51
51
  end.once
52
52
  fixtures_project.post
53
53
  end
@@ -17,9 +17,11 @@ describe Slather::CoverageService::SimpleOutput do
17
17
  it "should print out the coverage for each file, and then total coverage" do
18
18
  expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixtures/fixtures.m: 2 of 4 lines (50.00%)")
19
19
  expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixtures/more_files/peekaview.m: 0 of 6 lines (0.00%)")
20
+ expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixtures/more_files/Branches.m: 10 of 20 lines (50.00%)")
20
21
  expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixturesTests/fixturesTests.m: 7 of 7 lines (100.00%)")
21
22
  expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixturesTests/peekaviewTests.m: 6 of 6 lines (100.00%)")
22
- expect(fixtures_project).to receive(:puts).with("Test Coverage: 65.22%")
23
+ expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixturesTests/BranchesTests.m: 10 of 10 lines (100.00%)")
24
+ expect(fixtures_project).to receive(:puts).with("Test Coverage: 66.04%")
23
25
  fixtures_project.post
24
26
  end
25
27
  end
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,7 @@ require 'coveralls'
7
7
 
8
8
  Coveralls.wear!
9
9
 
10
+ FIXTURES_XML_PATH = File.join(File.dirname(__FILE__), 'fixtures/cobertura.xml')
10
11
  FIXTURES_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/gutter.json')
11
12
  FIXTURES_PROJECT_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures.xcodeproj')
12
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slather
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.19.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: nokogiri
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.6.3
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.6.3
125
139
  description:
126
140
  email:
127
141
  - mark@venmo.com
@@ -142,6 +156,7 @@ files:
142
156
  - lib/cocoapods_plugin.rb
143
157
  - lib/slather.rb
144
158
  - lib/slather/coverage_file.rb
159
+ - lib/slather/coverage_service/cobertura_xml_output.rb
145
160
  - lib/slather/coverage_service/coveralls.rb
146
161
  - lib/slather/coverage_service/gutter_json_output.rb
147
162
  - lib/slather/coverage_service/simple_output.rb
@@ -149,14 +164,18 @@ files:
149
164
  - lib/slather/project.rb
150
165
  - lib/slather/version.rb
151
166
  - slather.gemspec
167
+ - spec/fixtures/cobertura.xml
152
168
  - spec/fixtures/fixtures.xcodeproj/project.pbxproj
153
169
  - spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
154
170
  - spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixtures.xcscheme
155
171
  - spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch
156
172
  - spec/fixtures/fixtures/fixtures.h
157
173
  - spec/fixtures/fixtures/fixtures.m
174
+ - spec/fixtures/fixtures/more_files/Branches.h
175
+ - spec/fixtures/fixtures/more_files/Branches.m
158
176
  - spec/fixtures/fixtures/more_files/peekaview.h
159
177
  - spec/fixtures/fixtures/more_files/peekaview.m
178
+ - spec/fixtures/fixturesTests/BranchesTests.m
160
179
  - spec/fixtures/fixturesTests/Supporting Files/en.lproj/InfoPlist.strings
161
180
  - spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist
162
181
  - spec/fixtures/fixturesTests/fixturesTests.m
@@ -164,6 +183,7 @@ files:
164
183
  - spec/fixtures/gutter.json
165
184
  - spec/slather/cocoapods_plugin_spec.rb
166
185
  - spec/slather/coverage_file_spec.rb
186
+ - spec/slather/coverage_service/cobertura_xml_spec.rb
167
187
  - spec/slather/coverage_service/coveralls_spec.rb
168
188
  - spec/slather/coverage_service/gutter_json_spec.rb
169
189
  - spec/slather/coverage_service/simple_output_spec.rb
@@ -195,14 +215,18 @@ signing_key:
195
215
  specification_version: 4
196
216
  summary: Test coverage reports for Xcode projects
197
217
  test_files:
218
+ - spec/fixtures/cobertura.xml
198
219
  - spec/fixtures/fixtures.xcodeproj/project.pbxproj
199
220
  - spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
200
221
  - spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixtures.xcscheme
201
222
  - spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch
202
223
  - spec/fixtures/fixtures/fixtures.h
203
224
  - spec/fixtures/fixtures/fixtures.m
225
+ - spec/fixtures/fixtures/more_files/Branches.h
226
+ - spec/fixtures/fixtures/more_files/Branches.m
204
227
  - spec/fixtures/fixtures/more_files/peekaview.h
205
228
  - spec/fixtures/fixtures/more_files/peekaview.m
229
+ - spec/fixtures/fixturesTests/BranchesTests.m
206
230
  - spec/fixtures/fixturesTests/Supporting Files/en.lproj/InfoPlist.strings
207
231
  - spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist
208
232
  - spec/fixtures/fixturesTests/fixturesTests.m
@@ -210,6 +234,7 @@ test_files:
210
234
  - spec/fixtures/gutter.json
211
235
  - spec/slather/cocoapods_plugin_spec.rb
212
236
  - spec/slather/coverage_file_spec.rb
237
+ - spec/slather/coverage_service/cobertura_xml_spec.rb
213
238
  - spec/slather/coverage_service/coveralls_spec.rb
214
239
  - spec/slather/coverage_service/gutter_json_spec.rb
215
240
  - spec/slather/coverage_service/simple_output_spec.rb