Unverified Commit 6b681650 by Andrew W. Lee Committed by GitHub

Remove unworking integration tests (#725)

`spec/integration` contains a lot of files that were used for integration tests. They stopped were [disabled in 2014](https://github.com/ctran/annotate_models/commit/9540121243da58cad3ab3c0ba444f22445a995ed#diff-78ddf877ecc2a9344997ef077a77955a) and haven't been working since. Removing because those tests don't run, don't work, and are outdated. The plan is to re-introduce integration tests sometime in the future.
parent 407ace64
##
# Usage:
#
# # build the image
# docker build -t annotate-docker .
#
# # run a bash login shell in a container running that image
# docker run -it annotate-docker bash -l
#
# References:
# https://github.com/ms-ati/docker-rvm/blob/master/Dockerfile
# https://hub.docker.com/r/instructure/rvm/dockerfile
##
FROM ubuntu:18.04
ARG RVM_USER=docker
# RVM version to install
ARG RVM_VERSION=stable
# Directorry path
ARG PROJECT_PATH=/annotate_models
# Install RVM
RUN apt-get update \
&& apt-get install -y \
curl \
git \
gnupg2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/
RUN addgroup --gid 9999 ${RVM_USER} \
&& adduser --uid 9999 --gid 9999 --disabled-password --gecos "Docker User" ${RVM_USER} \
&& usermod -L ${RVM_USER}
# No ipv6 support in container (https://github.com/inversepath/usbarmory-debian-base_image/issues/)
RUN mkdir ~/.gnupg && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf
# https://superuser.com/questions/954509/what-are-the-correct-permissions-for-the-gnupg-enclosing-folder-gpg-warning
RUN chmod 700 ~/.gnupg && chmod 600 ~/.gnupg/*
# Install + verify RVM with gpg (https://rvm.io/rvm/security)
RUN gpg2 --quiet --no-tty --logger-fd 1 --keyserver hkp://keys.gnupg.net \
--recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \
7D2BAF1CF37B13E2069D6956105BD0E739499BDB \
&& echo 409B6B1796C275462A1703113804BB82D39DC0E3:6: | \
gpg2 --quiet --no-tty --logger-fd 1 --import-ownertrust \
&& curl -sSO https://raw.githubusercontent.com/rvm/rvm/${RVM_VERSION}/binscripts/rvm-installer \
&& curl -sSO https://raw.githubusercontent.com/rvm/rvm/${RVM_VERSION}/binscripts/rvm-installer.asc \
&& gpg2 --quiet --no-tty --logger-fd 1 --verify rvm-installer.asc \
&& bash rvm-installer ${RVM_VERSION} \
&& rm rvm-installer rvm-installer.asc \
&& echo "bundler" >> /usr/local/rvm/gemsets/global.gems \
&& echo "rvm_silence_path_mismatch_check_flag=1" >> /etc/rvmrc \
&& echo "install: --no-document" > /etc/gemrc
# Workaround tty check, see https://github.com/hashicorp/vagrant/issues/1673#issuecomment-26650102
RUN sed -i 's/^mesg n/tty -s \&\& mesg n/g' /root/.profile
# Switch to a bash login shell to allow simple 'rvm' in RUN commands
SHELL ["/bin/bash", "-l", "-c"]
RUN rvm group add rvm "${RVM_USER}"
# Create project directory and copy path
RUN mkdir -p /${PROJECT_PATH} && chown ${RVM_USER}:${RVM_USER} /${PROJECT_PATH}
COPY . /${PROJECT_PATH}
# Switch to user
USER ${RVM_USER}
RUN echo ". /etc/profile.d/rvm.sh" >> ~/.bashrc
WORKDIR ${PROJECT_PATH}
module Annotate
module Validations
module Common
def self.test_commands
'bin/annotate && bin/annotate --routes'
end
def self.verify_output(output)
output.should =~ /Annotated \(1\): Task/
output.should =~ /Route file annotated./
end
def self.verify_files(which_files, test_rig, schema_annotation, routes_annotation, place_before = true)
check_task_model(test_rig, schema_annotation, place_before) if which_files[:model]
check_task_unittest(test_rig, schema_annotation, place_before) if which_files[:test]
check_task_fixture(test_rig, schema_annotation, place_before) if which_files[:fixture]
check_task_factory(test_rig, schema_annotation, place_before) if which_files[:factory]
check_routes(test_rig, routes_annotation, place_before) if which_files[:routes]
end
def self.check_task_model(test_rig, annotation, place_before = true)
model = apply_annotation(test_rig, 'app/models/task.rb', annotation, place_before)
File.read('app/models/task.rb').should == model
end
def self.check_routes(test_rig, annotation, place_before = true)
routes = apply_annotation(test_rig, 'config/routes.rb', annotation, place_before)
File.read('config/routes.rb')
.sub(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}/, 'YYYY-MM-DD HH:MM')
.should == routes
end
def self.check_task_unittest(test_rig, annotation, place_before = true)
unittest = apply_annotation(test_rig, 'test/unit/task_test.rb', annotation, place_before)
File.read('test/unit/task_test.rb').should == unittest
end
def self.check_task_modeltest(test_rig, annotation, place_before=true)
unittest = apply_annotation(test_rig, 'test/models/task_test.rb', annotation, place_before)
File.read('test/models/task_test.rb').should == unittest
end
def self.check_task_factory(test_rig, annotation, place_before=true)
fixture = apply_annotation(test_rig, 'test/factories/tasks.rb', annotation, place_before)
File.read('test/factories/tasks.rb').should == fixture
end
def self.check_task_fixture(test_rig, annotation, place_before = true)
fixture = apply_annotation(test_rig, 'test/fixtures/tasks.yml', annotation, place_before)
File.read('test/fixtures/tasks.yml').should == fixture
end
def self.apply_annotation(test_rig, fname, annotation, place_before = true)
corpus = File.read(File.join(test_rig, fname))
if place_before
annotation + "\n" + corpus
else
corpus + "\n" + annotation
end
end
end
end
end
module Annotate
module Validations
class Base
def self.test_commands
Annotate::Validations::Common.test_commands
end
def self.verify_output(output)
Annotate::Validations::Common.verify_output(output)
end
def self.verify_files(test_rig)
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'
end
end
end
end
# Smoke test to assure basic functionality works on a variety of Rails versions.
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'spec_helper'
require 'files'
require 'wrong'
require 'rake'
include Files
include Wrong::D
BASEDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
RVM_BIN = `which rvm`.chomp
USING_RVM = (RVM_BIN != '')
CURRENT_RUBY = `rvm-prompt i v p 2>/dev/null`.chomp
ENV['rvm_pretty_print_flag'] = '0'
ENV['BUNDLE_GEMFILE'] = './Gemfile'
describe "annotate inside Rails, using #{CURRENT_RUBY}" do
chosen_scenario = nil
unless ENV['SCENARIO'].blank?
chosen_scenario = File.expand_path(ENV['SCENARIO'])
raise "Can't find specified scenario '#{chosen_scenario}'!" unless File.directory?(chosen_scenario)
end
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
unless USING_RVM
skip 'Must have RVM installed.'
next
end
# Don't proceed if the working copy is dirty!
expect(Annotate::Integration.clean?(test_rig)).to eq(true)
skip 'temporarily ignored until Travis can run them'
Bundler.with_clean_env do
dir base_dir do
temp_dir = Dir.pwd
expect(File.basename(temp_dir)).to eq(base_dir)
# Delete cruft from hands-on debugging...
Annotate::Integration.nuke_cruft(test_rig)
# Copy everything to our test directory...
exclusions = ["#{test_rig}/.", "#{test_rig}/.."]
files = (FileList["#{test_rig}/*", "#{test_rig}/.*"] - exclusions).to_a
# We want to NOT preserve symlinks during this copy...
system("rsync -aL #{files.shelljoin} #{temp_dir.shellescape}")
# By default, rvm_ruby_string isn't inherited over properly, so let's
# make sure it's there so our .rvmrc will work.
ENV['rvm_ruby_string'] = CURRENT_RUBY
require base_dir.to_s # Will get "#{base_dir}.rb"...
klass = "Annotate::Validations::#{base_dir.tr('.', '_').classify}".constantize
Dir.chdir(temp_dir) do
# bash is required by rvm
# the shopt command forces us out of "strict sh" mode
commands = <<-BASH
export AUTOMATED_TEST="#{BASEDIR}";
shopt -u -o posix;
source .rvmrc &&
(bundle check || bundle install) &&
#{klass.test_commands}
BASH
output = `/usr/bin/env bash -c '#{commands}' 2>&1`.chomp
klass.verify_output(output)
klass.verify_files(test_rig)
end
end
end
end
end
end
require 'common_validation'
module Annotate
module Validations
class Rails23WithBundler < Base
def self.schema_annotation
<<-RUBY
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string(255)
# created_at :datetime
# updated_at :datetime
#
RUBY
end
def self.route_annotation
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) {:controller=>"tasks", :action=>"index"}
# POST /tasks(.:format) {:controller=>"tasks", :action=>"create"}
# new_task GET /tasks/new(.:format) {:controller=>"tasks", :action=>"new"}
# edit_task GET /tasks/:id/edit(.:format) {:controller=>"tasks", :action=>"edit"}
# task GET /tasks/:id(.:format) {:controller=>"tasks", :action=>"show"}
# PUT /tasks/:id(.:format) {:controller=>"tasks", :action=>"update"}
# DELETE /tasks/:id(.:format) {:controller=>"tasks", :action=>"destroy"}
#
RUBY
end
end
end
end
../../fixtures/rvmrc.sh
\ No newline at end of file
# This file is a hybrid file meant for live debugging without going through an
# actual RSpec run, and for being used in an RSpec run. To change it, change
# template.Gemfile and run 'rake templates:rebuild' which will do so for all
# templates in all build scenarios.
#
# ALSO, be sure NOT to commit any changes that happen in app/* or config/*
# when debugging this way as that will defeat the point of the automated tests!
#
# In fact, before running RSpec again after manual testing, you should run
# 'rake integration:clober' to reset modified files to their pristine state,
# and remove cruft that may interfere with the build.
source 'https://rubygems.org'
gem 'bundler'
gem 'rake', '~>0.8.7', :require => false
gem 'rails', '~>2.3.14'
gem 'sqlite3'
group :development do
if(ENV['AUTOMATED_TEST'] && ENV['AUTOMATED_TEST'] != '')
gem 'annotate', :path => ENV['AUTOMATED_TEST']
else
gem 'annotate', :path => '../../..'
end
end
PATH
remote: ../../..
specs:
annotate (2.5.0)
activerecord
rake
GEM
remote: https://rubygems.org/
specs:
actionmailer (2.3.14)
actionpack (= 2.3.14)
actionpack (2.3.14)
activesupport (= 2.3.14)
rack (~> 1.1.0)
activerecord (2.3.14)
activesupport (= 2.3.14)
activeresource (2.3.14)
activesupport (= 2.3.14)
activesupport (2.3.14)
rack (1.1.3)
rails (2.3.14)
actionmailer (= 2.3.14)
actionpack (= 2.3.14)
activerecord (= 2.3.14)
activeresource (= 2.3.14)
activesupport (= 2.3.14)
rake (>= 0.8.3)
rake (0.8.7)
sqlite3 (1.3.5)
PLATFORMS
ruby
DEPENDENCIES
annotate!
bundler
rails (~> 2.3.14)
rake (~> 0.8.7)
sqlite3
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
defined? Rails::Initializer
end
def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end
def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end
class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
end
end
class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end
def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => e
if e.message =~ /Could not find RubyGem rails/
$stderr.puts "Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed."
exit 1
else
raise
end
end
class << self
def rubygems_version
Gem::RubyGemsVersion rescue nil
end
def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end
def load_rubygems
min_version = '1.3.2'
require 'rubygems'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end
private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
end
# All that for this:
class Rails::Boot
def run
load_initializer
Rails::Initializer.class_eval do
def load_gems
@bundler_loaded ||= Bundler.require :default, Rails.env
end
end
Rails::Initializer.run(:set_load_path)
end
end
Rails.boot!
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 1
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 1
timeout: 5000
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.frameworks -= [ :active_resource, :action_mailer ]
end
config.cache_classes = false
config.whiny_nils = true
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_view.debug_rjs = true
config.action_mailer.raise_delivery_errors = false
config.cache_classes = true
config.whiny_nils = true
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_controller.allow_forgery_protection = false
config.action_view.cache_template_loading = true
config.action_mailer.delivery_method = :test
# new_rails_defaults.rb
if defined?(ActiveRecord)
ActiveRecord::Base.include_root_in_json = true
ActiveRecord::Base.store_full_sti_class = true
end
ActionController::Routing.generate_best_match = false
ActiveSupport.use_standard_json_time_format = true
ActiveSupport.escape_html_entities_in_json = false
# session_store.rb
ActionController::Base.session = {
:key => '_session',
:secret => 'a61ce930be7219beee70d3e3411e0794d90ab22d12e87a1f7f50c98ad7b08771ed92e72e1a7299c8ec4795d45d566a39e0a0a1f7e7095e2eeb31320a0c5d7ee5'
}
# cookie_verification_secret.rb
ActionController::Base.cookie_verifier_secret = '1b2363a161fbf01041bd9d0b0d9a332e5c7445503c9e89585c8a248698d28054e3918fa77a0206e662629ee9a00d2831949e74801f27ee85ba2116b62b675935';
# Hacks for Ruby 1.9.3...
MissingSourceFile::REGEXPS << [/^cannot load such file -- (.+)$/i, 1]
ActionController::Routing::Routes.draw do |map|
map.resources :tasks
end
class CreateTasks < ActiveRecord::Migration
def self.up
create_table :tasks do |t|
t.string :content
t.timestamps
end
end
def self.down
drop_table :tasks
end
end
# This file is auto-generated from the current state of the database. Instead of editing this file,
# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
# to create the application database on another system, you should be using db:schema:load, not running
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120816085200) do
create_table "tasks", :force => true do |t|
t.string "content"
t.datetime "created_at"
t.datetime "updated_at"
end
end
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
content: MyString
two:
content: MyString
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::TestCase
end
require 'test_helper'
class TaskTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
require 'common_validation'
module Annotate
module Validations
class Rails322 < Base
def self.schema_annotation
<<-RUBY
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
RUBY
end
def self.route_annotation
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) tasks#index
# POST /tasks(.:format) tasks#create
# new_task GET /tasks/new(.:format) tasks#new
# edit_task GET /tasks/:id/edit(.:format) tasks#edit
# task GET /tasks/:id(.:format) tasks#show
# PUT /tasks/:id(.:format) tasks#update
# DELETE /tasks/:id(.:format) tasks#destroy
#
RUBY
end
end
end
end
../../fixtures/rvmrc.sh
\ No newline at end of file
# This file is a hybrid file meant for live debugging without going through an
# actual RSpec run, and for being used in an RSpec run. To change it, change
# template.Gemfile and run 'rake templates:rebuild' which will do so for all
# templates in all build scenarios.
#
# ALSO, be sure NOT to commit any changes that happen in app/* or config/*
# when debugging this way as that will defeat the point of the automated tests!
#
# In fact, before running RSpec again after manual testing, you should run
# 'rake integration:clober' to reset modified files to their pristine state,
# and remove cruft that may interfere with the build.
source 'https://rubygems.org'
gem 'rails', '3.2.2'
gem 'sqlite3'
group :development do
if(ENV['AUTOMATED_TEST'] && ENV['AUTOMATED_TEST'] != '')
gem 'annotate', :path => ENV['AUTOMATED_TEST']
else
gem 'annotate', :path => '../../..'
end
end
PATH
remote: ../../..
specs:
annotate (2.5.0)
activerecord
rake
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
json (1.7.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (~> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
PLATFORMS
ruby
DEPENDENCIES
annotate!
rails (= 3.2.2)
sqlite3
../../fixtures/rails_32_rakefile
\ No newline at end of file
../../../fixtures/rails_32old_application.rb
\ No newline at end of file
../../../fixtures/rails32_boot.rb
\ No newline at end of file
../../../fixtures/database.yml
\ No newline at end of file
../../../fixtures/rails_32_environment.rb
\ No newline at end of file
../../../../fixtures/rails_32_development.rb
\ No newline at end of file
../../../../fixtures/rails_32_test.rb
\ No newline at end of file
../../../../fixtures/rails32_unified_initializer.rb
\ No newline at end of file
TestApp::Application.routes.draw do
resources :tasks
end
../../../../fixtures/20120816164927_create_tasks.rb
\ No newline at end of file
../../../fixtures/rails_32_schema.rb
\ No newline at end of file
../../../fixtures/rails_32_rails
\ No newline at end of file
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
content: MyString
two:
content: MyString
../../../fixtures/rails_32_test_helper.rb
\ No newline at end of file
require 'test_helper'
class TaskTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
require 'common_validation'
module Annotate
module Validations
class Rails328 < Base
def self.schema_annotation
<<-RUBY
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
RUBY
end
def self.route_annotation
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) tasks#index
# POST /tasks(.:format) tasks#create
# new_task GET /tasks/new(.:format) tasks#new
# edit_task GET /tasks/:id/edit(.:format) tasks#edit
# task GET /tasks/:id(.:format) tasks#show
# PUT /tasks/:id(.:format) tasks#update
# DELETE /tasks/:id(.:format) tasks#destroy
#
RUBY
end
end
end
end
../../fixtures/rvmrc.sh
\ No newline at end of file
../../fixtures/rails_328_gemfile
\ No newline at end of file
../../fixtures/rails_328_gemfile.lock
\ No newline at end of file
../../fixtures/rails_32_rakefile
\ No newline at end of file
class Task < ActiveRecord::Base
attr_accessible :content
end
require File.expand_path('../boot', __FILE__)
require "active_record/railtie"
require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
end
module TestApp
class Application < Rails::Application
config.active_record.whitelist_attributes = true
config.active_support.escape_html_entities_in_json = true
config.assets.enabled = false
end
end
../../../fixtures/rails32_boot.rb
\ No newline at end of file
../../../fixtures/database.yml
\ No newline at end of file
../../../fixtures/rails_32_environment.rb
\ No newline at end of file
../../../../fixtures/rails_32_development.rb
\ No newline at end of file
../../../../fixtures/rails_32_test.rb
\ No newline at end of file
../../../../fixtures/rails32_unified_initializer.rb
\ No newline at end of file
TestApp::Application.routes.draw do
resources :tasks
end
../../../../fixtures/20120816164927_create_tasks.rb
\ No newline at end of file
../../../fixtures/rails_32_schema.rb
\ No newline at end of file
../../../fixtures/rails_32_rails
\ No newline at end of file
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
content: MyString
two:
content: MyString
../../../fixtures/rails_32_test_helper.rb
\ No newline at end of file
require 'test_helper'
class TaskTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
require 'common_validation'
module Annotate
module Validations
class Rails32AutoloadingFactoryGirl < Base
def self.schema_annotation
<<-RUBY
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
RUBY
end
def self.route_annotation
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) tasks#index
# POST /tasks(.:format) tasks#create
# new_task GET /tasks/new(.:format) tasks#new
# edit_task GET /tasks/:id/edit(.:format) tasks#edit
# task GET /tasks/:id(.:format) tasks#show
# PUT /tasks/:id(.:format) tasks#update
# DELETE /tasks/:id(.:format) tasks#destroy
#
RUBY
end
def self.verify_files(test_rig)
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
end
../../fixtures/rvmrc.sh
\ No newline at end of file
# This file is a hybrid file meant for live debugging without going through an
# actual RSpec run, and for being used in an RSpec run. To change it, change
# template.Gemfile and run 'rake templates:rebuild' which will do so for all
# templates in all build scenarios.
#
# ALSO, be sure NOT to commit any changes that happen in app/* or config/*
# when debugging this way as that will defeat the point of the automated tests!
#
# In fact, before running RSpec again after manual testing, you should run
# 'rake integration:clober' to reset modified files to their pristine state,
# and remove cruft that may interfere with the build.
source 'https://rubygems.org'
gem 'rails', '3.2.2'
gem 'sqlite3'
group :development do
if(ENV['AUTOMATED_TEST'] && ENV['AUTOMATED_TEST'] != '')
gem 'annotate', :path => ENV['AUTOMATED_TEST']
else
gem 'annotate', :path => '../../..'
end
end
group :test do
gem 'factory_girl'
gem 'factory_girl_rails'
end
PATH
remote: ../../..
specs:
annotate (2.5.0)
activerecord
rake
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
erubis (2.7.0)
factory_girl (4.0.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.0.0)
factory_girl (~> 4.0.0)
railties (>= 3.0.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
json (1.7.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (~> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
PLATFORMS
ruby
DEPENDENCIES
annotate!
factory_girl
factory_girl_rails
rails (= 3.2.2)
sqlite3
../../fixtures/rails_32_rakefile
\ No newline at end of file
../../../fixtures/rails_32old_application.rb
\ No newline at end of file
../../../fixtures/rails32_boot.rb
\ No newline at end of file
../../../fixtures/database.yml
\ No newline at end of file
../../../fixtures/rails_32_environment.rb
\ No newline at end of file
../../../../fixtures/rails_32_development.rb
\ No newline at end of file
../../../../fixtures/rails_32_test.rb
\ No newline at end of file
../../../../fixtures/rails32_unified_initializer.rb
\ No newline at end of file
TestApp::Application.routes.draw do
resources :tasks
end
../../../../fixtures/20120816164927_create_tasks.rb
\ No newline at end of file
../../../fixtures/rails_32_schema.rb
\ No newline at end of file
../../../fixtures/rails_32_rails
\ No newline at end of file
# Read about factories at https://github.com/thoughtbot/factory_bot
FactoryGirl.define do
factory :task do
content "MyString"
end
end
../../../fixtures/rails_32_test_helper.rb
\ No newline at end of file
require 'test_helper'
class TaskTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
require 'common_validation'
module Annotate
module Validations
class Rails32CustomInflection < Base
def self.schema_annotation
<<-RUBY
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
RUBY
end
def self.route_annotation
<<-RUBY
# == Route Map (Updated YYYY-MM-DD HH:MM)
#
# tasks GET /tasks(.:format) tasks#index
# POST /tasks(.:format) tasks#create
# new_task GET /tasks/new(.:format) tasks#new
# edit_task GET /tasks/:id/edit(.:format) tasks#edit
# task GET /tasks/:id(.:format) tasks#show
# PUT /tasks/:id(.:format) tasks#update
# DELETE /tasks/:id(.:format) tasks#destroy
#
RUBY
end
def self.verify_output(output)
output.should =~ /Annotated \(1\): TASk/
output.should =~ /Route file annotated./
end
end
end
end
../../fixtures/rvmrc.sh
\ No newline at end of file
../../fixtures/rails_328_gemfile
\ No newline at end of file
../../fixtures/rails_328_gemfile.lock
\ No newline at end of file
../../fixtures/rails_32_rakefile
\ No newline at end of file
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