Use pry_eval to test show-doc on commands

This commit is contained in:
Ryan Fitzgerald 2012-08-17 00:47:32 -07:00
parent 46e1196e75
commit 90b3f807f0
2 changed files with 4 additions and 6 deletions

View File

@ -309,7 +309,6 @@ if !mri18_and_no_real_source_location?
end
describe "on commands" do
# mostly copied & modified from test_help.rb
before do
@oldset = Pry.config.commands
@ -323,19 +322,18 @@ if !mri18_and_no_real_source_location?
end
it 'should display help for a specific command' do
mock_pry('show-doc ls').should =~ /Usage: ls/
pry_eval('show-doc ls').should =~ /Usage: ls/
end
it 'should display help for a regex command with a "listing"' do
@set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
mock_pry('show-doc foo').should =~ /Test listing/
pry_eval('show-doc foo').should =~ /Test listing/
end
it 'should display help for a command with a spaces in its name' do
@set.command "command with spaces", "description of a command with spaces" do; end
mock_pry('show-doc "command with spaces"').should =~ /description of a command with spaces/
pry_eval('show-doc "command with spaces"').should =~ /description of a command with spaces/
end
end
end
end

View File

@ -4,7 +4,7 @@ require 'helper'
# for C methods actually runs the methods - and since it runs ALL
# methods (in an attempt to find a match) it runs 'exit' and aborts
# the test, causing a failure. We should fix this in the future by
# blacklisting certain methods for 1.8 MRI (such as exit, fork, and so on)
# blacklisting certain methods for 1.8 MRI (such as exit, fork, and so on)
unless Pry::Helpers::BaseHelpers.mri_18?
MyKlass = Class.new do
def hello