Skip to content

Commit 1c1c585

Browse files
authored
Some project clean up (#786)
This PR does the following: * moves code coverage generation to happen when `COVERAGE` environment variable is present. * makes integration tests run when when `INTEGRATION_TESTS` is present. * moves `ruby-head` from TravisCI build. Previously the configuration allowed for `ruby-head` to be ignored if it failed, but it conflicted with the gem release build job step.
1 parent c9e85d3 commit 1c1c585

File tree

5 files changed

+24
-40
lines changed

5 files changed

+24
-40
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ rvm:
33
- 2.4.9
44
- 2.5.7
55
- 2.6.5
6-
- ruby-head
76

87
env:
98
- RAILS_ENV=development RACK_ENV=development

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ end
3838
group :test do
3939
gem 'files', require: false
4040
gem 'git', require: false
41-
gem 'wrong', require: false
4241
end

spec/integration/integration_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class IntegrationHelper
55
}.freeze
66

77
def self.able_to_run?(file_path, ruby_version)
8+
return false unless ENV['INTEGRATION_TESTS']
9+
810
file_name = File.basename(file_path)
911
rails_app = File.basename(file_name, '_spec.rb')
1012
ruby_dependency = MIN_RUBY_VERSIONS[rails_app]

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'annotate/active_record_patch'
55
require 'active_support/core_ext/string'
66
require 'files'
7+
require 'tmpdir'
78

89
describe AnnotateModels do
910
MAGIC_COMMENTS = [
@@ -1781,7 +1782,6 @@ def mock_column(name, type, options = {})
17811782

17821783
describe '.get_model_class' do
17831784
before :all do
1784-
require 'tmpdir'
17851785
AnnotateModels.model_dir = Dir.mktmpdir('annotate_models')
17861786
end
17871787

@@ -2137,7 +2137,6 @@ class Foo
21372137
end
21382138

21392139
let :tmpdir do
2140-
require 'tmpdir'
21412140
Dir.mktmpdir('annotate_models')
21422141
end
21432142

@@ -2659,21 +2658,13 @@ class User < ActiveRecord::Base
26592658
end
26602659

26612660
it 'displays just the error message with trace disabled (default)' do
2662-
error_output = capturing(:stderr) do
2663-
AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true
2664-
end
2665-
2666-
expect(error_output).to include("Unable to annotate #{@model_dir}/user.rb: oops")
2667-
expect(error_output).not_to include('/spec/annotate/annotate_models_spec.rb:')
2661+
expect { AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true }.to output(a_string_including("Unable to annotate #{@model_dir}/user.rb: oops")).to_stderr
2662+
expect { AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true }.not_to output(a_string_including('/spec/annotate/annotate_models_spec.rb:')).to_stderr
26682663
end
26692664

26702665
it 'displays the error message and stacktrace with trace enabled' do
2671-
error_output = capturing(:stderr) do
2672-
AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true, trace: true
2673-
end
2674-
2675-
expect(error_output).to include("Unable to annotate #{@model_dir}/user.rb: oops")
2676-
expect(error_output).to include('/spec/lib/annotate/annotate_models_spec.rb:')
2666+
expect { AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including("Unable to annotate #{@model_dir}/user.rb: oops")).to_stderr
2667+
expect { AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including('/spec/lib/annotate/annotate_models_spec.rb:')).to_stderr
26772668
end
26782669
end
26792670

@@ -2689,21 +2680,13 @@ class User < ActiveRecord::Base
26892680
end
26902681

26912682
it 'displays just the error message with trace disabled (default)' do
2692-
error_output = capturing(:stderr) do
2693-
AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true
2694-
end
2695-
2696-
expect(error_output).to include("Unable to deannotate #{@model_dir}/user.rb: oops")
2697-
expect(error_output).not_to include("/user.rb:2:in `<class:User>'")
2683+
expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true }.to output(a_string_including("Unable to deannotate #{@model_dir}/user.rb: oops")).to_stderr
2684+
expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true }.not_to output(a_string_including("/user.rb:2:in `<class:User>'")).to_stderr
26982685
end
26992686

27002687
it 'displays the error message and stacktrace with trace enabled' do
2701-
error_output = capturing(:stderr) do
2702-
AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true
2703-
end
2704-
2705-
expect(error_output).to include("Unable to deannotate #{@model_dir}/user.rb: oops")
2706-
expect(error_output).to include("/user.rb:2:in `<class:User>'")
2688+
expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including("Unable to deannotate #{@model_dir}/user.rb: oops")).to_stderr
2689+
expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including("/user.rb:2:in `<class:User>'")).to_stderr
27072690
end
27082691
end
27092692

spec/spec_helper.rb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
require 'coveralls'
2-
require 'codeclimate-test-reporter'
3-
require 'simplecov'
1+
if ENV['COVERAGE']
2+
require 'coveralls'
3+
require 'codeclimate-test-reporter'
4+
require 'simplecov'
45

5-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
6-
[
7-
Coveralls::SimpleCov::Formatter,
8-
SimpleCov::Formatter::HTMLFormatter,
9-
CodeClimate::TestReporter::Formatter
10-
]
11-
)
6+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
7+
[
8+
Coveralls::SimpleCov::Formatter,
9+
SimpleCov::Formatter::HTMLFormatter,
10+
CodeClimate::TestReporter::Formatter
11+
]
12+
)
1213

13-
SimpleCov.start
14+
SimpleCov.start
15+
end
1416

1517
require 'rubygems'
1618
require 'bundler'
1719
Bundler.setup
1820

1921
require 'rake'
2022
require 'rspec'
21-
require 'wrong/adapters/rspec'
2223

2324
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
2425
$LOAD_PATH.unshift(File.dirname(__FILE__))

0 commit comments

Comments
 (0)