summaryrefslogtreecommitdiff
path: root/spec/support/builders.rb
diff options
context:
space:
mode:
authorFelix Bùˆnemann <buenemann@louis.info>2015-11-16 20:26:15 +0100
committerFelix Bùˆnemann <buenemann@louis.info>2015-11-16 20:26:15 +0100
commit95d21b224284739e0fd1bf936cc36688e669b377 (patch)
treead34d9bb0531446cf806c6ac5a6d8d627dd2489e /spec/support/builders.rb
parentf787c664b4645fb44066b140b3b9afee542590c9 (diff)
downloadbundler-95d21b224284739e0fd1bf936cc36688e669b377.tar.gz
Fix bundle console specs
The previous specs only worked by accident, because the error message "Couldn't load pry\nCould not find constant IRB\n" contained both of the strings expected by the assertions. In order to test loading an alternate console without adding a permanent dependency, we can use a fake pry gem that implements the minimum required api.
Diffstat (limited to 'spec/support/builders.rb')
-rw-r--r--spec/support/builders.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 95b4b6eb59..913263c51d 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -242,6 +242,39 @@ module Spec
end
build_gem "foo"
+
+ # A minimal fake pry console
+ build_gem "pry" do |s|
+ s.write "lib/pry.rb", <<-RUBY
+ class Pry
+ class << self
+ def toplevel_binding
+ unless defined?(@toplevel_binding) && @toplevel_binding
+ TOPLEVEL_BINDING.eval %{
+ def self.__pry__; binding; end
+ Pry.instance_variable_set(:@toplevel_binding, __pry__)
+ class << self; undef __pry__; end
+ }
+ end
+ @toplevel_binding.eval('private')
+ @toplevel_binding
+ end
+
+ def __pry__
+ while line = gets
+ begin
+ puts eval(line, toplevel_binding).inspect.sub(/^"(.*)"$/, '=> \\1')
+ rescue Exception => e
+ puts "\#{e.class}: \#{e.message}"
+ puts e.backtrace.first
+ end
+ end
+ end
+ alias start __pry__
+ end
+ end
+ RUBY
+ end
end
end