Merge pull request #1468 from egwspiti/fix-cat
display an error message when cat is invoked without arguments.
This commit is contained in:
commit
cac8abc256
|
@ -6,6 +6,8 @@ class Pry
|
||||||
attr_reader :_pry_
|
attr_reader :_pry_
|
||||||
|
|
||||||
def initialize(file_with_embedded_line, _pry_, opts)
|
def initialize(file_with_embedded_line, _pry_, opts)
|
||||||
|
raise CommandError, "Must provide a filename, --in, or --ex." if !file_with_embedded_line
|
||||||
|
|
||||||
@file_with_embedded_line = file_with_embedded_line
|
@file_with_embedded_line = file_with_embedded_line
|
||||||
@opts = opts
|
@opts = opts
|
||||||
@_pry_ = _pry_
|
@_pry_ = _pry_
|
||||||
|
@ -13,8 +15,6 @@ class Pry
|
||||||
end
|
end
|
||||||
|
|
||||||
def format
|
def format
|
||||||
raise CommandError, "Must provide a filename, --in, or --ex." if !file_with_embedded_line
|
|
||||||
|
|
||||||
set_file_and_dir_locals(file_name, _pry_, _pry_.current_context)
|
set_file_and_dir_locals(file_name, _pry_, _pry_.current_context)
|
||||||
decorate(@code_from_file)
|
decorate(@code_from_file)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,12 @@ describe "cat" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "when invoked without arguments" do
|
||||||
|
it 'should display an error message' do
|
||||||
|
expect { @t.eval 'cat' }.to raise_error(Pry::CommandError, /Must provide a filename/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "on receiving a file that does not exist" do
|
describe "on receiving a file that does not exist" do
|
||||||
it 'should display an error message' do
|
it 'should display an error message' do
|
||||||
expect { @t.eval 'cat supercalifragilicious66' }.to raise_error(StandardError, /Cannot open/)
|
expect { @t.eval 'cat supercalifragilicious66' }.to raise_error(StandardError, /Cannot open/)
|
||||||
|
|
Loading…
Reference in New Issue