slather 0.0.235 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +13 -5
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +18 -0
  4. data/.travis.yml +20 -0
  5. data/README.md +59 -11
  6. data/bin/slather +11 -8
  7. data/docs/logo.jpg +0 -0
  8. data/lib/slather/coverage_file.rb +6 -5
  9. data/lib/slather/coverage_service/coveralls.rb +11 -2
  10. data/lib/slather/coverage_service/simple_output.rb +1 -0
  11. data/lib/slather/project.rb +43 -27
  12. data/lib/slather/version.rb +1 -1
  13. data/scripts/travis.sh +2 -0
  14. data/slather.gemspec +1 -0
  15. data/spec/fixtures/fixtures.xcodeproj/project.pbxproj +452 -0
  16. data/spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  17. data/spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixtures.xcscheme +69 -0
  18. data/spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch +9 -0
  19. data/spec/fixtures/fixtures/fixtures.h +16 -0
  20. data/spec/fixtures/fixtures/fixtures.m +23 -0
  21. data/spec/fixtures/fixtures/more_files/peekaview.h +13 -0
  22. data/spec/fixtures/fixtures/more_files/peekaview.m +31 -0
  23. data/spec/fixtures/fixturesTests/Supporting Files/en.lproj/InfoPlist.strings +2 -0
  24. data/spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist +22 -0
  25. data/spec/fixtures/fixturesTests/fixturesTests.m +36 -0
  26. data/spec/fixtures/fixturesTests/peekaviewTests.m +34 -0
  27. data/spec/slather/coverage_file_spec.rb +106 -0
  28. data/spec/slather/coverage_service/coveralls_spec.rb +66 -0
  29. data/spec/slather/coverage_service/simple_output_spec.rb +26 -0
  30. data/spec/slather/fixtures.gcno +0 -0
  31. data/spec/slather/project_spec.rb +219 -0
  32. data/spec/spec_helper.rb +16 -0
  33. metadata +73 -18
