diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 05f7d94f..884bc643 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -181,8 +181,9 @@ class Pry end end - repl_epilogue(target) break_data || nil + ensure + repl_epilogue(target) end # Perform a read-eval-print. diff --git a/lib/pry/version.rb b/lib/pry/version.rb index 6ae445db..7d836869 100644 --- a/lib/pry/version.rb +++ b/lib/pry/version.rb @@ -1,3 +1,3 @@ class Pry - VERSION = "0.9.8pre3" + VERSION = "0.9.8pre4" end diff --git a/pry.gemspec b/pry.gemspec index e646a6e5..64c62b1f 100644 --- a/pry.gemspec +++ b/pry.gemspec @@ -1,21 +1,21 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{pry} - s.version = "0.9.8pre3" + s.name = "pry" + s.version = "0.9.8pre4" s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= - s.authors = [%q{John Mair (banisterfiend)}] - s.date = %q{2012-01-12} - s.description = %q{An IRB alternative and runtime developer console} - s.email = %q{jrmair@gmail.com} - s.executables = [%q{pry}] - s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.travis.yml}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{Gemfile}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/cli.rb}, %q{lib/pry/command.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/options_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/hooks.rb}, %q{lib/pry/indent.rb}, %q{lib/pry/method.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/rbx_method.rb}, %q{lib/pry/rbx_path.rb}, %q{lib/pry/version.rb}, %q{lib/pry/wrapped_module.rb}, %q{man/pry.1}, %q{man/pry.1.html}, %q{man/pry.1.ronn}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_cli.rb}, %q{test/test_command.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_ls.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_hooks.rb}, %q{test/test_indent.rb}, %q{test/test_input_stack.rb}, %q{test/test_method.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/test_syntax_checking.rb}, %q{test/test_wrapped_module.rb}, %q{test/testrc}, %q{test/testrcbad}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}] - s.homepage = %q{http://pry.github.com} - s.require_paths = [%q{lib}] - s.rubygems_version = %q{1.8.6} - s.summary = %q{An IRB alternative and runtime developer console} - s.test_files = [%q{test/helper.rb}, %q{test/test_cli.rb}, %q{test/test_command.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_ls.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_hooks.rb}, %q{test/test_indent.rb}, %q{test/test_input_stack.rb}, %q{test/test_method.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/test_syntax_checking.rb}, %q{test/test_wrapped_module.rb}, %q{test/testrc}, %q{test/testrcbad}] + s.authors = ["John Mair (banisterfiend)"] + s.date = "2012-01-13" + s.description = "An IRB alternative and runtime developer console" + s.email = "jrmair@gmail.com" + s.executables = ["pry"] + s.files = [".document", ".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "CONTRIBUTORS", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "TODO", "bin/pry", "examples/example_basic.rb", "examples/example_command_override.rb", "examples/example_commands.rb", "examples/example_hooks.rb", "examples/example_image_edit.rb", "examples/example_input.rb", "examples/example_input2.rb", "examples/example_output.rb", "examples/example_print.rb", "examples/example_prompt.rb", "examples/helper.rb", "lib/pry.rb", "lib/pry/cli.rb", "lib/pry/command.rb", "lib/pry/command_set.rb", "lib/pry/commands.rb", "lib/pry/completion.rb", "lib/pry/config.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/default_commands/basic.rb", "lib/pry/default_commands/context.rb", "lib/pry/default_commands/documentation.rb", "lib/pry/default_commands/easter_eggs.rb", "lib/pry/default_commands/gems.rb", "lib/pry/default_commands/input.rb", "lib/pry/default_commands/introspection.rb", "lib/pry/default_commands/ls.rb", "lib/pry/default_commands/shell.rb", "lib/pry/extended_commands/experimental.rb", "lib/pry/extended_commands/user_command_api.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/options_helpers.rb", "lib/pry/helpers/text.rb", "lib/pry/history.rb", "lib/pry/history_array.rb", "lib/pry/hooks.rb", "lib/pry/indent.rb", "lib/pry/method.rb", "lib/pry/plugins.rb", "lib/pry/pry_class.rb", "lib/pry/pry_instance.rb", "lib/pry/rbx_method.rb", "lib/pry/rbx_path.rb", "lib/pry/version.rb", "lib/pry/wrapped_module.rb", "man/pry.1", "man/pry.1.html", "man/pry.1.ronn", "pry.gemspec", "test/helper.rb", "test/test_cli.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_special_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad", "wiki/Customizing-pry.md", "wiki/Home.md"] + s.homepage = "http://pry.github.com" + s.require_paths = ["lib"] + s.rubygems_version = "1.8.10" + s.summary = "An IRB alternative and runtime developer console" + s.test_files = ["test/helper.rb", "test/test_cli.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_special_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad"] if s.respond_to? :specification_version then s.specification_version = 3 diff --git a/test/test_hooks.rb b/test/test_hooks.rb index 18bd43da..f4a90fc2 100644 --- a/test/test_hooks.rb +++ b/test/test_hooks.rb @@ -306,5 +306,33 @@ describe Pry::Hooks do Pry.config.hooks.delete_hook(:when_started, :test_hook) end end + + describe "after_session hook" do + it 'should always run, even if uncaught exception bubbles out of repl' do + + o = OpenStruct.new + o.great_escape = Class.new(StandardError) + + Pry.config.exception_whitelist << o.great_escape + + array = [1, 2, 3, 4, 5] + + begin + redirect_pry_io(StringIO.new("raise great_escape"), out=StringIO.new) do + Pry.start o, :hooks => Pry::Hooks.new.add_hook(:after_session, :cleanup) { array = nil } + end + rescue => ex + exception = ex + end + + # ensure that an exception really was raised and it broke out + # of the repl + exception.is_a?(o.great_escape).should == true + + # check that after_session hook ran + array.should == nil + end + end + end end