mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Update spec/commands/cat/file_formatter_spec.rb with review and comments
This commit is contained in:
parent
f8b5177ab5
commit
4f4b40cc71
1 changed files with 58 additions and 54 deletions
|
@ -1,66 +1,70 @@
|
|||
require 'helper'
|
||||
|
||||
describe "cat/file_formatter" do
|
||||
before do
|
||||
@p = Pry.new
|
||||
@opt = Slop.new
|
||||
Pry::Code.stubs(:from_file)
|
||||
end
|
||||
|
||||
after do
|
||||
Pry::Code.unstub(:from_file)
|
||||
end
|
||||
|
||||
describe "parse file path" do
|
||||
it 'should parse windows style(/) absolute path without line_num' do
|
||||
file_with_embedded_line = "C:/Ruby193/pry_instance.rb"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "C:/Ruby193/pry_instance.rb"
|
||||
line_num.should == nil
|
||||
describe Pry::Command::Cat::FileFormatter do
|
||||
describe "#file_and_line" do
|
||||
before do
|
||||
@p = Pry.new
|
||||
@opt = Slop.new
|
||||
Pry::Code.stubs(:from_file)
|
||||
end
|
||||
|
||||
it 'should parse windows style(/) absolute path with line_num' do
|
||||
file_with_embedded_line = "C:/Ruby193/pry_instance.rb:2"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "C:/Ruby193/pry_instance.rb"
|
||||
line_num.should == 2
|
||||
after do
|
||||
Pry::Code.unstub(:from_file)
|
||||
end
|
||||
|
||||
it 'should parse windows style(\\) absolute path without line_num' do
|
||||
file_with_embedded_line = "C:\\Ruby193\\pry_instance.rb"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "C:\\Ruby193\\pry_instance.rb"
|
||||
line_num.should == nil
|
||||
describe "windows filesystem" do
|
||||
it "should parse '/'style absolute path without line_num" do
|
||||
file_with_embedded_line = "C:/Ruby193/pry_instance.rb"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "C:/Ruby193/pry_instance.rb"
|
||||
line_num.should == nil
|
||||
end
|
||||
|
||||
it "should parse '/'style absolute path with line_num" do
|
||||
file_with_embedded_line = "C:/Ruby193/pry_instance.rb:2"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "C:/Ruby193/pry_instance.rb"
|
||||
line_num.should == 2
|
||||
end
|
||||
|
||||
it "should parse '\\'style absolute path without line_num" do
|
||||
file_with_embedded_line = "C:\\Ruby193\\pry_instance.rb"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "C:\\Ruby193\\pry_instance.rb"
|
||||
line_num.should == nil
|
||||
end
|
||||
|
||||
it "should parse '\\'style absolute path with line_num" do
|
||||
file_with_embedded_line = "C:\\Ruby193\\pry_instance.rb:2"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "C:\\Ruby193\\pry_instance.rb"
|
||||
line_num.should == 2
|
||||
end
|
||||
end
|
||||
|
||||
it 'should parse windows style(\\) absolute path with line_num' do
|
||||
file_with_embedded_line = "C:\\Ruby193\\pry_instance.rb:2"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "C:\\Ruby193\\pry_instance.rb"
|
||||
line_num.should == 2
|
||||
describe "UNIX-like filesystem" do
|
||||
it "should parse absolute path without line_num" do
|
||||
file_with_embedded_line = "/Ruby193/pry_instance.rb"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "/Ruby193/pry_instance.rb"
|
||||
line_num.should == nil
|
||||
end
|
||||
|
||||
it "should parse absolute path with line_num" do
|
||||
file_with_embedded_line = "/Ruby193/pry_instance.rb:2"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "/Ruby193/pry_instance.rb"
|
||||
line_num.should == 2
|
||||
end
|
||||
end
|
||||
|
||||
it 'should parse UNIX-like absolute path without line_num' do
|
||||
file_with_embedded_line = "/Ruby193/pry_instance.rb"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "/Ruby193/pry_instance.rb"
|
||||
line_num.should == nil
|
||||
end
|
||||
|
||||
it 'should parse UNIX-like absolute path with line_num' do
|
||||
file_with_embedded_line = "/Ruby193/pry_instance.rb:2"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
file_name.should == "/Ruby193/pry_instance.rb"
|
||||
line_num.should == 2
|
||||
end
|
||||
|
||||
it 'should parse relative path without line_num' do
|
||||
it "should parse relative path without line_num" do
|
||||
file_with_embedded_line = "pry_instance.rb"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
|
@ -68,7 +72,7 @@ describe "cat/file_formatter" do
|
|||
line_num.should == nil
|
||||
end
|
||||
|
||||
it 'should parse relative path with line_num' do
|
||||
it "should parse relative path with line_num" do
|
||||
file_with_embedded_line = "pry_instance.rb:2"
|
||||
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
|
||||
file_name, line_num = ff.file_and_line
|
||||
|
|
Loading…
Add table
Reference in a new issue