Commit b26650d0 by Guillermo Guerrero Ibarra Committed by Cuong Tran

Fixed some offenses (#423)

Fixed some offenses
parent bb8cdf84
source 'https://rubygems.org'
gem 'rake', require: false
gem 'activerecord', '>= 4.2.5', require: false
gem 'rake', require: false
group :development do
gem 'mg', require: false
gem 'bump'
gem 'mg', require: false
platforms :mri, :mingw do
gem 'yard', require: false
end
......@@ -13,13 +13,16 @@ end
group :development, :test do
gem 'byebug'
gem 'rspec', require: false
gem 'guard-rspec', require: false
gem 'terminal-notifier-guard', require: false
gem 'simplecov', require: false
gem 'rspec', require: false
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 'coveralls'
gem 'ruby_dep', '1.3.1'
platforms :mri, :mingw do
......@@ -29,6 +32,6 @@ group :development, :test do
end
group :test do
gem 'wrong', require: false
gem 'files', require: false
gem 'wrong', require: false
end
# 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.
# * bundler: 'bundle exec rspec'
......@@ -11,16 +9,16 @@
guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/.+_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
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/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('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch('spec/rails_helper.rb') { "spec" }
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
watch('config/routes.rb') { 'spec/routing' }
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
watch('spec/rails_helper.rb') { 'spec' }
# Capybara features specs
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
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
......@@ -4,36 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'annotate/version'
Gem::Specification.new do |s|
s.name = "annotate"
s.name = 'annotate'
s.version = Annotate.version
s.required_ruby_version = '>= 1.9.3'
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.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.executables = ["annotate"]
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.homepage = "http://github.com/ctran/annotate_models"
s.licenses = ["Ruby"]
s.require_paths = ["lib"]
s.rubyforge_project = "annotate"
s.rubygems_version = "2.1.11"
s.summary = "Annotates Rails Models, routes, fixtures, and others based on the database schema."
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.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.executables = ['annotate']
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.homepage = 'http://github.com/ctran/annotate_models'
s.licenses = ['Ruby']
s.require_paths = ['lib']
s.rubyforge_project = 'annotate'
s.rubygems_version = '2.1.11'
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
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rake>, [">= 10.4", "< 12.1"])
s.add_runtime_dependency(%q<activerecord>, [">= 3.2", "< 6.0"])
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<activerecord>, ['>= 3.2', '< 6.0'])
else
s.add_dependency(%q<rake>, [">= 10.4", "< 12.1"])
s.add_dependency(%q<activerecord>, [">= 3.2", "< 6.0"])
s.add_dependency(%q<rake>, ['>= 10.4', '< 12.1'])
s.add_dependency(%q<activerecord>, ['>= 3.2', '< 6.0'])
end
else
s.add_dependency(%q<rake>, [">= 0.8.7"])
s.add_dependency(%q<activerecord>, [">= 3.2", "< 6.0"])
s.add_dependency(%q<rake>, ['>= 0.8.7'])
s.add_dependency(%q<activerecord>, ['>= 3.2', '< 6.0'])
end
end
......@@ -716,7 +716,7 @@ module AnnotateModels
id = c
elsif c.name.eql?('created_at') || c.name.eql?('updated_at')
timestamps << c
elsif c.name[-3,3].eql?('_id')
elsif c.name[-3, 3].eql?('_id')
associations << c
else
rest_cols << c
......
......@@ -2,12 +2,12 @@ require File.dirname(__FILE__) + '/../spec_helper.rb'
require 'annotate/annotate_routes'
describe AnnotateRoutes do
ROUTE_FILE = 'config/routes.rb'
ANNOTATION_ADDED = "#{ROUTE_FILE} annotated."
ANNOTATION_REMOVED = "Removed annotations from #{ROUTE_FILE}."
FILE_UNCHANGED = "#{ROUTE_FILE} unchanged."
ROUTE_FILE = 'config/routes.rb'.freeze
ANNOTATION_ADDED = "#{ROUTE_FILE} annotated.".freeze
ANNOTATION_REMOVED = "Removed annotations from #{ROUTE_FILE}.".freeze
FILE_UNCHANGED = "#{ROUTE_FILE} unchanged.".freeze
def mock_file(stubs={})
def mock_file(stubs = {})
@mock_file ||= double(File, stubs)
end
......@@ -82,7 +82,7 @@ describe AnnotateRoutes do
describe 'When adding with newer Rake versions' do
before(:each) do
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(AnnotateRoutes).to receive(:puts).with(ANNOTATION_ADDED)
end
......@@ -102,7 +102,7 @@ describe AnnotateRoutes 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(@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
......
require File.dirname(__FILE__) + '/spec_helper.rb'
describe Annotate do
it "should have a version" do
it 'should have a version' do
expect(Annotate.version).to be_instance_of(String)
end
end
......@@ -12,11 +12,9 @@
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120816164927) do
create_table "tasks", :force => true do |t|
t.string "content"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
......@@ -71,27 +71,28 @@ module Annotate
module Validations
class Base
def self.test_commands
return Annotate::Validations::Common.test_commands
Annotate::Validations::Common.test_commands
end
def self.verify_output(output)
return Annotate::Validations::Common.verify_output(output)
Annotate::Validations::Common.verify_output(output)
end
def self.verify_files(test_rig)
return Annotate::Validations::Common.verify_files({
:model => true,
:test => true,
:fixture => true,
:factory => false,
:routes => true
}, test_rig, self.schema_annotation, self.route_annotation, true)
Annotate::Validations::Common.verify_files(
{
model: true,
test: true,
fixture: true,
factory: false,
routes: true
}, test_rig, schema_annotation, route_annotation, true
)
end
def self.foo
require 'pry'
require 'pry-coolline'
binding.pry
end
end
end
......
# 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 'files'
require 'wrong'
......@@ -7,7 +7,7 @@ require 'rake'
include Files
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
USING_RVM = (RVM_BIN != '')
......@@ -24,13 +24,13 @@ describe "annotate inside Rails, using #{CURRENT_RUBY}" do
Annotate::Integration::SCENARIOS.each do |test_rig, base_dir, test_name|
next if(chosen_scenario && chosen_scenario != test_rig)
it "works under #{test_name}" do
if !USING_RVM
unless USING_RVM
skip 'Must have RVM installed.'
next
end
# 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'
......@@ -53,7 +53,7 @@ describe "annotate inside Rails, using #{CURRENT_RUBY}" do
# make sure it's there so our .rvmrc will work.
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
Dir.chdir(temp_dir) do
......
......@@ -4,7 +4,7 @@ module Annotate
module Validations
class Rails23WithBundler < Base
def self.schema_annotation
return <<-RUBY
<<-RUBY
# == Schema Information
#
# Table name: tasks
......@@ -18,7 +18,7 @@ RUBY
end
def self.route_annotation
return <<-RUBY
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) {:controller=>"tasks", :action=>"index"}
......
......@@ -4,7 +4,7 @@ module Annotate
module Validations
class Rails322 < Base
def self.schema_annotation
return <<-RUBY
<<-RUBY
# == Schema Information
#
# Table name: tasks
......@@ -18,7 +18,7 @@ RUBY
end
def self.route_annotation
return <<-RUBY
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) tasks#index
......
......@@ -4,7 +4,7 @@ module Annotate
module Validations
class Rails32AutoloadingFactoryGirl < Base
def self.schema_annotation
return <<-RUBY
<<-RUBY
# == Schema Information
#
# Table name: tasks
......@@ -18,7 +18,7 @@ RUBY
end
def self.route_annotation
return <<-RUBY
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) tasks#index
......@@ -33,13 +33,15 @@ RUBY
end
def self.verify_files(test_rig)
return Annotate::Validations::Common.verify_files({
:model => true,
:test => true,
:fixture => false,
:factory => true,
:routes => true
}, test_rig, self.schema_annotation, self.route_annotation, true)
Annotate::Validations::Common.verify_files(
{
model: true,
test: true,
fixture: false,
factory: true,
routes: true
}, test_rig, schema_annotation, route_annotation, true
)
end
end
end
......
......@@ -4,7 +4,7 @@ module Annotate
module Validations
class Rails32CustomInflection < Base
def self.schema_annotation
return <<-RUBY
<<-RUBY
# == Schema Information
#
# Table name: tasks
......@@ -18,7 +18,7 @@ RUBY
end
def self.route_annotation
return <<-RUBY
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) tasks#index
......
......@@ -4,7 +4,7 @@ module Annotate
module Validations
class Rails32WithAssetPipeline < Base
def self.schema_annotation
return <<-RUBY
<<-RUBY
# == Schema Information
#
# Table name: tasks
......@@ -18,7 +18,7 @@ RUBY
end
def self.route_annotation
return <<-RUBY
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) tasks#index
......
......@@ -4,7 +4,7 @@ module Annotate
module Validations
class Standalone < Base
def self.schema_annotation
return <<-RUBY
<<-RUBY
# == Schema Information
#
# Table name: tasks
......@@ -18,9 +18,7 @@ RUBY
end
def self.test_commands
return %q{
bin/annotate --require ./config/init.rb
}
'bin/annotate --require ./config/init.rb'
end
def self.verify_output(output)
......@@ -28,13 +26,15 @@ RUBY
end
def self.verify_files(test_rig)
return Annotate::Validations::Common.verify_files({
:model => true,
:test => false,
:fixture => false,
:factory => false,
:routes => false
}, test_rig, self.schema_annotation, nil, true)
Annotate::Validations::Common.verify_files(
{
model: true,
test: false,
fixture: false,
factory: false,
routes: false
}, test_rig, schema_annotation, nil, true
)
end
end
end
......
......@@ -2,11 +2,13 @@ require 'coveralls'
require 'codeclimate-test-reporter'
require 'simplecov'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[
Coveralls::SimpleCov::Formatter,
SimpleCov::Formatter::HTMLFormatter,
CodeClimate::TestReporter::Formatter
])
]
)
SimpleCov.start
......@@ -18,8 +20,8 @@ require 'rake'
require 'rspec'
require 'wrong/adapters/rspec'
$:.unshift(File.join(File.dirname(__FILE__), '../lib'))
$:.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'active_support'
require 'active_support/core_ext/object/blank'
......@@ -30,21 +32,28 @@ require 'byebug'
module Annotate
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)
SCENARIO_HOME=File.join(File.dirname(__FILE__), 'integration')
SCENARIOS=Dir.glob("#{SCENARIO_HOME}/*").
select { |candidate| File.directory?(candidate) }.
map do |test_rig|
CRUFT_PATTERNS = %w(
%SCENARIO%/bin/*
%SCENARIO%/log/*
%SCENARIO%/tmp/*
%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)
[test_rig, base_dir, base_dir.titlecase]
end
def self.nuke_cruft(test_rig)
FileList[
Annotate::Integration::CRUFT_PATTERNS.
map { |pattern| pattern.sub('%SCENARIO%', test_rig) }
Annotate::Integration::CRUFT_PATTERNS.map do |pattern|
pattern.sub('%SCENARIO%', test_rig)
end
].each do |fname|
FileUtils.rm_rf(fname)
end
......@@ -58,13 +67,13 @@ module Annotate
def self.empty_gemset(test_rig)
Dir.chdir(test_rig) do
system(%q{
system('
(
export SKIP_BUNDLER=1
source .rvmrc &&
rvm --force gemset empty
) 2>&1
})
')
end
end
......@@ -76,8 +85,8 @@ module Annotate
system("git clean -dfx #{SCENARIO_HOME}/*/")
end
def self.is_clean?(test_rig)
return `git status --porcelain #{test_rig}/ | wc -l`.strip.to_i == 0
def self.clean?(test_rig)
`git status --porcelain #{test_rig}/ | wc -l`.strip.to_i.zero?
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