slather 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b74146844eaeb36f2504f1b3d68e590a5e10144d
4
- data.tar.gz: baed92208b8cba0525eb4c7ed9a0089f5f6d28de
3
+ metadata.gz: c81c8298dd7e5d03d440067813e42429f437f230
4
+ data.tar.gz: 01deae864fd161f898c75d90b8c7eaab9bf4d4b5
5
5
  SHA512:
6
- metadata.gz: 12c63ac37efb3a93bff26f71990a532ce0bc93d98fdca7f637e214b3eb7bdcaf67ad400a57f933241cf01e66f7db32a42d4971c21c9ddd69678cc69cb639384a
7
- data.tar.gz: be09f2c02c71ca463bab39d56515b2d5de22d54ab3546950dd370a05daf5618f264cf4aeb46d02d5bd52d06cc5a121b792d524f1a5bcc75a68dd97cb6f4c563d
6
+ metadata.gz: fb215d533208cd99d38b18481bb11e91dc40a6db8e5e43d601229d26108d56e5fef118cc2d3aa3296459c7e7adaad8d2bc5d5886a852c30e219a1c7114ede654
7
+ data.tar.gz: a630985a0f07c4d32e158246f43e5c6e2cc2296e6944020a0f2db716d17d846256c6be4b30417e6dcf09d9bb64cc7435f9ad5ec116d8d3bb2a1797556f9f6865
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## v1.6.0
6
+
7
+ * Add an option to define the output directory for cobertura xml reports
8
+ [Julian Krumow](https://github.com/tarbrain)
9
+ [#37](https://github.com/venmo/slather/pull/37)
10
+
5
11
  ## v1.5.1
6
12
 
7
13
  * Avoid crashes when coverage data is empty
data/README.md CHANGED
@@ -72,24 +72,39 @@ install: bundle install --without=documentation --path ../travis_bundle_dir
72
72
  after_success: slather
73
73
  ```
74
74
 
75
+ #### Travis CI Pro
76
+
77
+ To use Coveralls with Travis CI Pro (for private repos), add following lines along with other settings to `.slather.yml`:
78
+
79
+ ```yml
80
+ # .slather.yml
81
+
82
+ ci_service: travis_pro
83
+ ci_access_token: <YOUR ACCESS TOKEN>
84
+ ```
85
+
86
+ Repo token can be found at https://coveralls.io/ repo page.
87
+
75
88
  ### Cobertura
76
89
 
77
- To create a Cobertura XML report set `cobertura_xml` as coverage service inside your `.slather.yml`:
90
+ To create a Cobertura XML report set `cobertura_xml` as coverage service inside your `.slather.yml`. Optionally you can define an output directory for the XML report:
78
91
 
79
92
  ```yml
80
93
  # .slather.yml
81
94
 
82
95
  coverage_service: cobertura_xml
83
96
  xcodeproj: path/to/project.xcodeproj
97
+ source_directory: path/to/sources/to/include
98
+ output_directory: path/to/xml_report
84
99
  ignore:
85
100
  - ExamplePodCode/*
86
101
  - ProjectTestsGroup/*
87
102
  ```
88
103
 
89
- Or use the command line options `--cobertura-xml` or `-x`:
104
+ Or use the command line options `--cobertura-xml` or `-x` and `--output_directory`:
90
105
 
91
106
  ```sh
92
- $ slather coverage -x
107
+ $ slather coverage -x --output-directory path/to/xml_report
93
108
  ```
94
109
 
95
110
  ### Coverage for code included via CocoaPods
data/bin/slather CHANGED
@@ -20,6 +20,7 @@ Clamp do
20
20
 
21
21
  option ["--build-directory", "-b"], "BUILD_DIRECTORY", "The directory where gcno files will be written to. Defaults to derived data."
22
22
  option ["--source-directory"], "SOURCE_DIRECTORY", "The directory where your source files are located."
23
+ option ["--output-directory"], "OUTPUT_DIRECTORY", "The directory where your Cobertura XML report will be written to."
23
24
  option ["--ignore", "-i"], "IGNORE", "ignore files conforming to a path", :multivalued => true
24
25
 
25
26
  def execute
@@ -29,6 +30,7 @@ Clamp do
29
30
  setup_ignore_list
30
31
  setup_build_directory
31
32
  setup_source_directory
33
+ setup_output_directory
32
34
  setup_coverage_service
33
35
 
34
36
  post
@@ -44,6 +46,10 @@ Clamp do
44
46
  project.source_directory = source_directory if source_directory
45
47
  end
46
48
 
49
+ def setup_output_directory
50
+ project.output_directory = output_directory if output_directory
51
+ end
52
+
47
53
  def setup_ignore_list
48
54
  project.ignore_list = ignore_list if !ignore_list.empty?
49
55
  end
@@ -11,9 +11,16 @@ module Slather
11
11
 
12
12
  def post
13
13
  cobertura_xml_report = create_xml_report(coverage_files)
14
- File.open('cobertura.xml', 'w') { |file|
15
- file.write(cobertura_xml_report.to_s)
16
- }
14
+ store_report(cobertura_xml_report)
15
+ end
16
+
17
+ def store_report(report)
18
+ output_file = 'cobertura.xml'
19
+ if output_directory
20
+ FileUtils.mkdir_p(output_directory)
21
+ output_file = File.join(output_directory, output_file)
22
+ end
23
+ File.write(output_file, report.to_s)
17
24
  end
18
25
 
19
26
  def grouped_coverage_files
@@ -13,13 +13,22 @@ module Slather
13
13
  private :travis_job_id
14
14
 
15
15
  def coveralls_coverage_data
16
- if ci_service == :travis_ci
16
+ if ci_service == :travis_ci || ci_service == :travis_pro
17
17
  if travis_job_id
18
- {
19
- :service_job_id => travis_job_id,
20
- :service_name => "travis-ci",
21
- :source_files => coverage_files.map(&:as_json)
22
- }.to_json
18
+ if ci_service == :travis_ci
19
+ {
20
+ :service_job_id => travis_job_id,
21
+ :service_name => "travis-ci",
22
+ :source_files => coverage_files.map(&:as_json)
23
+ }.to_json
24
+ elsif ci_service == :travis_pro
25
+ {
26
+ :service_job_id => travis_job_id,
27
+ :service_name => "travis-pro",
28
+ :repo_token => ci_access_token,
29
+ :source_files => coverage_files.map(&:as_json)
30
+ }.to_json
31
+ end
23
32
  else
24
33
  raise StandardError, "Environment variable `TRAVIS_JOB_ID` not set. Is this running on a travis build?"
25
34
  end
@@ -19,7 +19,7 @@ end
19
19
  module Slather
20
20
  class Project < Xcodeproj::Project
21
21
 
22
- attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service, :source_directory
22
+ attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service, :ci_access_token, :source_directory, :output_directory
23
23
 
24
24
  alias_method :setup_for_coverage, :slather_setup_for_coverage
25
25
 
@@ -70,8 +70,10 @@ module Slather
70
70
  configure_build_directory_from_yml
71
71
  configure_ignore_list_from_yml
72
72
  configure_ci_service_from_yml
73
+ configure_ci_access_token_from_yml
73
74
  configure_coverage_service_from_yml
74
75
  configure_source_directory_from_yml
76
+ configure_output_directory_from_yml
75
77
  end
76
78
 
77
79
  def configure_build_directory_from_yml
@@ -82,6 +84,10 @@ module Slather
82
84
  self.source_directory ||= self.class.yml["source_directory"] if self.class.yml["source_directory"]
83
85
  end
84
86
 
87
+ def configure_output_directory_from_yml
88
+ self.output_directory ||= self.class.yml["output_directory"] if self.class.yml["output_directory"]
89
+ end
90
+
85
91
  def configure_ignore_list_from_yml
86
92
  self.ignore_list ||= [(self.class.yml["ignore"] || [])].flatten
87
93
  end
@@ -98,6 +104,10 @@ module Slather
98
104
  self.coverage_service ||= (self.class.yml["coverage_service"] || :terminal)
99
105
  end
100
106
 
107
+ def configure_ci_access_token_from_yml
108
+ self.ci_access_token ||= (self.class.yml["ci_access_token"] || "")
109
+ end
110
+
101
111
  def coverage_service=(service)
102
112
  service = service && service.to_sym
103
113
  if service == :coveralls
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
data/slather.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rspec", "~> 2.14"
24
24
  spec.add_development_dependency "pry", "~> 0.9"
25
25
  spec.add_development_dependency "cocoapods", "~> 0.34"
26
+ spec.add_development_dependency "json_spec", "~> 1.1.4"
26
27
 
27
28
  spec.add_dependency "clamp", "~> 0.6"
28
29
  spec.add_dependency "xcodeproj", "~> 0.19.2"
@@ -12,7 +12,7 @@ describe Slather::CoverageFile do
12
12
 
13
13
  describe "#initialize" do
14
14
  it "should convert the provided path string to a Pathname object, and set it as the gcno_file_pathname" do
15
- expect(coverage_file.gcno_file_pathname.exist?).to be_truthy
15
+ expect(coverage_file.gcno_file_pathname).to be_exist
16
16
  expect(coverage_file.gcno_file_pathname.basename.to_s).to eq("fixtures.gcno")
17
17
  end
18
18
  end
@@ -43,7 +43,7 @@ describe Slather::CoverageFile do
43
43
  describe "#source_file" do
44
44
  it "should return a file object for the source_file_pathname" do
45
45
  file = coverage_file.source_file
46
- expect(file.kind_of?(File)).to be_truthy
46
+ expect(file).to be_a File
47
47
  expect(Pathname(file.path)).to eq(coverage_file.source_file_pathname)
48
48
  end
49
49
  end
@@ -94,18 +94,18 @@ OBJC
94
94
  describe "#ignored" do
95
95
  it "should return true if the source_file_pathname globs against anything in the project.ignore_list" do
96
96
  coverage_file.project.ignore_list = ["*spec*", "*test*"]
97
- expect(coverage_file.ignored?).to be_truthy
97
+ expect(coverage_file).to be_ignored
98
98
  end
99
99
 
100
100
  it "should return false if the source_file_pathname does not glob against anything in the project.ignore_list" do
101
101
  coverage_file.project.ignore_list = ["*test*", "*XCTest*"]
102
- expect(coverage_file.ignored?).to be_falsy
102
+ expect(coverage_file).not_to be_ignored
103
103
  end
104
104
  end
105
105
 
106
106
  describe "gcov_data" do
107
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
108
+ expect(coverage_file.gcov_data).to include("1: 15: NSLog(@\"tested\");")
109
109
  end
110
110
  end
111
111
 
@@ -34,5 +34,15 @@ describe Slather::CoverageService::CoberturaXmlOutput do
34
34
 
35
35
  File.unlink('cobertura.xml')
36
36
  end
37
+
38
+ it "should create an XML report in the given output directory" do
39
+ fixtures_project.output_directory = "./output"
40
+ fixtures_project.post
41
+
42
+ filepath = "#{fixtures_project.output_directory}/cobertura.xml"
43
+ expect(File.exists?(filepath)).to be_truthy
44
+
45
+ FileUtils.rm_rf(fixtures_project.output_directory)
46
+ end
37
47
  end
38
48
  end
@@ -27,7 +27,24 @@ 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/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/more_files/Empty.m\",\"source\":\"//\\n// Empty.m\\n// fixtures\\n//\\n// Created by Julian Krumow on 27.10.14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"Empty.h\\\"\\n\\n@implementation Empty\\n\\n@end\\n\",\"coverage\":[]},{\"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]}]}")
30
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql("{\"service_job_id\":\"9182\",\"service_name\":\"travis-ci\"}").excluding("source_files")
31
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql(fixtures_project.send(:coverage_files).map(&:as_json).to_json).at_path("source_files")
32
+ end
33
+
34
+ it "should raise an error if there is no TRAVIS_JOB_ID" do
35
+ fixtures_project.stub(:travis_job_id).and_return(nil)
36
+ expect { fixtures_project.send(:coveralls_coverage_data) }.to raise_error(StandardError)
37
+ end
38
+ end
39
+
40
+ context "coverage_service is :travis_pro" do
41
+ before(:each) { fixtures_project.ci_service = :travis_pro }
42
+
43
+ it "should return valid json for coveralls coverage data" do
44
+ fixtures_project.stub(:travis_job_id).and_return("9182")
45
+ fixtures_project.stub(:ci_access_token).and_return("abc123")
46
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql("{\"service_job_id\":\"9182\",\"service_name\":\"travis-pro\",\"repo_token\":\"abc123\"}").excluding("source_files")
47
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql(fixtures_project.send(:coverage_files).map(&:as_json).to_json).at_path("source_files")
31
48
  end
32
49
 
33
50
  it "should raise an error if there is no TRAVIS_JOB_ID" do
@@ -47,7 +64,7 @@ describe Slather::CoverageService::Coveralls do
47
64
  fixtures_project.stub(:travis_job_id).and_return("9182")
48
65
  expect(fixtures_project).to receive(:`) do |cmd|
49
66
  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/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/more_files/Empty.m\",\"source\":\"//\\n// Empty.m\\n// fixtures\\n//\\n// Created by Julian Krumow on 27.10.14.\\n// Copyright (c) 2014 marklarr. All rights reserved.\\n//\\n\\n#import \\\"Empty.h\\\"\\n\\n@implementation Empty\\n\\n@end\\n\",\"coverage\":[]},{\"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]}]}")
67
+ expect(File.read('coveralls_json_file')).to be_json_eql(fixtures_project.send(:coveralls_coverage_data))
51
68
  end.once
52
69
  fixtures_project.post
53
70
  end
@@ -18,13 +18,10 @@ describe Slather::CoverageService::GutterJsonOutput do
18
18
  it "should print out the coverage for each file, and then total coverage" do
19
19
  fixtures_project.post
20
20
 
21
- fixture_json = JSON.parse(File.read(FIXTURES_JSON_PATH))
22
- fixture_json['meta']['timestamp'] = ''
21
+ fixture_json = File.read(FIXTURES_JSON_PATH)
22
+ current_json = File.read('.gutter.json')
23
23
 
24
- current_json = JSON.parse(File.read('.gutter.json'))
25
- current_json['meta']['timestamp'] = ''
26
-
27
- expect(current_json).to eq(fixture_json)
24
+ expect(current_json).to be_json_eql(fixture_json)
28
25
  File.unlink('.gutter.json')
29
26
  end
30
27
  end
@@ -15,14 +15,17 @@ describe Slather::CoverageService::SimpleOutput do
15
15
 
16
16
  describe '#post' do
17
17
  it "should print out the coverage for each file, and then total coverage" do
18
- expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixtures/fixtures.m: 2 of 4 lines (50.00%)")
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%)")
21
- expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixtures/more_files/Empty.m: 0 of 0 lines (0.00%)")
22
- expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixturesTests/fixturesTests.m: 7 of 7 lines (100.00%)")
23
- expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixturesTests/peekaviewTests.m: 6 of 6 lines (100.00%)")
24
- expect(fixtures_project).to receive(:puts).with("spec/fixtures/fixturesTests/BranchesTests.m: 10 of 10 lines (100.00%)")
25
- expect(fixtures_project).to receive(:puts).with("Test Coverage: 66.04%")
18
+ ["spec/fixtures/fixtures/fixtures.m: 2 of 4 lines (50.00%)",
19
+ "spec/fixtures/fixtures/more_files/peekaview.m: 0 of 6 lines (0.00%)",
20
+ "spec/fixtures/fixtures/more_files/Branches.m: 10 of 20 lines (50.00%)",
21
+ "spec/fixtures/fixtures/more_files/Empty.m: 0 of 0 lines (0.00%)",
22
+ "spec/fixtures/fixturesTests/fixturesTests.m: 7 of 7 lines (100.00%)",
23
+ "spec/fixtures/fixturesTests/peekaviewTests.m: 6 of 6 lines (100.00%)",
24
+ "spec/fixtures/fixturesTests/BranchesTests.m: 10 of 10 lines (100.00%)",
25
+ "Test Coverage: 66.04%"].each do |line|
26
+ expect(fixtures_project).to receive(:puts).with(line)
27
+ end
28
+
26
29
  fixtures_project.post
27
30
  end
28
31
  end
@@ -179,6 +179,21 @@ describe Slather::Project do
179
179
  end
180
180
  end
181
181
 
182
+ describe "#configure_output_directory_from_yml" do
183
+ it "should set the output_directory if it has been provided in the yml and has not already been set" do
184
+ Slather::Project.stub(:yml).and_return({"output_directory" => "/some/path"})
185
+ fixtures_project.configure_output_directory_from_yml
186
+ expect(fixtures_project.output_directory).to eq("/some/path")
187
+ end
188
+
189
+ it "should not set the output_directory if it has already been set" do
190
+ Slather::Project.stub(:yml).and_return({"output_directory" => "/some/path"})
191
+ fixtures_project.output_directory = "/already/set"
192
+ fixtures_project.configure_output_directory_from_yml
193
+ expect(fixtures_project.output_directory).to eq("/already/set")
194
+ end
195
+ end
196
+
182
197
  describe "#configure_ci_service_from_yml" do
183
198
  it "should set the ci_service if it has been provided in the yml and has not already been set" do
184
199
  Slather::Project.stub(:yml).and_return({"ci_service" => "some_service"})
@@ -228,6 +243,14 @@ describe Slather::Project do
228
243
  end
229
244
  end
230
245
 
246
+ describe "#configure_ci_access_token_from_yml" do
247
+ it "should set the ci_access_token if it has been provided by the yml" do
248
+ Slather::Project.stub(:yml).and_return({"ci_access_token" => "abc123"})
249
+ expect(fixtures_project).to receive(:ci_access_token=).with("abc123")
250
+ fixtures_project.configure_ci_access_token_from_yml
251
+ end
252
+ end
253
+
231
254
  describe "#coverage_service=" do
232
255
  it "should extend Slather::CoverageService::Coveralls and set coverage_service = :coveralls if given coveralls" do
233
256
  expect(fixtures_project).to receive(:extend).with(Slather::CoverageService::Coveralls)
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ Bundler.setup
4
4
  require 'slather'
5
5
  require 'pry'
6
6
  require 'coveralls'
7
+ require 'json_spec'
7
8
 
8
9
  Coveralls.wear!
9
10
 
@@ -16,3 +17,7 @@ RSpec.configure do |config|
16
17
  FileUtils.rm_rf(Dir[File.expand_path('~') + "/Library/Developer/Xcode/DerivedData/fixture*"].first)
17
18
  end
18
19
  end
20
+
21
+ JsonSpec.configure do
22
+ exclude_keys "timestamp"
23
+ end
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.5.1
4
+ version: 1.5.2
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-11-03 00:00:00.000000000 Z
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.34'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json_spec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.1.4
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.1.4
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: clamp
99
113
  requirement: !ruby/object:Gem::Requirement