Skip to content

Commit

Permalink
file_formatter_spec: simplify tests a bit
Browse files Browse the repository at this point in the history
* simplify test names

* use described_class instead of the actual name.
  It's shorter.
  • Loading branch information
kyrylo committed Feb 26, 2015
1 parent 6dc8007 commit 2542f07
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions spec/commands/cat/file_formatter_spec.rb
Expand Up @@ -12,68 +12,68 @@
end

describe "windows filesystem" do
it "should parse '/'style absolute path without line_num" do
it "parses '/'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)
ff = described_class.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should eq "C:/Ruby193/pry_instance.rb"
line_num.should eq nil
end

it "should parse '/'style absolute path with line_num" do
it "parses '/'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)
ff = described_class.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should eq "C:/Ruby193/pry_instance.rb"
line_num.should eq 2
end

it "should parse '\\'style absolute path without line_num" do
it "parses '\\'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)
ff = described_class.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should eq "C:\\Ruby193\\pry_instance.rb"
line_num.should eq nil
end

it "should parse '\\'style absolute path with line_num" do
it "parses '\\'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)
ff = described_class.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should eq "C:\\Ruby193\\pry_instance.rb"
line_num.should eq 2
end
end

describe "UNIX-like filesystem" do
it "should parse absolute path without line_num" do
it "parses 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)
ff = described_class.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should eq "/Ruby193/pry_instance.rb"
line_num.should eq nil
end

it "should parse absolute path with line_num" do
it "parses 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)
ff = described_class.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should eq "/Ruby193/pry_instance.rb"
line_num.should eq 2
end
end

it "should parse relative path without line_num" do
it "parses 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)
ff = described_class.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should eq "pry_instance.rb"
line_num.should eq nil
end

it "should parse relative path with line_num" do
it "parses 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)
ff = described_class.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should eq "pry_instance.rb"
line_num.should eq 2
Expand All @@ -82,12 +82,12 @@

describe "#format" do
it "formats given files" do
ff = Pry::Command::Cat::FileFormatter.new(__FILE__, @p, @opt)
ff = described_class.new(__FILE__, @p, @opt)
expect(ff.format).to match(/it "formats given files" do/)
end

it "should format given files with line number" do
ff = Pry::Command::Cat::FileFormatter.new(__FILE__ + ':83', @p, @opt)
it "formats given files with line number" do
ff = described_class.new(__FILE__ + ':83', @p, @opt)
expect(ff.format).to match(/it "formats given files" do/)
end
end
Expand Down

0 comments on commit 2542f07

Please sign in to comment.