@@ -0,0 +1,26 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Slather::CoverageService::SimpleOutput do
4
+
5
+ let(:fixtures_project) do
6
+ proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
7
+ proj.extend(Slather::CoverageService::SimpleOutput)
8
+ end
9
+
10
+ describe '#coverage_file_class' do
11
+ it "should return CoverallsCoverageFile" do
12
+ expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::CoverallsCoverageFile)
13
+ end
14
+ end
15
+
16
+ describe '#post' do
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/fixturesTests/fixturesTests.m: 7 of 7 lines (100.00%)")
21
+ 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
+ fixtures_project.post
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,219 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Slather::Project do
4
+
5
+ let(:fixtures_project) do
6
+ Slather::Project.any_instance.stub(:configure_from_yml)
7
+ Slather::Project.open(FIXTURES_PROJECT_PATH)
8
+ end
9
+
10
+ describe "::open" do
11
+ it "should return a project instance that has been configured from yml" do
12
+ expect_any_instance_of(Slather::Project).to receive(:configure_from_yml)
13
+ expect(fixtures_project).not_to be_nil
14
+ end
15
+ end
16
+
17
+ describe "#derived_data_dir" do
18
+ it "should return the system's derived data directory" do
19
+ expect(fixtures_project.send(:derived_data_dir)).to eq(File.expand_path('~') + "/Library/Developer/Xcode/DerivedData/")
20
+ end
21
+ end
22
+
23
+ describe "#build_directory" do
24
+ it "should return the build_directory property, if it has been explicitly set" do
25
+ build_directory_mock = double(String)
26
+ fixtures_project.build_directory = build_directory_mock
27
+ expect(fixtures_project.build_directory).to eq(build_directory_mock)
28
+ end
29
+
30
+ it "should return the derived_data_dir if no build_directory has been set" do
31
+ derived_data_dir_mock = double(String)
32
+ fixtures_project.stub(:derived_data_dir).and_return(derived_data_dir_mock)
33
+ expect(fixtures_project.build_directory).to eq(derived_data_dir_mock)
34
+ end
35
+ end
36
+
37
+ describe "::yml" do
38
+ before(:each) { Slather::Project.instance_variable_set("@yml", nil) }
39
+
40
+ context ".slather.yml file exists" do
41
+ before(:all) { File.open(".slather.yml", "w") { |f| f.write("two: 2") } }
42
+ after(:all) { File.delete(".slather.yml") }
43
+
44
+ it "should load and return .slather.yml, if it exists" do
45
+ expect(Slather::Project.yml).to eq({"two" => 2})
46
+ end
47
+ end
48
+
49
+ context ".slather.yml file doesn't exist" do
50
+ it "should return an empy hash" do
51
+ expect(Slather::Project.yml).to eq({})
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "#coverage_files" do
57
+ class SpecCoverageFile < Slather::CoverageFile
58
+ end
59
+
60
+ before(:each) do
61
+ Dir.stub(:[]).and_call_original
62
+ Dir.stub(:[]).with("#{fixtures_project.build_directory}/**/*.gcno").and_return(["/some/path/fixtures.gcno",
63
+ "/some/path/peekaview.gcno",
64
+ "/some/path/fixturesTests.gcno",
65
+ "/some/path/peekaviewTests.gcno",
66
+ "/some/path/NotInProject.gcno",
67
+ "/some/path/NSRange.gcno"])
68
+ fixtures_project.stub(:coverage_file_class).and_return(SpecCoverageFile)
69
+ end
70
+
71
+ it "should return coverage file objects of type coverage_file_class for unignored project files" do
72
+ fixtures_project.ignore_list = ["*fixturesTests*"]
73
+ coverage_files = fixtures_project.send(:coverage_files)
74
+ coverage_files.each { |cf| expect(cf.kind_of?(SpecCoverageFile)).to be_truthy }
75
+ expect(coverage_files.map { |cf| cf.source_file_pathname.basename.to_s }).to eq(["fixtures.m", "peekaview.m"])
76
+ end
77
+
78
+ it "should raise an exception if no unignored project coverage file files were found" do
79
+ fixtures_project.ignore_list = ["*fixturesTests*", "*fixtures*"]
80
+ expect {fixtures_project.send(:coverage_files)}.to raise_error(StandardError)
81
+ end
82
+ end
83
+
84
+ describe "#configure_from_yml" do
85
+ it "should configure all properties from the yml" do
86
+ unstubbed_project = Slather::Project.open(FIXTURES_PROJECT_PATH)
87
+ expect(unstubbed_project).to receive(:configure_build_directory_from_yml)
88
+ expect(unstubbed_project).to receive(:configure_ignore_list_from_yml)
89
+ expect(unstubbed_project).to receive(:configure_ci_service_from_yml)
90
+ expect(unstubbed_project).to receive(:configure_coverage_service_from_yml)
91
+ unstubbed_project.configure_from_yml
92
+ end
93
+ end
94
+
95
+ describe "#configure_ignore_list_from_yml" do
96
+ it "should set the ignore_list if it has been provided in the yml and has not already been set" do
97
+ Slather::Project.stub(:yml).and_return({"ignore" => ["test", "ing"] })
98
+ fixtures_project.configure_ignore_list_from_yml
99
+ expect(fixtures_project.ignore_list).to eq(["test", "ing"])
100
+ end
101
+
102
+ it "should force the ignore_list into an array" do
103
+ Slather::Project.stub(:yml).and_return({"ignore" => "test" })
104
+ fixtures_project.configure_ignore_list_from_yml
105
+ expect(fixtures_project.ignore_list).to eq(["test"])
106
+ end
107
+
108
+ it "should not set the ignore_list if it has already been set" do
109
+ Slather::Project.stub(:yml).and_return({"ignore" => ["test", "ing"] })
110
+ fixtures_project.ignore_list = ["already", "set"]
111
+ fixtures_project.configure_ignore_list_from_yml
112
+ expect(fixtures_project.ignore_list).to eq(["already", "set"])
113
+ end
114
+
115
+ it "should default the ignore_list to an empty array if nothing is provided in the yml" do
116
+ Slather::Project.stub(:yml).and_return({})
117
+ fixtures_project.configure_ignore_list_from_yml
118
+ expect(fixtures_project.ignore_list).to eq([])
119
+ end
120
+ end
121
+
122
+ describe "#configure_build_directory_from_yml" do
123
+ it "should set the build_directory if it has been provided in the yml and has not already been set" do
124
+ Slather::Project.stub(:yml).and_return({"build_directory" => "/some/path"})
125
+ fixtures_project.configure_build_directory_from_yml
126
+ expect(fixtures_project.build_directory).to eq("/some/path")
127
+ end
128
+
129
+ it "should not set the build_directory if it has already been set" do
130
+ Slather::Project.stub(:yml).and_return({"build_directory" => "/some/path"})
131
+ fixtures_project.build_directory = "/already/set"
132
+ fixtures_project.configure_build_directory_from_yml
133
+ expect(fixtures_project.build_directory).to eq("/already/set")
134
+ end
135
+
136
+ it "should default the build_directory to derived data if nothing is provided in the yml" do
137
+ Slather::Project.stub(:yml).and_return({})
138
+ fixtures_project.configure_build_directory_from_yml
139
+ expect(fixtures_project.build_directory).to eq(fixtures_project.send(:derived_data_dir))
140
+ end
141
+ end
142
+
143
+ describe "#configure_ci_service_from_yml" do
144
+ it "should set the ci_service if it has been provided in the yml and has not already been set" do
145
+ Slather::Project.stub(:yml).and_return({"ci_service" => "some_service"})
146
+ fixtures_project.configure_ci_service_from_yml
147
+ expect(fixtures_project.ci_service).to eq(:some_service)
148
+ end
149
+
150
+ it "should not set the ci_service if it has already been set" do
151
+ Slather::Project.stub(:yml).and_return({"ci_service" => "some service"})
152
+ fixtures_project.ci_service = "already_set"
153
+ fixtures_project.configure_ci_service_from_yml
154
+ expect(fixtures_project.ci_service).to eq(:already_set)
155
+ end
156
+
157
+ it "should default the ci_service to :travis_ci if nothing is provided in the yml" do
158
+ Slather::Project.stub(:yml).and_return({})
159
+ fixtures_project.configure_ci_service_from_yml
160
+ expect(fixtures_project.ci_service).to eq(:travis_ci)
161
+ end
162
+ end
163
+
164
+ describe "#ci_service=" do
165
+ it "should set the ci_service as a symbol" do
166
+ fixtures_project.ci_service = "foobar"
167
+ expect(fixtures_project.ci_service).to eq(:foobar)
168
+ end
169
+ end
170
+
171
+ describe "#configure_coverage_service_from_yml" do
172
+ it "should set the coverage_service if it has been provided by the yml" do
173
+ Slather::Project.stub(:yml).and_return({"coverage_service" => "some_service"})
174
+ expect(fixtures_project).to receive(:coverage_service=).with("some_service")
175
+ fixtures_project.configure_coverage_service_from_yml
176
+ end
177
+
178
+ it "should default the coverage_service to :terminal if nothing is provided in the yml" do
179
+ Slather::Project.stub(:yml).and_return({})
180
+ expect(fixtures_project).to receive(:coverage_service=).with(:terminal)
181
+ fixtures_project.configure_coverage_service_from_yml
182
+ end
183
+
184
+ it "should not set the coverage_service if it has already been set" do
185
+ Slather::Project.stub(:yml).and_return({"coverage_service" => "some_service" })
186
+ fixtures_project.stub(:coverage_service).and_return("already set")
187
+ expect(fixtures_project).to_not receive(:coverage_service=)
188
+ fixtures_project.configure_coverage_service_from_yml
189
+ end
190
+ end
191
+
192
+ describe "#coverage_service=" do
193
+ it "should extend Slather::CoverageService::Coveralls and set coverage_service = :coveralls if given coveralls" do
194
+ expect(fixtures_project).to receive(:extend).with(Slather::CoverageService::Coveralls)
195
+ fixtures_project.coverage_service = "coveralls"
196
+ expect(fixtures_project.coverage_service).to eq(:coveralls)
197
+ end
198
+
199
+ it "should extend Slather::CoverageService::SimpleOutput and set coverage_service = :terminal if given terminal" do
200
+ expect(fixtures_project).to receive(:extend).with(Slather::CoverageService::SimpleOutput)
201
+ fixtures_project.coverage_service = "terminal"
202
+ expect(fixtures_project.coverage_service).to eq(:terminal)
203
+ end
204
+
205
+ it "should raise an exception if it does not recognize the coverage service" do
206
+ expect { fixtures_project.coverage_service = "xcode bots, lol" }.to raise_error(StandardError)
207
+ end
208
+ end
209
+
210
+ describe "#setup_for_coverage" do
211
+ it "should enable the correct flags to generate test coverage on all of the build_configurations build settings" do
212
+ fixtures_project.setup_for_coverage
213
+ fixtures_project.build_configurations.each do |build_configuration|
214
+ expect(build_configuration.build_settings["GCC_INSTRUMENT_PROGRAM_FLOW_ARCS"]).to eq("YES")
215
+ expect(build_configuration.build_settings["GCC_GENERATE_TEST_COVERAGE_FILES"]).to eq("YES")
216
+ end
217
+ end
218
+ end
219
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'slather'
5
+ require 'pry'
6
+ require 'coveralls'
7
+
8
+ Coveralls.wear!
9
+
10
+ FIXTURES_PROJECT_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures.xcodeproj')
11
+
12
+ RSpec.configure do |config|
13
+ config.after(:suite) do
14
+ FileUtils.rm_rf(Dir[File.expand_path('~') + "/Library/Developer/Xcode/DerivedData/fixture*"].first)
15
+ end
16
+ end
metadata CHANGED
@@ -1,97 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.235
4
+ version: 1.0.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-06-21 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ~>
32
46
  - !ruby/object:Gem::Version
