pry 0.9.12.6-i386-mingw32 → 0.10.0-i386-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +702 -0
- data/LICENSE +2 -2
- data/{README.markdown → README.md} +37 -31
- data/lib/pry.rb +38 -151
- data/lib/pry/cli.rb +35 -17
- data/lib/pry/code.rb +19 -63
- data/lib/pry/code/code_file.rb +103 -0
- data/lib/pry/code/code_range.rb +2 -1
- data/lib/pry/code/loc.rb +2 -2
- data/lib/pry/code_object.rb +40 -21
- data/lib/pry/color_printer.rb +55 -0
- data/lib/pry/command.rb +12 -9
- data/lib/pry/command_set.rb +81 -38
- data/lib/pry/commands.rb +1 -1
- data/lib/pry/commands/amend_line.rb +2 -2
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat.rb +11 -2
- data/lib/pry/commands/cat/exception_formatter.rb +6 -7
- data/lib/pry/commands/cat/file_formatter.rb +15 -32
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cd.rb +14 -3
- data/lib/pry/commands/change_inspector.rb +27 -0
- data/lib/pry/commands/change_prompt.rb +26 -0
- data/lib/pry/commands/code_collector.rb +4 -4
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +10 -22
- data/lib/pry/commands/edit/exception_patcher.rb +2 -2
- data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
- data/lib/pry/commands/exit_program.rb +0 -1
- data/lib/pry/commands/find_method.rb +16 -22
- data/lib/pry/commands/gem_install.rb +5 -2
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gist.rb +10 -11
- data/lib/pry/commands/help.rb +14 -14
- data/lib/pry/commands/hist.rb +27 -8
- data/lib/pry/commands/install_command.rb +14 -12
- data/lib/pry/commands/list_inspectors.rb +35 -0
- data/lib/pry/commands/list_prompts.rb +35 -0
- data/lib/pry/commands/ls.rb +72 -296
- data/lib/pry/commands/ls/constants.rb +47 -0
- data/lib/pry/commands/ls/formatter.rb +49 -0
- data/lib/pry/commands/ls/globals.rb +48 -0
- data/lib/pry/commands/ls/grep.rb +21 -0
- data/lib/pry/commands/ls/instance_vars.rb +39 -0
- data/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/lib/pry/commands/ls/local_names.rb +35 -0
- data/lib/pry/commands/ls/local_vars.rb +39 -0
- data/lib/pry/commands/ls/ls_entity.rb +70 -0
- data/lib/pry/commands/ls/methods.rb +57 -0
- data/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/lib/pry/commands/ls/self_methods.rb +32 -0
- data/lib/pry/commands/play.rb +44 -10
- data/lib/pry/commands/pry_backtrace.rb +1 -2
- data/lib/pry/commands/raise_up.rb +2 -2
- data/lib/pry/commands/reload_code.rb +16 -19
- data/lib/pry/commands/ri.rb +7 -3
- data/lib/pry/commands/shell_command.rb +18 -13
- data/lib/pry/commands/shell_mode.rb +2 -4
- data/lib/pry/commands/show_doc.rb +5 -0
- data/lib/pry/commands/show_info.rb +8 -13
- data/lib/pry/commands/show_source.rb +15 -3
- data/lib/pry/commands/simple_prompt.rb +1 -1
- data/lib/pry/commands/toggle_color.rb +8 -4
- data/lib/pry/commands/watch_expression.rb +105 -0
- data/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/lib/pry/commands/whereami.rb +18 -10
- data/lib/pry/commands/wtf.rb +3 -3
- data/lib/pry/config.rb +20 -254
- data/lib/pry/config/behavior.rb +139 -0
- data/lib/pry/config/convenience.rb +26 -0
- data/lib/pry/config/default.rb +165 -0
- data/lib/pry/core_extensions.rb +31 -21
- data/lib/pry/editor.rb +107 -103
- data/lib/pry/exceptions.rb +77 -0
- data/lib/pry/helpers/base_helpers.rb +22 -109
- data/lib/pry/helpers/command_helpers.rb +10 -8
- data/lib/pry/helpers/documentation_helpers.rb +1 -2
- data/lib/pry/helpers/text.rb +4 -5
- data/lib/pry/history.rb +46 -45
- data/lib/pry/history_array.rb +6 -1
- data/lib/pry/hooks.rb +9 -29
- data/lib/pry/indent.rb +6 -6
- data/lib/pry/input_completer.rb +242 -0
- data/lib/pry/input_lock.rb +132 -0
- data/lib/pry/inspector.rb +27 -0
- data/lib/pry/last_exception.rb +61 -0
- data/lib/pry/method.rb +82 -87
- data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
- data/lib/pry/module_candidate.rb +4 -14
- data/lib/pry/object_path.rb +82 -0
- data/lib/pry/output.rb +50 -0
- data/lib/pry/pager.rb +193 -48
- data/lib/pry/plugins.rb +1 -1
- data/lib/pry/prompt.rb +26 -0
- data/lib/pry/pry_class.rb +149 -230
- data/lib/pry/pry_instance.rb +302 -413
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +202 -0
- data/lib/pry/repl_file_loader.rb +20 -26
- data/lib/pry/rubygem.rb +13 -5
- data/lib/pry/terminal.rb +2 -1
- data/lib/pry/test/helper.rb +26 -41
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +45 -59
- metadata +62 -225
- data/.document +0 -2
- data/.gitignore +0 -16
- data/.travis.yml +0 -25
- data/.yardopts +0 -1
- data/CHANGELOG +0 -534
- data/CONTRIBUTORS +0 -55
- data/Gemfile +0 -12
- data/Rakefile +0 -140
- data/TODO +0 -117
- data/lib/pry/completion.rb +0 -321
- data/lib/pry/custom_completions.rb +0 -6
- data/lib/pry/rbx_method.rb +0 -13
- data/man/pry.1 +0 -195
- data/man/pry.1.html +0 -204
- data/man/pry.1.ronn +0 -141
- data/pry.gemspec +0 -29
- data/spec/Procfile +0 -3
- data/spec/cli_spec.rb +0 -78
- data/spec/code_object_spec.rb +0 -277
- data/spec/code_spec.rb +0 -219
- data/spec/command_helpers_spec.rb +0 -29
- data/spec/command_integration_spec.rb +0 -644
- data/spec/command_set_spec.rb +0 -627
- data/spec/command_spec.rb +0 -821
- data/spec/commands/amend_line_spec.rb +0 -247
- data/spec/commands/bang_spec.rb +0 -19
- data/spec/commands/cat_spec.rb +0 -164
- data/spec/commands/cd_spec.rb +0 -250
- data/spec/commands/disable_pry_spec.rb +0 -25
- data/spec/commands/edit_spec.rb +0 -727
- data/spec/commands/exit_all_spec.rb +0 -34
- data/spec/commands/exit_program_spec.rb +0 -19
- data/spec/commands/exit_spec.rb +0 -34
- data/spec/commands/find_method_spec.rb +0 -70
- data/spec/commands/gem_list_spec.rb +0 -26
- data/spec/commands/gist_spec.rb +0 -79
- data/spec/commands/help_spec.rb +0 -56
- data/spec/commands/hist_spec.rb +0 -181
- data/spec/commands/jump_to_spec.rb +0 -15
- data/spec/commands/ls_spec.rb +0 -181
- data/spec/commands/play_spec.rb +0 -140
- data/spec/commands/raise_up_spec.rb +0 -56
- data/spec/commands/save_file_spec.rb +0 -177
- data/spec/commands/show_doc_spec.rb +0 -510
- data/spec/commands/show_input_spec.rb +0 -17
- data/spec/commands/show_source_spec.rb +0 -782
- data/spec/commands/whereami_spec.rb +0 -203
- data/spec/completion_spec.rb +0 -241
- data/spec/control_d_handler_spec.rb +0 -58
- data/spec/documentation_helper_spec.rb +0 -73
- data/spec/editor_spec.rb +0 -79
- data/spec/exception_whitelist_spec.rb +0 -21
- data/spec/fixtures/candidate_helper1.rb +0 -11
- data/spec/fixtures/candidate_helper2.rb +0 -8
- data/spec/fixtures/example.erb +0 -5
- data/spec/fixtures/example_nesting.rb +0 -33
- data/spec/fixtures/show_source_doc_examples.rb +0 -15
- data/spec/fixtures/testrc +0 -2
- data/spec/fixtures/testrcbad +0 -2
- data/spec/fixtures/whereami_helper.rb +0 -6
- data/spec/helper.rb +0 -34
- data/spec/helpers/bacon.rb +0 -86
- data/spec/helpers/mock_pry.rb +0 -43
- data/spec/helpers/table_spec.rb +0 -105
- data/spec/history_array_spec.rb +0 -67
- data/spec/hooks_spec.rb +0 -522
- data/spec/indent_spec.rb +0 -301
- data/spec/input_stack_spec.rb +0 -90
- data/spec/method_spec.rb +0 -482
- data/spec/prompt_spec.rb +0 -60
- data/spec/pry_defaults_spec.rb +0 -419
- data/spec/pry_history_spec.rb +0 -99
- data/spec/pry_output_spec.rb +0 -95
- data/spec/pry_spec.rb +0 -515
- data/spec/run_command_spec.rb +0 -25
- data/spec/sticky_locals_spec.rb +0 -157
- data/spec/syntax_checking_spec.rb +0 -81
- data/spec/wrapped_module_spec.rb +0 -261
- data/wiki/Customizing-pry.md +0 -397
- data/wiki/Home.md +0 -4
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Pry::Helpers::DocumentationHelpers do
|
4
|
-
before do
|
5
|
-
@helper = Pry::Helpers::DocumentationHelpers
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "get_comment_content" do
|
9
|
-
it "should strip off the hash and unindent" do
|
10
|
-
@helper.get_comment_content(" # hello\n # world\n").should == "hello\nworld\n"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should strip out leading lines of hashes" do
|
14
|
-
@helper.get_comment_content("###############\n#hello\n#world\n").should == "hello\nworld\n"
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should remove shebangs" do
|
18
|
-
@helper.get_comment_content("#!/usr/bin/env ruby\n# This is a program\n").should == "This is a program\n"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should unindent past separators" do
|
22
|
-
@helper.get_comment_content(" # Copyright Me <me@cirw.in>\n #--\n # So there.\n").should == "Copyright Me <me@cirw.in>\n--\nSo there.\n"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "process_rdoc" do
|
27
|
-
before do
|
28
|
-
Pry.color = true
|
29
|
-
end
|
30
|
-
|
31
|
-
after do
|
32
|
-
Pry.color = false
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should syntax highlight indented code" do
|
36
|
-
@helper.process_rdoc(" 4 + 4\n").should.not == " 4 + 4\n"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should highlight words surrounded by +s" do
|
40
|
-
@helper.process_rdoc("the +parameter+").should =~ /the \e.*parameter\e.*/
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should syntax highlight things in backticks" do
|
44
|
-
@helper.process_rdoc("for `Example`").should =~ /for `\e.*Example\e.*`/
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should emphasise em tags" do
|
48
|
-
@helper.process_rdoc("for <em>science</em>").should == "for \e[1mscience\e[0m"
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should emphasise italic tags" do
|
52
|
-
@helper.process_rdoc("for <i>science</i>").should == "for \e[1mscience\e[0m"
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should syntax highlight code in <code>" do
|
56
|
-
@helper.process_rdoc("for <code>Example</code>").should =~ /for \e.*Example\e.*/
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should not double-highlight backticks inside indented code" do
|
60
|
-
@helper.process_rdoc(" `echo 5`").should =~ /echo 5/
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should not remove ++" do
|
64
|
-
@helper.process_rdoc("--\n comment in a bubble\n++").should =~ /\+\+/
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should do nothing if Pry.color is false" do
|
68
|
-
Pry.color = false
|
69
|
-
@helper.process_rdoc(" 4 + 4\n").should == " 4 + 4\n"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
data/spec/editor_spec.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe Pry::Editor do
|
5
|
-
class << Pry::Editor
|
6
|
-
public :build_editor_invocation_string
|
7
|
-
end
|
8
|
-
|
9
|
-
before do
|
10
|
-
# OS-specific tempdir name. For GNU/Linux it's "tmp", for Windows it's
|
11
|
-
# something "Temp".
|
12
|
-
@tf_dir =
|
13
|
-
if Pry::Helpers::BaseHelpers.mri_19?
|
14
|
-
Pathname.new(Dir::Tmpname.tmpdir)
|
15
|
-
else
|
16
|
-
Pathname.new(Dir.tmpdir)
|
17
|
-
end
|
18
|
-
|
19
|
-
@tf_path = File.join(@tf_dir.to_s, 'hello world.rb')
|
20
|
-
end
|
21
|
-
|
22
|
-
unless Pry::Helpers::BaseHelpers.windows?
|
23
|
-
describe "build_editor_invocation_string" do
|
24
|
-
before do
|
25
|
-
class << Pry::Editor
|
26
|
-
public :build_editor_invocation_string
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should shell-escape files' do
|
31
|
-
invocation_str = Pry::Editor.build_editor_invocation_string(@tf_path, 5, true)
|
32
|
-
invocation_str.should =~ /#@tf_dir.+hello\\ world\.rb/
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "build_editor_invocation_string on windows" do
|
38
|
-
before do
|
39
|
-
class << Pry::Editor
|
40
|
-
def windows?; true; end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
after do
|
45
|
-
class << Pry::Editor
|
46
|
-
undef windows?
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should replace / by \\" do
|
51
|
-
invocation_str = Pry::Editor.build_editor_invocation_string(@tf_path, 5, true)
|
52
|
-
invocation_str.should =~ %r(\\#{@tf_dir.basename}\\)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should not shell-escape files" do
|
56
|
-
invocation_str = Pry::Editor.build_editor_invocation_string(@tf_path, 5, true)
|
57
|
-
invocation_str.should =~ /hello world\.rb/
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'invoke_editor with a proc' do
|
62
|
-
before do
|
63
|
-
@old_editor = Pry.config.editor
|
64
|
-
Pry.config.editor = proc{ |file, line, blocking|
|
65
|
-
@file = file
|
66
|
-
nil
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
after do
|
71
|
-
Pry.config.editor = @old_editor
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should not shell-escape files' do
|
75
|
-
Pry::Editor.invoke_editor(@tf_path, 10, true)
|
76
|
-
@file.should == @tf_path
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe "Pry.config.exception_whitelist" do
|
4
|
-
before do
|
5
|
-
@str_output = StringIO.new
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should rescue all exceptions NOT specified on whitelist' do
|
9
|
-
Pry.config.exception_whitelist.include?(NameError).should == false
|
10
|
-
lambda { Pry.start(self, :input => StringIO.new("raise NameError\nexit"), :output => @str_output) }.should.not.raise NameError
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should NOT rescue exceptions specified on whitelist' do
|
14
|
-
old_whitelist = Pry.config.exception_whitelist
|
15
|
-
Pry.config.exception_whitelist = [NameError]
|
16
|
-
lambda { Pry.start(self, :input => StringIO.new("raise NameError"), :output => @str_output) }.should.raise NameError
|
17
|
-
Pry.config.exception_whitelist = old_whitelist
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
data/spec/fixtures/example.erb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# []
|
2
|
-
class A # ["class A"]
|
3
|
-
def a; end # ["class A"]
|
4
|
-
class B; def b; end; end # ["class A", "class B"]
|
5
|
-
end # []
|
6
|
-
# []
|
7
|
-
class << A # ["class << A"]
|
8
|
-
class B # ["class << A", "class B"]
|
9
|
-
def c; end # ["class << A", "class B"]
|
10
|
-
end # ["class << A"]
|
11
|
-
# ["class << A"]
|
12
|
-
module F::B # ["class << A", "module F::B"]
|
13
|
-
def foo; end # ["class << A", "module F::B"]
|
14
|
-
end # ["class << A"]
|
15
|
-
end # []
|
16
|
-
# []
|
17
|
-
module (:symbol.class)::Exciting #
|
18
|
-
def foo; end #
|
19
|
-
class B #
|
20
|
-
def goo; end #
|
21
|
-
end #
|
22
|
-
end # []
|
23
|
-
# []
|
24
|
-
module C # ["module C"]
|
25
|
-
class D # ["module C", "class D"]
|
26
|
-
def guh; foo.end; end # ["module C", "class D"]
|
27
|
-
end # ["module C"]
|
28
|
-
def bar; :end; end # ["module C"]
|
29
|
-
class << new.bar; end # ["module C"]
|
30
|
-
class << new.bar; def f; end; end #
|
31
|
-
# ["module C"]
|
32
|
-
class << self; def mug; end; end # ["module C", "class << self"]
|
33
|
-
end # []
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# used by test_show_source.rb and test_documentation.rb
|
2
|
-
class TestClassForShowSource
|
3
|
-
def alpha
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
class TestClassForShowSourceClassEval
|
8
|
-
def alpha
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class TestClassForShowSourceInstanceEval
|
13
|
-
def alpha
|
14
|
-
end
|
15
|
-
end
|
data/spec/fixtures/testrc
DELETED
data/spec/fixtures/testrcbad
DELETED
data/spec/helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
unless Object.const_defined? 'Pry'
|
2
|
-
$:.unshift File.expand_path '../../lib', __FILE__
|
3
|
-
require 'pry'
|
4
|
-
end
|
5
|
-
|
6
|
-
require 'mocha/api'
|
7
|
-
|
8
|
-
require 'pry/test/helper'
|
9
|
-
require 'helpers/bacon'
|
10
|
-
require 'helpers/mock_pry'
|
11
|
-
|
12
|
-
class Module
|
13
|
-
public :remove_const
|
14
|
-
public :remove_method
|
15
|
-
end
|
16
|
-
|
17
|
-
# turn warnings off (esp for Pry::Hooks which will generate warnings
|
18
|
-
# in tests)
|
19
|
-
$VERBOSE = nil
|
20
|
-
|
21
|
-
Pad = OpenStruct.new
|
22
|
-
def Pad.clear
|
23
|
-
@table = {}
|
24
|
-
end
|
25
|
-
|
26
|
-
# to help with tracking down bugs that cause an infinite loop in the test suite
|
27
|
-
if ENV["SET_TRACE_FUNC"]
|
28
|
-
require 'set_trace' if Pry::Helpers::BaseHelpers.rbx?
|
29
|
-
set_trace_func proc { |event, file, line, id, binding, classname|
|
30
|
-
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
puts "Ruby v#{RUBY_VERSION} (#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"}), Pry v#{Pry::VERSION}, method_source v#{MethodSource::VERSION}, CodeRay v#{CodeRay::VERSION}, Slop v#{Slop::VERSION}"
|
data/spec/helpers/bacon.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# Colorize output (based on greeneggs (c) 2009 Michael Fleet)
|
2
|
-
# TODO: Make own gem (assigned to rking)
|
3
|
-
module Bacon
|
4
|
-
class Context
|
5
|
-
include PryTestHelpers
|
6
|
-
end
|
7
|
-
|
8
|
-
COLORS = {'F' => 31, 'E' => 35, 'M' => 33, '.' => 32}
|
9
|
-
USE_COLOR = !(ENV['NO_PRY_COLORED_BACON'] == 'true') && Pry::Helpers::BaseHelpers.use_ansi_codes?
|
10
|
-
|
11
|
-
module TestUnitOutput
|
12
|
-
def handle_requirement(description)
|
13
|
-
error = yield
|
14
|
-
|
15
|
-
if error.empty?
|
16
|
-
print colorize_string('.')
|
17
|
-
else
|
18
|
-
print colorize_string(error[0..0])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def handle_summary
|
23
|
-
puts
|
24
|
-
puts ErrorLog if Backtraces
|
25
|
-
|
26
|
-
out = "%d tests, %d assertions, %d failures, %d errors" %
|
27
|
-
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
28
|
-
|
29
|
-
if Counter.values_at(:failed, :errors).inject(:+) > 0
|
30
|
-
puts colorize_string(out, 'F')
|
31
|
-
else
|
32
|
-
puts colorize_string(out, '.')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def colorize_string(text, color = nil)
|
37
|
-
if USE_COLOR
|
38
|
-
"\e[#{ COLORS[color || text] }m#{ text }\e[0m"
|
39
|
-
else
|
40
|
-
text
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Reset top-level binding at the beginning of each test case.
|
47
|
-
module Bacon
|
48
|
-
class Context
|
49
|
-
def it_with_reset_binding(description, &block)
|
50
|
-
Pry.toplevel_binding = nil
|
51
|
-
it_without_reset_binding(description, &block)
|
52
|
-
end
|
53
|
-
alias it_without_reset_binding it
|
54
|
-
alias it it_with_reset_binding
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Support mocha
|
59
|
-
# mocha-on-bacon (c) Copyright (C) 2011, Eloy Durán <eloy.de.enige@gmail.com>
|
60
|
-
module Bacon
|
61
|
-
module MochaRequirementsCounter
|
62
|
-
def self.increment
|
63
|
-
Counter[:requirements] += 1
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class Context
|
68
|
-
include Mocha::API
|
69
|
-
|
70
|
-
def it_with_mocha(description, &block)
|
71
|
-
it_without_mocha(description) do
|
72
|
-
begin
|
73
|
-
mocha_setup
|
74
|
-
block.call
|
75
|
-
mocha_verify(MochaRequirementsCounter)
|
76
|
-
rescue Mocha::ExpectationError => e
|
77
|
-
raise Error.new(:failed, e.message)
|
78
|
-
ensure
|
79
|
-
mocha_teardown
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
alias it_without_mocha it
|
84
|
-
alias it it_with_mocha
|
85
|
-
end
|
86
|
-
end
|
data/spec/helpers/mock_pry.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
def mock_pry(*args)
|
2
|
-
args.flatten!
|
3
|
-
binding = args.first.is_a?(Binding) ? args.shift : binding()
|
4
|
-
|
5
|
-
input = InputTester.new(*args)
|
6
|
-
output = StringIO.new
|
7
|
-
|
8
|
-
redirect_pry_io(input, output) do
|
9
|
-
binding.pry
|
10
|
-
end
|
11
|
-
|
12
|
-
output.string
|
13
|
-
end
|
14
|
-
|
15
|
-
# Set I/O streams. Out defaults to an anonymous StringIO.
|
16
|
-
def redirect_pry_io(new_in, new_out = StringIO.new)
|
17
|
-
old_in = Pry.input
|
18
|
-
old_out = Pry.output
|
19
|
-
|
20
|
-
Pry.input = new_in
|
21
|
-
Pry.output = new_out
|
22
|
-
begin
|
23
|
-
yield
|
24
|
-
ensure
|
25
|
-
Pry.input = old_in
|
26
|
-
Pry.output = old_out
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class InputTester
|
31
|
-
def initialize(*actions)
|
32
|
-
@orig_actions = actions.dup
|
33
|
-
@actions = actions
|
34
|
-
end
|
35
|
-
|
36
|
-
def readline(*)
|
37
|
-
@actions.shift
|
38
|
-
end
|
39
|
-
|
40
|
-
def rewind
|
41
|
-
@actions = @orig_actions.dup
|
42
|
-
end
|
43
|
-
end
|
data/spec/helpers/table_spec.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe 'Formatting Table' do
|
4
|
-
it 'knows about colorized fitting' do
|
5
|
-
t = Pry::Helpers::Table.new %w(hihi), :column_count => 1
|
6
|
-
t.fits_on_line?(4).should == true
|
7
|
-
t.items = []
|
8
|
-
t.fits_on_line?(4).should == true
|
9
|
-
|
10
|
-
t.items = %w(hi hi)
|
11
|
-
t.fits_on_line?(4).should == true
|
12
|
-
t.column_count = 2
|
13
|
-
t.fits_on_line?(4).should == false
|
14
|
-
|
15
|
-
t.items = %w(
|
16
|
-
a ccc
|
17
|
-
bb dddd
|
18
|
-
).sort
|
19
|
-
t.fits_on_line?(8).should == true
|
20
|
-
t.fits_on_line?(7).should == false
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'formatting - should order downward and wrap to columns' do
|
24
|
-
FAKE_COLUMNS = 62
|
25
|
-
def try_round_trip(expected)
|
26
|
-
things = expected.split(/\s+/).sort
|
27
|
-
actual = Pry::Helpers.tablify(things, FAKE_COLUMNS).to_s.strip
|
28
|
-
[expected, actual].each{|e| e.gsub! /\s+$/, ''}
|
29
|
-
if actual != expected
|
30
|
-
bar = '-'*25
|
31
|
-
puts \
|
32
|
-
bar+'expected'+bar,
|
33
|
-
expected,
|
34
|
-
bar+'actual'+bar,
|
35
|
-
actual
|
36
|
-
end
|
37
|
-
actual.should == expected
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should handle a tiny case' do
|
41
|
-
try_round_trip(<<-eot)
|
42
|
-
asdf asfddd fdass
|
43
|
-
eot
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should handle the basic case' do
|
47
|
-
try_round_trip(<<-eot)
|
48
|
-
aadd ddasffssdad sdsaadaasd ssfasaafssd
|
49
|
-
adassdfffaasds f sdsfasddasfds ssssdaa
|
50
|
-
assfsafsfsds fsasa ssdsssafsdasdf
|
51
|
-
eot
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should handle... another basic case' do
|
55
|
-
try_round_trip(<<-EOT)
|
56
|
-
aaad dasaasffaasf fdasfdfss safdfdddsasd
|
57
|
-
aaadfasassdfff ddadadassasdf fddsasadfssdss sasf
|
58
|
-
aaddaafaf dddasaaaaaa fdsasad sddsa
|
59
|
-
aas dfsddffdddsdfd ff sddsfsaa
|
60
|
-
adasadfaaffds dsfafdsfdfssda ffadsfafsaafa ss
|
61
|
-
asddaadaaadfdd dssdss ffssfsfafaadss ssas
|
62
|
-
asdsdaa faadf fsddfff ssdfssff
|
63
|
-
asfadsssaaad fasfaafdssd s
|
64
|
-
EOT
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should handle colors' do
|
68
|
-
try_round_trip(<<-EOT)
|
69
|
-
\e[31maaaaaaaaaa\e[0m \e[31mccccccccccccccccccccccccccccc\e[0m
|
70
|
-
\e[31mbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\e[0m \e[31mddddddddddddd\e[0m
|
71
|
-
EOT
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should handle empty input' do
|
75
|
-
try_round_trip('')
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should handle one-token input' do
|
79
|
-
try_round_trip('asdf')
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe 'line length is smaller than the length of the longest word' do
|
84
|
-
before do
|
85
|
-
element = 'swizzle'
|
86
|
-
@elem_len = element.length
|
87
|
-
@out = [element, 'crime', 'fun']
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should not raise error' do
|
91
|
-
should.not.raise(FloatDomainError) {
|
92
|
-
Pry::Helpers.tablify(@out, @elem_len - 1)
|
93
|
-
}
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should format output as one column' do
|
97
|
-
table = Pry::Helpers.tablify(@out, @elem_len - 1).to_s
|
98
|
-
table.should == "swizzle\ncrime \nfun "
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe 'decide between one-line or indented output' do
|
103
|
-
Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'
|
104
|
-
end
|
105
|
-
end
|