Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11433: add_script_console_for_rails_contributors.diff

File add_script_console_for_rails_contributors.diff, 1.8 kB (added by thechrisoshow, 6 months ago)

Adds script/console for rails contributors

  • activerecord/RUNNING_UNIT_TESTS

    old new  
    2929    
    3030That'll run the base suite using the MySQL-Ruby adapter. 
    3131 
     32== Console 
    3233 
     34There is also a script/console that allows you to examine the Rails test data just like you would a normal rails application.  Use it with: 
    3335 
     36   script/console 
     37 
     38If you want to try it with different database connector pass the adapter name as a parameter.  For example: 
     39 
     40  script/console sqlite3 
     41 
  • activerecord/script/console

    old new  
     1#!/usr/bin/env ruby 
     2irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' 
     3 
     4options = { :irb => irb } 
     5libs =  " -r irb/completion" 
     6libs << %( -r "script/console") 
     7 
     8ENV['ADAPTER'] = ARGV.first || 'mysql' 
     9 
     10puts "Loading #{ENV['ADAPTER']} environment" 
     11 
     12exec "#{options[:irb]} #{libs} --simple-prompt" 
  • activerecord/script/console.rb

    old new  
     1$:.unshift(File.dirname(__FILE__) + '/../test') 
     2$:.unshift(File.dirname(__FILE__) + "/../test/connections/native_#{ENV['ADAPTER']}") 
     3 
     4require 'cases/helper' 
     5 
     6# work around the at_exit hook in test/unit, which kills IRB 
     7Test::Unit.run = true if Test::Unit.respond_to?(:run=) 
     8 
     9Dir.glob("test/models/*.rb").each {|f| require f} 
     10