forked from mislav/will_paginate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix
spec/console
and show nice SQL output
- Loading branch information
Showing
3 changed files
with
28 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#!/usr/bin/env ruby | ||
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' | ||
libs = [] | ||
libs = %w[rubygems irb/completion console_fixtures] | ||
|
||
libs << 'irb/completion' | ||
libs << 'console_fixtures' | ||
args = libs.map { |lib| ['-r', lib] }.flatten | ||
args << '--simple-prompt' | ||
|
||
exec "#{irb} -Ilib:spec#{libs.map{ |l| " -r #{l}" }.join} --simple-prompt" | ||
ENV['RUBYLIB'] = 'lib:spec' | ||
exec irb, *args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
require 'bundler' | ||
Bundler.setup | ||
|
||
require 'will_paginate/finders/active_record' | ||
require 'finders/activerecord_test_connector' | ||
|
||
ActiverecordTestConnector.setup | ||
|
||
windows = RUBY_PLATFORM =~ /(:?mswin|mingw)/ | ||
# used just for the `color` method | ||
log_subscriber = ActiveSupport::LogSubscriber.log_subscribers.first | ||
|
||
IGNORE_SQL = /\b(sqlite_master|sqlite_version)\b|^CREATE TABLE/ | ||
|
||
ActiveSupport::Notifications.subscribe(/^sql\./) do |*args| | ||
data = args.last | ||
unless data[:name] =~ /^Fixture/ or data[:sql] =~ IGNORE_SQL | ||
if windows | ||
puts data[:sql] | ||
else | ||
puts log_subscriber.send(:color, data[:sql], :cyan) | ||
end | ||
end | ||
end | ||
|
||
# load all fixtures | ||
Fixtures.create_fixtures(ActiverecordTestConnector::FIXTURES_PATH, ActiveRecord::Base.connection.tables) | ||
|
||
ActiverecordTestConnector.show_sql | ||
WillPaginate::Finders::ActiveRecord.enable! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters