Skip to content

Some project clean up #786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ rvm:
- 2.4.9
- 2.5.7
- 2.6.5
- ruby-head

env:
- RAILS_ENV=development RACK_ENV=development
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ end
group :test do
gem 'files', require: false
gem 'git', require: false
gem 'wrong', require: false
end
2 changes: 2 additions & 0 deletions spec/integration/integration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class IntegrationHelper
}.freeze

def self.able_to_run?(file_path, ruby_version)
return false unless ENV['INTEGRATION_TESTS']

file_name = File.basename(file_path)
rails_app = File.basename(file_name, '_spec.rb')
ruby_dependency = MIN_RUBY_VERSIONS[rails_app]
Expand Down
35 changes: 9 additions & 26 deletions spec/lib/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'annotate/active_record_patch'
require 'active_support/core_ext/string'
require 'files'
require 'tmpdir'

describe AnnotateModels do
MAGIC_COMMENTS = [
Expand Down Expand Up @@ -1781,7 +1782,6 @@ def mock_column(name, type, options = {})

describe '.get_model_class' do
before :all do
require 'tmpdir'
AnnotateModels.model_dir = Dir.mktmpdir('annotate_models')
end

Expand Down Expand Up @@ -2137,7 +2137,6 @@ class Foo
end

let :tmpdir do
require 'tmpdir'
Dir.mktmpdir('annotate_models')
end

Expand Down Expand Up @@ -2659,21 +2658,13 @@ class User < ActiveRecord::Base
end

it 'displays just the error message with trace disabled (default)' do
error_output = capturing(:stderr) do
AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true
end

expect(error_output).to include("Unable to annotate #{@model_dir}/user.rb: oops")
expect(error_output).not_to include('/spec/annotate/annotate_models_spec.rb:')
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
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
end

it 'displays the error message and stacktrace with trace enabled' do
error_output = capturing(:stderr) do
AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true, trace: true
end

expect(error_output).to include("Unable to annotate #{@model_dir}/user.rb: oops")
expect(error_output).to include('/spec/lib/annotate/annotate_models_spec.rb:')
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
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
end
end

Expand All @@ -2689,21 +2680,13 @@ class User < ActiveRecord::Base
end

it 'displays just the error message with trace disabled (default)' do
error_output = capturing(:stderr) do
AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true
end

expect(error_output).to include("Unable to deannotate #{@model_dir}/user.rb: oops")
expect(error_output).not_to include("/user.rb:2:in `<class:User>'")
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
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
end

it 'displays the error message and stacktrace with trace enabled' do
error_output = capturing(:stderr) do
AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true
end

expect(error_output).to include("Unable to deannotate #{@model_dir}/user.rb: oops")
expect(error_output).to include("/user.rb:2:in `<class:User>'")
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
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
end
end

Expand Down
25 changes: 13 additions & 12 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
require 'coveralls'
require 'codeclimate-test-reporter'
require 'simplecov'
if ENV['COVERAGE']
require 'coveralls'
require 'codeclimate-test-reporter'
require 'simplecov'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[
Coveralls::SimpleCov::Formatter,
SimpleCov::Formatter::HTMLFormatter,
CodeClimate::TestReporter::Formatter
]
)
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[
Coveralls::SimpleCov::Formatter,
SimpleCov::Formatter::HTMLFormatter,
CodeClimate::TestReporter::Formatter
]
)

SimpleCov.start
SimpleCov.start
end

require 'rubygems'
require 'bundler'
Bundler.setup

require 'rake'
require 'rspec'
require 'wrong/adapters/rspec'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
Expand Down