public
Description: Resources for rspec developers/contributors
Homepage: http://rspec.info/
Clone URL: git://github.com/dchelimsky/rspec-dev.git
Cleaning up Formatter. Making migrations less fragile to different versions of 
Rails.
btakita (author)
Wed May 21 23:29:42 -0700 2008
commit  d1782a195aa6040f3ef1c1654117e750bbf7a042
tree    c0b8f790b01731a1ad9838b64d588d737dcf7e47
parent  de7f9e0667c09e354ee0a60054988fa93b266a11
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
61
62
63
...
66
67
68
69
70
 
...
 
 
 
 
 
 
 
 
 
 
1
2
3
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
6
7
8
 
 
 
 
 
 
 
 
 
 
 
 
9
10
 
 
 
 
 
 
 
 
 
 
 
11
 
12
13
14
15
...
18
19
20
 
21
22
0
@@ -1,63 +1,15 @@
0
-# Be sure to restart your web server when you modify this file.
0
-
0
-# Uncomment below to force Rails into production mode when 
0
-# you don't control web/app server and can't set it the proper way
0
-# ENV['RAILS_ENV'] ||= 'production'
0
-
0
-# Specifies gem version of Rails to use when vendor/rails is not present
0
-# RAILS_GEM_VERSION = '1.1.6'
0
-
0
-# Bootstrap the Rails environment, frameworks, and default configuration
0
 require File.join(File.dirname(__FILE__), 'boot')
0
 require "rubygems"
0
 
0
 Rails::Initializer.run do |config|
0
-  # Settings in config/environments/* take precedence those specified here
0
-  
0
-  # Skip frameworks you're not going to use
0
-  # config.frameworks -= [ :action_web_service, :action_mailer ]
0
-
0
-  # Add additional load paths for your own custom dirs
0
-  # config.load_paths += %W( #{RAILS_ROOT}/extras )
0
-
0
-  # Force all environments to use the same logger level 
0
-  # (by default production uses :info, the others :debug)
0
-  # config.log_level = :debug
0
-
0
-  # Use the database for sessions instead of the file system
0
-  # (create the session table with 'rake db:sessions:create')
0
-  # config.action_controller.session_store = :active_record_store
0
 #  config.action_controller.session = {
0
 #    :session_key => '_example_rails_app',
0
 #    :secret      => '78b197e00cca77859c1e77d6498d16cd'
0
 #  }
0
-  # Use SQL instead of Active Record's schema dumper when creating the test database.
0
-  # This is necessary if your schema can't be completely dumped by the schema dumper, 
0
-  # like if you have constraints or database-specific column types
0
-  # config.active_record.schema_format = :sql
0
-
0
-  # Activate observers that should always be running
0
-  # config.active_record.observers = :cacher, :garbage_collector
0
-
0
-  # Make Active Record use UTC-base instead of local time
0
-  # config.active_record.default_timezone = :utc
0
-  
0
-  # See Rails::Configuration for more options
0
 end
0
 
0
-# Add new inflection rules using the following format 
0
-# (all these examples are active by default):
0
-# Inflector.inflections do |inflect|
0
-#   inflect.plural /^(ox)$/i, '\1en'
0
-#   inflect.singular /^(ox)en/i, '\1'
0
-#   inflect.irregular 'person', 'people'
0
-#   inflect.uncountable %w( fish sheep )
0
-# end
0
-
0
-# Include your application configuration below
0
-
0
 def in_memory_database?
0
-  ENV["RAILS_ENV"] == "test" and 
0
+  ENV["RAILS_ENV"] == "test" and
0
   ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
0
   Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
0
 end
0
@@ -66,4 +18,4 @@ if in_memory_database?
0
   puts "creating sqlite in memory database"
0
   # load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
0
   ActiveRecord::Migrator.up('db/migrate') # use migrations
0
-end
0
\ No newline at end of file
0
+end
...
3
4
5
6
 
7
8
9
10
 
11
12
...
3
4
5
 
6
7
8
9
 
10
11
12
0
@@ -3,10 +3,10 @@ class InitialSchema < ActiveRecord::Migration
0
     create_table :people do |t|
0
       t.column :name, :string, :default => nil
0
       t.column :address, :text
0
-    end
0
+    end rescue nil
0
   end
0
 
0
   def self.down
0
-    drop_table :people
0
+    drop_table :people rescue nil
0
   end
0
 end
...
4
5
6
7
 
8
9
10
11
 
12
13
...
4
5
6
 
7
8
9
10
 
11
12
13
0
@@ -4,10 +4,10 @@ class CreateAnimals < ActiveRecord::Migration
0
       t.column :name,      :string, :default => nil
0
       t.column :person_id, :integer
0
       t.column :age, :float
0
-    end
0
+    end rescue nil
0
   end
0
 
0
   def self.down
0
-    drop_table :animals
0
+    drop_table :animals rescue nil
0
   end
0
 end
...
2
3
4
5
 
6
7
8
9
 
10
11
12
...
2
3
4
 
5
6
7
8
 
9
10
11
12
0
@@ -2,11 +2,11 @@ class CreateThings < ActiveRecord::Migration
0
   def self.up
0
     create_table :things do |t|
0
       t.column :name,      :string, :default => nil
0
-    end
0
+    end rescue nil
0
   end
0
 
0
   def self.down
0
-    drop_table :things
0
+    drop_table :things rescue nil
0
   end
0
 end
0
  
...
2
3
4
5
 
6
7
8
 
9
10
11
12
13
 
 
14
15
16
...
2
3
4
 
5
6
7
 
8
9
10
11
 
 
12
13
14
15
16
0
@@ -2,15 +2,15 @@ class CreateMockables < ActiveRecord::Migration
0
   def self.up
0
     create_table :mockable_models do |t|
0
       t.column :name, :string
0
-    end
0
+    end rescue nil
0
     create_table :associated_models do |t|
0
       t.column :mockable_model_id, :integer
0
-    end
0
+    end rescue nil
0
   end
0
 
0
   def self.down
0
-    drop_table :mockable_models
0
-    drop_table :associated_models
0
+    drop_table :mockable_models rescue nil
0
+    drop_table :associated_models rescue nil
0
   end
0
 end
0
  
...
42
43
44
45
46
47
 
48
49
50
...
57
58
59
 
60
61
62
...
42
43
44
 
45
46
47
48
49
50
...
57
58
59
60
61
62
63
0
@@ -42,9 +42,9 @@ class PreCommit::RspecOnRails < PreCommit
0
       sh "git checkout #{pair[:tag]}"
0
     end
0
     puts "#####################################################"
0
-    cleanup(cleanup_rspec)
0
     ensure_db_config
0
     clobber_sqlite_data
0
+    cleanup(cleanup_rspec)
0
     generate_rspec
0
 
0
     generate_login_controller
0
@@ -57,6 +57,7 @@ class PreCommit::RspecOnRails < PreCommit
0
     # a clean DB?
0
     rake_sh "db:test:prepare"
0
     sh "ruby vendor/plugins/rspec-rails/stories/all.rb"
0
+  ensure
0
     cleanup(cleanup_rspec)
0
   end
0
 

Comments