Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Pry fix #71

wants to merge 2 commits into from

4 participants


The rails console require conditionals fail when running pry directly. I've added a check for defined?(Pry) to get ActiveRecord and ActiveSupport extensions loaded.

The second commit is due to rspec complaining about the order of that array after I changed the require stuff. Since the order doesn't matter, I just changed the test.


I didn't include rspec tests for the main change in this pull request since that code is already untested and spec_helper requires awesome_print already.

I have tested this with both pry and irb in my project.


@ryansch - What is the symptom of this? I don't have anything special going
on other than pry-rails, and I get this:

[3] pry(main)> require 'awesome_print/ext/active_record'
=> false
[4] pry(main)> require 'awesome_print/ext/active_support'
=> false

So, I'm already getting those requires (otherwise they'd return true).

What am I misunderstanding about this patch?


I'll have to dig into this again. We were running rails 2 at the time and I don't think we were using the pry-rails gem.


I'm experiencing the exact same problem. I have gem 'pry' and gem 'awesome_print' in my :development group, but I'm not running rails console, I'm running just pry and my ~/.pryrc takes care of loading Rails (if I am in a Rails project directory). This results in both extensions not being loaded as requring them returns true (also ap doesn't work for AR models if I don't require them):

[DEV] main:0> require 'awesome_print/ext/active_record'
=> true
[DEV] main:0> require 'awesome_print/ext/active_support'
=> true
@michaeldv michaeldv closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 29, 2011
  1. @ryansch
  2. @ryansch

    Fixing rspec test on methods.

    ryansch committed
    We don't care about the order of the array.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +3 −3 lib/awesome_print.rb
  2. +1 −1  spec/methods_spec.rb
6 lib/awesome_print.rb
@@ -18,9 +18,9 @@
require File.dirname(__FILE__) + "/awesome_print/core_ext/logger" if defined?(Logger)
# Load the following under normal circumstances as well as in Rails
- # console when required from ~/.irbrc.
- require File.dirname(__FILE__) + "/awesome_print/ext/active_record" if defined?(ActiveRecord) || (defined?(IRB) && ENV['RAILS_ENV'])
- require File.dirname(__FILE__) + "/awesome_print/ext/active_support" if defined?(ActiveSupport) || (defined?(IRB) && ENV['RAILS_ENV'])
+ # console when required from ~/.irbrc or ~/.pryrc.
+ require File.dirname(__FILE__) + "/awesome_print/ext/active_record" if defined?(ActiveRecord) || (defined?(Pry) || (defined?(IRB) && ENV['RAILS_ENV']))
+ require File.dirname(__FILE__) + "/awesome_print/ext/active_support" if defined?(ActiveSupport) || (defined?(Pry) || (defined?(IRB) && ENV['RAILS_ENV']))
# Load remaining extensions.
require File.dirname(__FILE__) + "/awesome_print/ext/action_view" if defined?(ActionView::Base)
2  spec/methods_spec.rb
@@ -411,7 +411,7 @@ def self.m_two; end
out = Hello.methods.grep(/^m_(.+)$/) { $1.to_sym }
- out.should == [:one, :two]
+ out.should =~ [:one, :two]
it "obj1.methods.grep(pattern, &block) should be awesome printed" do
Something went wrong with that request. Please try again.