33
47
  version: '10.3'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ~>
39
53
  - !ruby/object:Gem::Version
40
54
  version: '10.3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ~>
46
60
  - !ruby/object:Gem::Version
47
61
  version: '2.14'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ~>
53
67
  - !ruby/object:Gem::Version
54
68
  version: '2.14'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: pry
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ~>
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0.9'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ~>
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0.9'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: clamp
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ~>
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0.6'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ~>
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0.6'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: xcodeproj
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ~>
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0.17'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ~>
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0.17'
97
111
  description:
@@ -102,12 +116,15 @@ executables:
102
116
  extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
105
- - ".gitignore"
119
+ - .coveralls.yml
120
+ - .gitignore
121
+ - .travis.yml
106
122
  - Gemfile
107
123
  - LICENSE.txt
108
124
  - README.md
109
125
  - Rakefile
110
126
  - bin/slather
127
+ - docs/logo.jpg
111
128
  - lib/slather.rb
112
129
  - lib/slather/coverage_file.rb
113
130
  - lib/slather/coverage_service/coveralls.rb
@@ -115,7 +132,26 @@ files:
115
132
  - lib/slather/coveralls_coverage_file.rb
116
133
  - lib/slather/project.rb
117
134
  - lib/slather/version.rb
135
+ - scripts/travis.sh
118
136
  - slather.gemspec
