Commit b26650d0 by Guillermo Guerrero Ibarra Committed by Cuong Tran

Fixed some offenses (#423)

Fixed some offenses
parent bb8cdf84
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'rake', require: false
gem 'activerecord', '>= 4.2.5', require: false gem 'activerecord', '>= 4.2.5', require: false
gem 'rake', require: false
group :development do group :development do
gem 'mg', require: false
gem 'bump' gem 'bump'
gem 'mg', require: false
platforms :mri, :mingw do platforms :mri, :mingw do
gem 'yard', require: false gem 'yard', require: false
end end
...@@ -13,13 +13,16 @@ end ...@@ -13,13 +13,16 @@ end
group :development, :test do group :development, :test do
gem 'byebug' gem 'byebug'
gem 'rspec', require: false
gem 'guard-rspec', require: false gem 'guard-rspec', require: false
gem 'terminal-notifier-guard', require: false gem 'rspec', require: false
gem 'simplecov', require: false
gem 'rubocop', '~> 0.46.0', require: false unless RUBY_VERSION =~ /^1.8/ gem 'rubocop', '~> 0.46.0', require: false unless RUBY_VERSION =~ /^1.8/
gem 'coveralls' gem 'simplecov', require: false
gem 'terminal-notifier-guard', require: false
gem 'codeclimate-test-reporter' gem 'codeclimate-test-reporter'
gem 'coveralls'
gem 'ruby_dep', '1.3.1' gem 'ruby_dep', '1.3.1'
platforms :mri, :mingw do platforms :mri, :mingw do
...@@ -29,6 +32,6 @@ group :development, :test do ...@@ -29,6 +32,6 @@ group :development, :test do
end end
group :test do group :test do
gem 'wrong', require: false
gem 'files', require: false gem 'files', require: false
gem 'wrong', require: false
end end
# Note: The cmd option is now required due to the increasing number of ways # Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses. # rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec' # * bundler: 'bundle exec rspec'
...@@ -11,16 +9,16 @@ ...@@ -11,16 +9,16 @@
guard :rspec, cmd: 'bundle exec rspec' do guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/.+_spec\.rb$}) watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" } watch('spec/spec_helper.rb') { 'spec' }
# Rails example # Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
watch('config/routes.rb') { "spec/routing" } watch('config/routes.rb') { 'spec/routing' }
watch('app/controllers/application_controller.rb') { "spec/controllers" } watch('app/controllers/application_controller.rb') { 'spec/controllers' }
watch('spec/rails_helper.rb') { "spec" } watch('spec/rails_helper.rb') { 'spec' }
# Capybara features specs # Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
...@@ -29,4 +27,3 @@ guard :rspec, cmd: 'bundle exec rspec' do ...@@ -29,4 +27,3 @@ guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/acceptance/(.+)\.feature$}) watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end end
...@@ -4,36 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) ...@@ -4,36 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'annotate/version' require 'annotate/version'
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "annotate" s.name = 'annotate'
s.version = Annotate.version s.version = Annotate.version
s.required_ruby_version = '>= 1.9.3' s.required_ruby_version = '>= 1.9.3'
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
s.authors = ["Alex Chaffee", "Cuong Tran", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"] s.authors = ['Alex Chaffee', 'Cuong Tran', 'Marcos Piccinini', 'Turadg Aleahmad', 'Jon Frisby']
s.description = "Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema." s.description = 'Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema.'
s.email = ["alex@stinky.com", "cuong.tran@gmail.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"] s.email = ['alex@stinky.com', 'cuong.tran@gmail.com', 'x@nofxx.com', 'turadg@aleahmad.net', 'jon@cloudability.com']
s.executables = ["annotate"] s.executables = ['annotate']
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "TODO.rdoc"] s.extra_rdoc_files = ['README.rdoc', 'CHANGELOG.rdoc', 'TODO.rdoc']
s.files = ["AUTHORS.rdoc", "CHANGELOG.rdoc", "LICENSE.txt", "README.rdoc", "TODO.rdoc", "annotate.gemspec", "bin/annotate", "lib/annotate.rb", "lib/annotate/active_record_patch.rb", "lib/annotate/annotate_models.rb", "lib/annotate/annotate_routes.rb", "lib/annotate/tasks.rb", "lib/annotate/version.rb", "lib/generators/annotate/USAGE", "lib/generators/annotate/install_generator.rb", "lib/generators/annotate/templates/auto_annotate_models.rake", "lib/tasks/annotate_models.rake", "lib/tasks/annotate_routes.rake", "lib/tasks/migrate.rake"] s.files = ['AUTHORS.rdoc', 'CHANGELOG.rdoc', 'LICENSE.txt', 'README.rdoc', 'TODO.rdoc', 'annotate.gemspec', 'bin/annotate', 'lib/annotate.rb', 'lib/annotate/active_record_patch.rb', 'lib/annotate/annotate_models.rb', 'lib/annotate/annotate_routes.rb', 'lib/annotate/tasks.rb', 'lib/annotate/version.rb', 'lib/generators/annotate/USAGE', 'lib/generators/annotate/install_generator.rb', 'lib/generators/annotate/templates/auto_annotate_models.rake', 'lib/tasks/annotate_models.rake', 'lib/tasks/annotate_routes.rake', 'lib/tasks/migrate.rake']
s.homepage = "http://github.com/ctran/annotate_models" s.homepage = 'http://github.com/ctran/annotate_models'
s.licenses = ["Ruby"] s.licenses = ['Ruby']
s.require_paths = ["lib"] s.require_paths = ['lib']
s.rubyforge_project = "annotate" s.rubyforge_project = 'annotate'
s.rubygems_version = "2.1.11" s.rubygems_version = '2.1.11'
s.summary = "Annotates Rails Models, routes, fixtures, and others based on the database schema." s.summary = 'Annotates Rails Models, routes, fixtures, and others based on the database schema.'
if s.respond_to? :specification_version then if s.respond_to? :specification_version
s.specification_version = 4 s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0')
s.add_runtime_dependency(%q<rake>, [">= 10.4", "< 12.1"]) s.add_runtime_dependency(%q<rake>, ['>= 10.4', '< 12.1'])
s.add_runtime_dependency(%q<activerecord>, [">= 3.2", "< 6.0"]) s.add_runtime_dependency(%q<activerecord>, ['>= 3.2', '< 6.0'])
else else
s.add_dependency(%q<rake>, [">= 10.4", "< 12.1"]) s.add_dependency(%q<rake>, ['>= 10.4', '< 12.1'])
s.add_dependency(%q<activerecord>, [">= 3.2", "< 6.0"]) s.add_dependency(%q<activerecord>, ['>= 3.2', '< 6.0'])
end end
else else
s.add_dependency(%q<rake>, [">= 0.8.7"]) s.add_dependency(%q<rake>, ['>= 0.8.7'])
s.add_dependency(%q<activerecord>, [">= 3.2", "< 6.0"]) s.add_dependency(%q<activerecord>, ['>= 3.2', '< 6.0'])
end end
end end
...@@ -716,7 +716,7 @@ module AnnotateModels ...@@ -716,7 +716,7 @@ module AnnotateModels
id = c id = c
elsif c.name.eql?('created_at') || c.name.eql?('updated_at') elsif c.name.eql?('created_at') || c.name.eql?('updated_at')
timestamps << c timestamps << c
elsif c.name[-3,3].eql?('_id') elsif c.name[-3, 3].eql?('_id')
associations << c associations << c
else else
rest_cols << c rest_cols << c
......
...@@ -2,12 +2,12 @@ require File.dirname(__FILE__) + '/../spec_helper.rb' ...@@ -2,12 +2,12 @@ require File.dirname(__FILE__) + '/../spec_helper.rb'
require 'annotate/annotate_routes' require 'annotate/annotate_routes'
describe AnnotateRoutes do describe AnnotateRoutes do
ROUTE_FILE = 'config/routes.rb' ROUTE_FILE = 'config/routes.rb'.freeze
ANNOTATION_ADDED = "#{ROUTE_FILE} annotated." ANNOTATION_ADDED = "#{ROUTE_FILE} annotated.".freeze
ANNOTATION_REMOVED = "Removed annotations from #{ROUTE_FILE}." ANNOTATION_REMOVED = "Removed annotations from #{ROUTE_FILE}.".freeze
FILE_UNCHANGED = "#{ROUTE_FILE} unchanged." FILE_UNCHANGED = "#{ROUTE_FILE} unchanged.".freeze
def mock_file(stubs={}) def mock_file(stubs = {})
@mock_file ||= double(File, stubs) @mock_file ||= double(File, stubs)
end end
...@@ -82,7 +82,7 @@ describe AnnotateRoutes do ...@@ -82,7 +82,7 @@ describe AnnotateRoutes do
describe 'When adding with newer Rake versions' do describe 'When adding with newer Rake versions' do
before(:each) do before(:each) do
expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true) expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true)
expect(AnnotateRoutes).to receive(:`).with("rake routes").and_return("another good line\ngood line") expect(AnnotateRoutes).to receive(:`).with('rake routes').and_return("another good line\ngood line")
expect(File).to receive(:open).with(ROUTE_FILE, 'wb').and_yield(mock_file) expect(File).to receive(:open).with(ROUTE_FILE, 'wb').and_yield(mock_file)
expect(AnnotateRoutes).to receive(:puts).with(ANNOTATION_ADDED) expect(AnnotateRoutes).to receive(:puts).with(ANNOTATION_ADDED)
end end
...@@ -102,7 +102,7 @@ describe AnnotateRoutes do ...@@ -102,7 +102,7 @@ describe AnnotateRoutes do
it 'should add a timestamp when :timestamp is passed' do it 'should add a timestamp when :timestamp is passed' do
expect(File).to receive(:read).with(ROUTE_FILE).and_return("ActionController::Routing...\nfoo") expect(File).to receive(:read).with(ROUTE_FILE).and_return("ActionController::Routing...\nfoo")
expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# another good line\n# good line\n/) expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# another good line\n# good line\n/)
AnnotateRoutes.do_annotations :timestamp => true AnnotateRoutes.do_annotations timestamp: true
end end
end end
......
require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/spec_helper.rb'
describe Annotate do describe Annotate do
it "should have a version" do it 'should have a version' do
expect(Annotate.version).to be_instance_of(String) expect(Annotate.version).to be_instance_of(String)
end end
end end
...@@ -12,11 +12,9 @@ ...@@ -12,11 +12,9 @@
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120816164927) do ActiveRecord::Schema.define(:version => 20120816164927) do
create_table "tasks", :force => true do |t| create_table "tasks", :force => true do |t|
t.string "content" t.string "content"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
end end
...@@ -71,27 +71,28 @@ module Annotate ...@@ -71,27 +71,28 @@ module Annotate
module Validations module Validations
class Base class Base
def self.test_commands def self.test_commands
return Annotate::Validations::Common.test_commands Annotate::Validations::Common.test_commands
end end
def self.verify_output(output) def self.verify_output(output)
return Annotate::Validations::Common.verify_output(output) Annotate::Validations::Common.verify_output(output)
end end
def self.verify_files(test_rig) def self.verify_files(test_rig)
return Annotate::Validations::Common.verify_files({ Annotate::Validations::Common.verify_files(
:model => true, {
:test => true, model: true,
:fixture => true, test: true,
:factory => false, fixture: true,
:routes => true factory: false,
}, test_rig, self.schema_annotation, self.route_annotation, true) routes: true
}, test_rig, schema_annotation, route_annotation, true
)
end end
def self.foo def self.foo
require 'pry' require 'pry'
require 'pry-coolline' require 'pry-coolline'
binding.pry
end end
end end
end end
......
# Smoke test to assure basic functionality works on a variety of Rails versions. # Smoke test to assure basic functionality works on a variety of Rails versions.
$:.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'spec_helper' require 'spec_helper'
require 'files' require 'files'
require 'wrong' require 'wrong'
...@@ -7,7 +7,7 @@ require 'rake' ...@@ -7,7 +7,7 @@ require 'rake'
include Files include Files
include Wrong::D include Wrong::D
BASEDIR=File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) BASEDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
RVM_BIN = `which rvm`.chomp RVM_BIN = `which rvm`.chomp
USING_RVM = (RVM_BIN != '') USING_RVM = (RVM_BIN != '')
...@@ -24,13 +24,13 @@ describe "annotate inside Rails, using #{CURRENT_RUBY}" do ...@@ -24,13 +24,13 @@ describe "annotate inside Rails, using #{CURRENT_RUBY}" do
Annotate::Integration::SCENARIOS.each do |test_rig, base_dir, test_name| Annotate::Integration::SCENARIOS.each do |test_rig, base_dir, test_name|
next if(chosen_scenario && chosen_scenario != test_rig) next if(chosen_scenario && chosen_scenario != test_rig)
it "works under #{test_name}" do it "works under #{test_name}" do
if !USING_RVM unless USING_RVM
skip 'Must have RVM installed.' skip 'Must have RVM installed.'
next next
end end
# Don't proceed if the working copy is dirty! # Don't proceed if the working copy is dirty!
expect(Annotate::Integration.is_clean?(test_rig)).to eq(true) expect(Annotate::Integration.clean?(test_rig)).to eq(true)
skip 'temporarily ignored until Travis can run them' skip 'temporarily ignored until Travis can run them'
...@@ -53,7 +53,7 @@ describe "annotate inside Rails, using #{CURRENT_RUBY}" do ...@@ -53,7 +53,7 @@ describe "annotate inside Rails, using #{CURRENT_RUBY}" do
# make sure it's there so our .rvmrc will work. # make sure it's there so our .rvmrc will work.
ENV['rvm_ruby_string']=CURRENT_RUBY ENV['rvm_ruby_string']=CURRENT_RUBY
require "#{base_dir}" # Will get "#{base_dir}.rb"... require base_dir.to_s # Will get "#{base_dir}.rb"...
klass = "Annotate::Validations::#{base_dir.tr('.', '_').classify}".constantize klass = "Annotate::Validations::#{base_dir.tr('.', '_').classify}".constantize
Dir.chdir(temp_dir) do Dir.chdir(temp_dir) do
......
...@@ -4,7 +4,7 @@ module Annotate ...@@ -4,7 +4,7 @@ module Annotate
module Validations module Validations
class Rails23WithBundler < Base class Rails23WithBundler < Base
def self.schema_annotation def self.schema_annotation
return <<-RUBY <<-RUBY
# == Schema Information # == Schema Information
# #
# Table name: tasks # Table name: tasks
...@@ -18,7 +18,7 @@ RUBY ...@@ -18,7 +18,7 @@ RUBY
end end
def self.route_annotation def self.route_annotation
return <<-RUBY <<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM) # == Route Map (Updated YYYY-MM-DD HH:MM)
# #
# tasks GET /tasks(.:format) {:controller=>"tasks", :action=>"index"} # tasks GET /tasks(.:format) {:controller=>"tasks", :action=>"index"}
......
...@@ -4,7 +4,7 @@ module Annotate ...@@ -4,7 +4,7 @@ module Annotate
module Validations module Validations
class Rails322 < Base class Rails322 < Base
def self.schema_annotation def self.schema_annotation
return <<-RUBY <<-RUBY
# == Schema Information # == Schema Information
# #
# Table name: tasks # Table name: tasks
...@@ -18,7 +18,7 @@ RUBY ...@@ -18,7 +18,7 @@ RUBY
end end
def self.route_annotation def self.route_annotation
return <<-RUBY <<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM) # == Route Map (Updated YYYY-MM-DD HH:MM)
# #
# tasks GET /tasks(.:format) tasks#index # tasks GET /tasks(.:format) tasks#index
......
...@@ -4,7 +4,7 @@ module Annotate ...@@ -4,7 +4,7 @@ module Annotate
module Validations module Validations
class Rails32AutoloadingFactoryGirl < Base class Rails32AutoloadingFactoryGirl < Base
def self.schema_annotation def self.schema_annotation
return <<-RUBY <<-RUBY
# == Schema Information # == Schema Information
# #
# Table name: tasks # Table name: tasks
...@@ -18,7 +18,7 @@ RUBY ...@@ -18,7 +18,7 @@ RUBY
end end
def self.route_annotation def self.route_annotation
return <<-RUBY <<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM) # == Route Map (Updated YYYY-MM-DD HH:MM)
# #
# tasks GET /tasks(.:format) tasks#index # tasks GET /tasks(.:format) tasks#index
...@@ -33,13 +33,15 @@ RUBY ...@@ -33,13 +33,15 @@ RUBY
end end
def self.verify_files(test_rig) def self.verify_files(test_rig)
return Annotate::Validations::Common.verify_files({ Annotate::Validations::Common.verify_files(
:model => true, {
:test => true, model: true,
:fixture => false, test: true,
:factory => true, fixture: false,
:routes => true factory: true,
}, test_rig, self.schema_annotation, self.route_annotation, true) routes: true
}, test_rig, schema_annotation, route_annotation, true
)
end end
end end
end end
......
...@@ -4,7 +4,7 @@ module Annotate ...@@ -4,7 +4,7 @@ module Annotate
module Validations module Validations
class Rails32CustomInflection < Base class Rails32CustomInflection < Base
def self.schema_annotation def self.schema_annotation
return <<-RUBY <<-RUBY
# == Schema Information # == Schema Information
# #
# Table name: tasks # Table name: tasks
...@@ -18,7 +18,7 @@ RUBY ...@@ -18,7 +18,7 @@ RUBY
end end
def self.route_annotation def self.route_annotation
return <<-RUBY <<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM) # == Route Map (Updated YYYY-MM-DD HH:MM)
# #
# tasks GET /tasks(.:format) tasks#index # tasks GET /tasks(.:format) tasks#index
......
...@@ -4,7 +4,7 @@ module Annotate ...@@ -4,7 +4,7 @@ module Annotate
module Validations module Validations
class Rails32WithAssetPipeline < Base class Rails32WithAssetPipeline < Base
def self.schema_annotation def self.schema_annotation
return <<-RUBY <<-RUBY
# == Schema Information # == Schema Information
# #
# Table name: tasks # Table name: tasks
...@@ -18,7 +18,7 @@ RUBY ...@@ -18,7 +18,7 @@ RUBY
end end
def self.route_annotation def self.route_annotation
return <<-RUBY <<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM) # == Route Map (Updated YYYY-MM-DD HH:MM)
# #
# tasks GET /tasks(.:format) tasks#index # tasks GET /tasks(.:format) tasks#index
......
...@@ -4,7 +4,7 @@ module Annotate ...@@ -4,7 +4,7 @@ module Annotate
module Validations module Validations
class Standalone < Base class Standalone < Base
def self.schema_annotation def self.schema_annotation
return <<-RUBY <<-RUBY
# == Schema Information # == Schema Information
# #
# Table name: tasks # Table name: tasks
...@@ -18,9 +18,7 @@ RUBY ...@@ -18,9 +18,7 @@ RUBY
end end
def self.test_commands def self.test_commands
return %q{ 'bin/annotate --require ./config/init.rb'
bin/annotate --require ./config/init.rb
}
end end
def self.verify_output(output) def self.verify_output(output)
...@@ -28,13 +26,15 @@ RUBY ...@@ -28,13 +26,15 @@ RUBY
end end
def self.verify_files(test_rig) def self.verify_files(test_rig)
return Annotate::Validations::Common.verify_files({ Annotate::Validations::Common.verify_files(
:model => true, {
:test => false, model: true,
:fixture => false, test: false,
:factory => false, fixture: false,
:routes => false factory: false,
}, test_rig, self.schema_annotation, nil, true) routes: false
}, test_rig, schema_annotation, nil, true
)
end end
end end
end end
......
...@@ -2,11 +2,13 @@ require 'coveralls' ...@@ -2,11 +2,13 @@ require 'coveralls'
require 'codeclimate-test-reporter' require 'codeclimate-test-reporter'
require 'simplecov' require 'simplecov'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[
Coveralls::SimpleCov::Formatter, Coveralls::SimpleCov::Formatter,
SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::HTMLFormatter,
CodeClimate::TestReporter::Formatter CodeClimate::TestReporter::Formatter
]) ]
)
SimpleCov.start SimpleCov.start
...@@ -18,8 +20,8 @@ require 'rake' ...@@ -18,8 +20,8 @@ require 'rake'
require 'rspec' require 'rspec'
require 'wrong/adapters/rspec' require 'wrong/adapters/rspec'
$:.unshift(File.join(File.dirname(__FILE__), '../lib')) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
$:.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'active_support' require 'active_support'
require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/blank'
...@@ -30,21 +32,28 @@ require 'byebug' ...@@ -30,21 +32,28 @@ require 'byebug'
module Annotate module Annotate
module Integration module Integration
ABSOLUTE_GEM_ROOT=File.expand_path('../../', __FILE__) ABSOLUTE_GEM_ROOT = File.expand_path('../../', __FILE__)
CRUFT_PATTERNS= %w(%SCENARIO%/bin/* %SCENARIO%/log/* %SCENARIO%/tmp/* %SCENARIO%/.bundle) CRUFT_PATTERNS = %w(
SCENARIO_HOME=File.join(File.dirname(__FILE__), 'integration') %SCENARIO%/bin/*
SCENARIOS=Dir.glob("#{SCENARIO_HOME}/*"). %SCENARIO%/log/*
select { |candidate| File.directory?(candidate) }. %SCENARIO%/tmp/*
map do |test_rig| %SCENARIO%/.bundle
).freeze
SCENARIO_HOME = File.join(File.dirname(__FILE__), 'integration')
SCENARIOS = Dir.glob("#{SCENARIO_HOME}/*").select do |candidate|
File.directory?(candidate)
end.map do |test_rig|
base_dir = File.basename(test_rig) base_dir = File.basename(test_rig)
[test_rig, base_dir, base_dir.titlecase] [test_rig, base_dir, base_dir.titlecase]
end end
def self.nuke_cruft(test_rig) def self.nuke_cruft(test_rig)
FileList[ FileList[
Annotate::Integration::CRUFT_PATTERNS. Annotate::Integration::CRUFT_PATTERNS.map do |pattern|
map { |pattern| pattern.sub('%SCENARIO%', test_rig) } pattern.sub('%SCENARIO%', test_rig)
end
].each do |fname| ].each do |fname|
FileUtils.rm_rf(fname) FileUtils.rm_rf(fname)
end end
...@@ -58,13 +67,13 @@ module Annotate ...@@ -58,13 +67,13 @@ module Annotate
def self.empty_gemset(test_rig) def self.empty_gemset(test_rig)
Dir.chdir(test_rig) do Dir.chdir(test_rig) do
system(%q{ system('
( (
export SKIP_BUNDLER=1 export SKIP_BUNDLER=1
source .rvmrc && source .rvmrc &&
rvm --force gemset empty rvm --force gemset empty
) 2>&1 ) 2>&1
}) ')
end end
end end
...@@ -76,8 +85,8 @@ module Annotate ...@@ -76,8 +85,8 @@ module Annotate
system("git clean -dfx #{SCENARIO_HOME}/*/") system("git clean -dfx #{SCENARIO_HOME}/*/")
end end
def self.is_clean?(test_rig) def self.clean?(test_rig)
return `git status --porcelain #{test_rig}/ | wc -l`.strip.to_i == 0 `git status --porcelain #{test_rig}/ | wc -l`.strip.to_i.zero?
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment