Commit 8e070848 by Jon Frisby

Overhauling integration test mechanism.

parent bb0db218
......@@ -8,6 +8,12 @@
/Gemfile.lock
*.gem
/.idea/
.rvmrc
/.rvmrc
.bundle
/.rbx
/spec/integration/*/bin/
/spec/integration/*/log/*
!/spec/integration/*/log/.gitkeep
/spec/integration/*/tmp/*
!/spec/integration/*/tmp/.gitkeep
/spec/integration/*/db/test.*
......@@ -15,6 +15,12 @@
* Added support for new FactoryGirl naming convention.
* Fix behavior of route annotations in newer versions of Rake that don't spit
out the CWD as their first line of output.
* Overhauled integration testing system to be much easier to work with, better
compartmentalized, and so forth -- at the cost that you must be using RVM to
utilize it. (It'll spit out appropriate pending messages if you don't.)
Also includes a mode for "tinkering" by hand with a scenario, and won't let
you run it through rspect if the repo is in a dirty state. Added appropriate
rake tasks to help with all of this.
* Routes can now be appended, pre-pended, or removed -- and do sane things in
all cases.
* Expose all `position_*` variables as CLI params.
......
......@@ -31,6 +31,88 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ['--backtrace', '--format d']
end
# Placeholder for running bin/* in development...
task :environment
task :integration_environment do
require './spec/spec_helper'
end
namespace :gemsets do
desc "Completely empty any gemsets used by scenarios, so they'll be perfectly clean on the next run."
task :empty => [:integration_environment] do
Annotate::Integration::SCENARIOS.each do |test_rig, base_dir, test_name|
Annotate::Integration.empty_gemset(test_rig)
end
end
end
task :clobber => :'gemsets:empty'
namespace :integration do
desc "Remove any cruft generated by manual debugging runs which is .gitignore'd."
task :clean => :integration_environment do
Annotate::Integration.nuke_all_cruft
end
desc "Reset any changed files, and remove any untracked files in spec/integration/*/, plus run integration:clean."
task :clobber => [:integration_environment, :'integration:clean'] do
Annotate::Integration.reset_dirty_files
Annotate::Integration.clear_untracked_files
end
task :symlink => [:integration_environment] do
require 'digest/md5'
integration_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'integration'))
fixture_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'fixtures'))
target_dir = File.expand_path(ENV['TARGET']) if(ENV['TARGET'])
raise "Must specify TARGET=x, where x is an integration test scenario!" unless(target_dir && Dir.exist?(target_dir))
raise "TARGET directory must be within spec/integration/!" unless(target_dir.start_with?(integration_dir))
candidates = {}
FileList[
"#{target_dir}/.rvmrc",
"#{target_dir}/**/*"
].select { |fname| !(File.symlink?(fname) || File.directory?(fname)) }.
map { |fname| fname.sub(integration_dir, '') }.
reject do |fname|
fname =~ /\/\.gitkeep$/ ||
fname =~ /\/app\/models\// ||
fname =~ /\/routes\.rb$/ ||
fname =~ /\/fixtures\// ||
fname =~ /\/factories\// ||
fname =~ /\.sqlite3$/ ||
(fname =~ /\/test\// && fname !~ /_helper\.rb$/) ||
(fname =~ /\/spec\// && fname !~ /_helper\.rb$/)
end.
map { |fname| "#{integration_dir}#{fname}"}.
each do |fname|
digest = Digest::MD5.hexdigest(File.read(fname))
candidates[digest] ||= []
candidates[digest] << fname
end
fixtures = {}
FileList["spec/fixtures/**/*"].each do |fname|
fixtures[Digest::MD5.hexdigest(File.read(fname))] = File.expand_path(fname)
end
candidates.keys.each do |digest|
if(fixtures.has_key?(digest))
candidates[digest].each do |fname|
# Double-check contents in case of hash collision...
if(FileUtils.identical?(fname, fixtures[digest]))
destination_dir = Pathname.new(File.dirname(fname))
relative_target = Pathname.new(fixtures[digest]).relative_path_from(destination_dir)
Dir.chdir(destination_dir) do
sh("ln", "-sfn", relative_target.to_s, File.basename(fname))
end
end
end
end
end
end
end
task :clobber => :'integration:clobber'
require 'yard'
YARD::Rake::YardocTask.new do |t|
# t.files = ['features/**/*.feature', 'features/**/*.rb', 'lib/**/*.rb']
......
class CreateTasks < ActiveRecord::Migration
def change
create_table :tasks do |t|
t.string :content
t.timestamps
end
end
end
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 1
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 1
timeout: 5000
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
# secret_token.rb
TestApp::Application.config.secret_token = '4768b21141022d583b141fde0db7e0b31759321b7fce459963914fdd82db248ea0318d9568030dcde70d404d4e86003ce5f51a7a83c8130842e5a97062b68c3c'
# session_store.rb
TestApp::Application.config.session_store :cookie_store, key: '_session'
# wrap_parameters.rb
ActiveSupport.on_load(:active_record) { self.include_root_in_json = false }
# 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.8'
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.beta4)
activesupport (>= 2.3.0)
rake (>= 0.8.7)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
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.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.8)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
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.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
PLATFORMS
ruby
DEPENDENCIES
annotate!
rails (= 3.2.8)
sqlite3
TestApp::Application.configure do
config.action_dispatch.best_standards_support = :builtin
config.active_record.auto_explain_threshold_in_seconds = 0.5
config.active_record.mass_assignment_sanitizer = :strict
config.active_support.deprecation = :log
config.cache_classes = false
config.consider_all_requests_local = true
config.whiny_nils = true
end
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
TestApp::Application.initialize!
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
#!/usr/bin/env rake
# 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.expand_path('../config/application', __FILE__)
TestApp::Application.load_tasks
# encoding: UTF-8
# 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 => 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
TestApp::Application.configure do
config.action_dispatch.show_exceptions = false
config.active_record.mass_assignment_sanitizer = :strict
config.active_support.deprecation = :stderr
config.cache_classes = true
config.consider_all_requests_local = true
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
config.whiny_nils = true
end
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
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.assets.enabled = false
end
end
# 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..rvmrc 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.
if [ "$(type rvm | head -1)" != "rvm is a function" ]; then
# First, make sure we're not in 'sh' mode (I.E. strict-superset-of-Bourne
# mode), as RVM doesn't like this...
shopt -u -o posix
# Now, load RVM...
source $HOME/.rvm/scripts/rvm
fi
# Now, switch to our preferred Ruby and gemset...
GEMSET=annotate_test_$(basename $(pwd) | perl -pse 's/\.//g')
rvm use --create ${rvm_ruby_string}@${GEMSET}
# Early-out when we just want to wipe the gemsets clean...
if [ "$SKIP_BUNDLER" != "1" ]; then
# ... and make sure everything's up-to-date, that it'll use the right Gemfile,
# etc.
if [ $(which bundle) == "" ]; then
gem install bundler
fi
export BUNDLE_GEMFILE=./Gemfile
# The apparently superfluous --gemfile param is to work around some stupidness
# in Bundler. Specifically it gets very confused about BUNDLE_GEMFILE not
# pointing at an absolute path.
#
# The special-case handling of bin being empty is to support debug workflows
# where the gemset will in fact already be set up, but the binstubs get nuked.
mkdir -p bin
if [ $(($(ls bin | wc -l) + 0)) -eq 0 ]; then
bundle install --binstubs=bin --gemfile ./Gemfile
else
bundle check || bundle install --binstubs=bin --gemfile ./Gemfile
fi
fi
module Annotate
module Validations
module Common
def self.test_commands
return %q{
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_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
protected
def self.apply_annotation(test_rig, fname, annotation, place_before=true)
corpus = File.read(File.join(test_rig, fname))
if(place_before)
corpus = annotation + "\n" + corpus
else
corpus = corpus + "\n" + annotation
end
end
end
end
end
module Annotate
module Validations
class Base
def self.test_commands
return Annotate::Validations::Common.test_commands
end
def self.verify_output(output)
return 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)
end
def self.foo
require 'pry'
require 'pry-coolline'
binding.pry
end
end
end
end
# Smoke test to assure basic functionality works on a variety of Rails versions.
$:.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
here = File.expand_path('..', __FILE__)
chosen_scenario = nil
if(!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
if(!USING_RVM)
pending "Must have RVM installed."
next
end
# Don't proceed if the working copy is dirty!
Annotate::Integration.is_clean?(test_rig).should == true
Bundler.with_clean_env do
dir base_dir do
temp_dir = Dir.pwd
File.basename(temp_dir).should == 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}" # Will get "#{base_dir}.rb"...
klass = "Annotate::Validations::#{base_dir.gsub('.', '_').classify}".constantize
Dir.chdir(temp_dir) do
output = `
(
export AUTOMATED_TEST="#{BASEDIR}"
source .rvmrc &&
#{klass.test_commands}
) 2>&1`.chomp
klass.verify_output(output)
klass.verify_files(test_rig)
end
end
end
end
end
end
source :rubygems
gem "rails", "~>2.3"
gem "sqlite3"
source :rubygems
gem 'rails', "~>3.2"
gem "sqlite3"
gem "jquery-rails"
gem "coffee-rails"
gem "sass-rails"
gem "uglifier"
require 'common_validation'
module Annotate
module Validations
class Rails23WithBundler < Base
def self.schema_annotation
return <<-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
return <<-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
tmp/*
!tmp/.gitkeep
log/*
!log/.gitkeep
../../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.beta4)
activesupport (>= 2.3.0)
rake (>= 0.8.7)
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
actionmailer (2.3.14)
actionpack (= 2.3.14)
......@@ -19,12 +26,15 @@ GEM
activeresource (= 2.3.14)
activesupport (= 2.3.14)
rake (>= 0.8.3)
rake (0.9.2.2)
rake (0.8.7)
sqlite3 (1.3.5)
PLATFORMS
ruby
DEPENDENCIES
rails (~> 2.3)
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 => load_error
if load_error.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
return <<-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
return <<-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.beta4)
activesupport (>= 2.3.0)
rake (>= 0.8.7)
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
class Task < ActiveRecord::Base
end
../../../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
return <<-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
return <<-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
return <<-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
return <<-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)
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)
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.beta4)
activesupport (>= 2.3.0)
rake (>= 0.8.7)
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_girl
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
return <<-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
return <<-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
class TASk < ActiveRecord::Base
attr_accessible :content
end
../../../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
# secret_token.rb
TestApp::Application.config.secret_token = '4768b21141022d583b141fde0db7e0b31759321b7fce459963914fdd82db248ea0318d9568030dcde70d404d4e86003ce5f51a7a83c8130842e5a97062b68c3c'
# session_store.rb
TestApp::Application.config.session_store :cookie_store, key: '_session'
# wrap_parameters.rb
ActiveSupport.on_load(:active_record) { self.include_root_in_json = false }
# inflections.rb
ActiveSupport::Inflector.inflections do |inflect|
inflect.acronym 'TASk'
end
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 Rails32WithAssetPipeline < Base
def self.schema_annotation
return <<-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
return <<-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'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
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.beta4)
activesupport (>= 2.3.0)
rake (>= 0.8.7)
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
actionmailer (3.2.7)
actionpack (= 3.2.7)
mail (~> 2.4.4)
actionpack (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
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.4)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.7)
activesupport (= 3.2.7)
sprockets (~> 2.1.2)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
activesupport (3.2.7)
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)
......@@ -43,9 +50,6 @@ GEM
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.7.4)
mail (2.4.4)
i18n (>= 0.4.0)
......@@ -61,25 +65,25 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.7)
actionmailer (= 3.2.7)
actionpack (= 3.2.7)
activerecord (= 3.2.7)
activeresource (= 3.2.7)
activesupport (= 3.2.7)
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.7)
railties (3.2.7)
actionpack (= 3.2.7)
activesupport (= 3.2.7)
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, < 2.0)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sass (3.1.20)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
......@@ -89,13 +93,13 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
thor (0.15.4)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.6)
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
......@@ -103,9 +107,9 @@ PLATFORMS
ruby
DEPENDENCIES
coffee-rails
jquery-rails
rails (~> 3.2)
sass-rails
annotate!
coffee-rails (~> 3.2.1)
rails (= 3.2.2)
sass-rails (~> 3.2.3)
sqlite3
uglifier
uglifier (>= 1.0.3)
../../fixtures/rails_32_rakefile
\ No newline at end of file
require File.expand_path('../boot', __FILE__)
require "active_record/railtie"
require "sprockets/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.assets.enabled = true
config.assets.version = '1.0'
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
TestApp::Application.configure do
config.action_dispatch.best_standards_support = :builtin
config.active_record.auto_explain_threshold_in_seconds = 0.5
config.active_record.mass_assignment_sanitizer = :strict
config.active_support.deprecation = :log
config.assets.compress = false
config.assets.debug = true
config.cache_classes = false
config.consider_all_requests_local = true
config.whiny_nils = true
end
../../../../fixtures/rails_32_test.rb
\ No newline at end of file
# secret_token.rb
TestApp::Application.config.secret_token = '4768b21141022d583b141fde0db7e0b31759321b7fce459963914fdd82db248ea0318d9568030dcde70d404d4e86003ce5f51a7a83c8130842e5a97062b68c3c'
# session_store.rb
TestApp::Application.config.session_store :cookie_store, key: '_session'
# wrap_parameters.rb
ActiveSupport.on_load(:action_controller) { wrap_parameters format: [:json] }
ActiveSupport.on_load(:active_record) { self.include_root_in_json = false }
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
# Smoke test to assure basic functionality works on a variety of Rails versions.
require 'files'
require 'wrong'
include Files
include Wrong::D
describe "annotate inside Rails" do
here = File.expand_path(File.dirname __FILE__)
['3.2', '2.3'].each do |base_version|
it "works under Rails #{base_version}" do
base_dir = "rails-#{base_version}"
gemfile = "#{here}/#{base_dir}.gems"
annotate_bin = File.expand_path "#{here}/../../bin/annotate"
Bundler.with_clean_env do
dir base_dir do
temp_dir = Dir.pwd
File.basename(Dir.pwd).should == base_dir
rails_cmd = "#{temp_dir}/rails"
case base_version
when /^2\./
new_cmd = "#{rails_cmd}"
generate_cmd = "script/generate"
when /^3\./
new_cmd = "#{rails_cmd} new"
generate_cmd = "#{rails_cmd} generate"
end
# todo: optionally use rvm
`bundle install --binstubs=#{temp_dir} --gemfile #{gemfile}`.should =~ /Your bundle is complete/
rails_version = `#{rails_cmd} -v`.chomp
rails_version.should =~ /^Rails/
rails_version = rails_version.split(" ").last
rails_version.should =~ /(\d+)(\.\d+)*/
rails_version.should =~ /^#{base_version}/
puts "\nUsing Rails #{rails_version}"
def process_model text, base_version
if base_version == "2.3"
# for some reason timestamps are nullable in Rails 2.3.14
text.gsub!(/datetime +not null/, "datetime")
text.gsub!(" attr_accessible :content\n", '')
end
end
`#{new_cmd} todo`
Dir.chdir("#{temp_dir}/todo") do
`#{generate_cmd} scaffold Task content:string`.should =~ %r{db/migrate/.*_create_tasks.rb}
`../rake db:migrate`.should =~ /CreateTasks: migrated/
expected_model = <<-RUBY
class Task < ActiveRecord::Base
attr_accessible :content
end
RUBY
process_model(expected_model, base_version)
File.read("app/models/task.rb").should == expected_model
`#{annotate_bin}`.chomp.should == "Annotated (1): Task"
expected_model = <<-RUBY + expected_model
# == 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
process_model(expected_model, base_version)
File.read("app/models/task.rb").should == expected_model
end
end
end
end
end
end
require 'common_validation'
module Annotate
module Validations
class Standalone < Base
def self.schema_annotation
return <<-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.test_commands
return %q{
bin/annotate --require ./config/init.rb
}
end
def self.verify_output(output)
output.should =~ /Annotated \(1\): Task/
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)
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 'activerecord', '3.2.8'
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.beta4)
activesupport (>= 2.3.0)
rake (>= 0.8.7)
GEM
remote: https://rubygems.org/
specs:
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
i18n (0.6.0)
multi_json (1.3.6)
rake (0.9.2.2)
sqlite3 (1.3.6)
tzinfo (0.3.33)
PLATFORMS
ruby
DEPENDENCIES
activerecord (= 3.2.8)
annotate!
sqlite3
class Task < ActiveRecord::Base
attr_accessible :content
end
require 'active_record'
ActiveRecord::Base.establish_connection({
adapter: 'sqlite3',
database: 'db/development.sqlite3',
pool: 1,
timeout: 5000
})
../../../fixtures/rails_32_schema.rb
\ No newline at end of file
......@@ -9,5 +9,63 @@ $:.unshift(File.join(File.dirname(__FILE__), '../lib'))
$:.unshift(File.dirname(__FILE__))
require 'active_support'
require 'active_support/core_ext/class/subclasses'
require 'active_support/core_ext/string/inflections'
require 'annotate'
module Annotate
module Integration
ABSOLUTE_GEM_ROOT=File.expand_path('../../', __FILE__)
CRUFT_PATTERNS=[
"%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|
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) }
].each do |fname|
FileUtils.rm_rf(fname)
end
end
def self.nuke_all_cruft
SCENARIOS.each do |test_rig, base_dir, test_name|
nuke_cruft(test_rig)
end
end
def self.empty_gemset(test_rig)
Dir.chdir(test_rig) do
system(%q{
(
export SKIP_BUNDLER=1
source .rvmrc &&
rvm --force gemset empty
) 2>&1
})
end
end
def self.reset_dirty_files
system("git checkout HEAD -- #{SCENARIO_HOME}/*/")
end
def self.clear_untracked_files
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
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