diff options
author | Felix Bùˆnemann <buenemann@louis.info> | 2015-11-16 20:26:15 +0100 |
---|---|---|
committer | Felix Bùˆnemann <buenemann@louis.info> | 2015-11-16 20:26:15 +0100 |
commit | 95d21b224284739e0fd1bf936cc36688e669b377 (patch) | |
tree | ad34d9bb0531446cf806c6ac5a6d8d627dd2489e /spec/support/builders.rb | |
parent | f787c664b4645fb44066b140b3b9afee542590c9 (diff) | |
download | bundler-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.rb | 33 |
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 |