137
+ - spec/fixtures/fixtures.xcodeproj/project.pbxproj
138
+ - spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
139
+ - spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixtures.xcscheme
140
+ - spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch
141
+ - spec/fixtures/fixtures/fixtures.h
142
+ - spec/fixtures/fixtures/fixtures.m
143
+ - spec/fixtures/fixtures/more_files/peekaview.h
144
+ - spec/fixtures/fixtures/more_files/peekaview.m
145
+ - spec/fixtures/fixturesTests/Supporting Files/en.lproj/InfoPlist.strings
146
+ - spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist
147
+ - spec/fixtures/fixturesTests/fixturesTests.m
148
+ - spec/fixtures/fixturesTests/peekaviewTests.m
149
+ - spec/slather/coverage_file_spec.rb
150
+ - spec/slather/coverage_service/coveralls_spec.rb
151
+ - spec/slather/coverage_service/simple_output_spec.rb
152
+ - spec/slather/fixtures.gcno
153
+ - spec/slather/project_spec.rb
154
+ - spec/spec_helper.rb
119
155
  homepage: https://github.com/marklarr/slather
120
156
  licenses:
121
157
  - MIT
@@ -126,12 +162,12 @@ require_paths:
126
162
  - lib
127
163
  required_ruby_version: !ruby/object:Gem::Requirement
128
164
  requirements:
129
- - - ">="
165
+ - - ! '>='
130
166
  - !ruby/object:Gem::Version
131
167
  version: '0'
132
168
  required_rubygems_version: !ruby/object:Gem::Requirement
133
169
  requirements:
134
- - - ">="
170
+ - - ! '>='
135
171
  - !ruby/object:Gem::Version
136
172
  version: '0'
137
173
  requirements: []
@@ -140,4 +176,23 @@ rubygems_version: 2.2.2
140
176
  signing_key:
141
177
  specification_version: 4
142
178
  summary: Test coverage reports for Xcode projects
143
- test_files: []
179
+ test_files:
180
+ - spec/fixtures/fixtures.xcodeproj/project.pbxproj
181
+ - spec/fixtures/fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
182
+ - spec/fixtures/fixtures.xcodeproj/xcshareddata/xcschemes/fixtures.xcscheme
183
+ - spec/fixtures/fixtures/Supporting Files/fixtures-Prefix.pch
184
+ - spec/fixtures/fixtures/fixtures.h
185
+ - spec/fixtures/fixtures/fixtures.m
186
+ - spec/fixtures/fixtures/more_files/peekaview.h
187
+ - spec/fixtures/fixtures/more_files/peekaview.m
188
+ - spec/fixtures/fixturesTests/Supporting Files/en.lproj/InfoPlist.strings
189
+ - spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist
190
+ - spec/fixtures/fixturesTests/fixturesTests.m
191
+ - spec/fixtures/fixturesTests/peekaviewTests.m
192
+ - spec/slather/coverage_file_spec.rb
193
+ - spec/slather/coverage_service/coveralls_spec.rb
194
+ - spec/slather/coverage_service/simple_output_spec.rb
195
+ - spec/slather/fixtures.gcno
196
+ - spec/slather/project_spec.rb
197
+ - spec/spec_helper.rb
198
+ has_rdoc: