diff options
Diffstat (limited to 'spec/ruby/core/file/join_spec.rb')
| -rw-r--r-- | spec/ruby/core/file/join_spec.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/spec/ruby/core/file/join_spec.rb b/spec/ruby/core/file/join_spec.rb index 7c5955d03b..0f0911ea31 100644 --- a/spec/ruby/core/file/join_spec.rb +++ b/spec/ruby/core/file/join_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' describe "File.join" do # see [ruby-core:46804] for the 4 following rules @@ -52,7 +52,7 @@ describe "File.join" do it "returns a duplicate string when given a single argument" do str = "usr" File.join(str).should == str - File.join(str).should_not equal(str) + File.join(str).should_not.equal?(str) end it "supports any number of arguments" do @@ -104,15 +104,15 @@ describe "File.join" do it "raises an ArgumentError if passed a recursive array" do a = ["a"] a << a - lambda { File.join a }.should raise_error(ArgumentError) + -> { File.join a }.should.raise(ArgumentError) end it "raises a TypeError exception when args are nil" do - lambda { File.join nil }.should raise_error(TypeError) + -> { File.join nil }.should.raise(TypeError) end it "calls #to_str" do - lambda { File.join(mock('x')) }.should raise_error(TypeError) + -> { File.join(mock('x')) }.should.raise(TypeError) bin = mock("bin") bin.should_receive(:to_str).exactly(:twice).and_return("bin") @@ -129,11 +129,20 @@ describe "File.join" do end it "calls #to_path" do - lambda { File.join(mock('x')) }.should raise_error(TypeError) + -> { File.join(mock('x')) }.should.raise(TypeError) bin = mock("bin") bin.should_receive(:to_path).exactly(:twice).and_return("bin") File.join(bin).should == "bin" File.join("usr", bin).should == "usr/bin" end + + it "raises errors for null bytes" do + -> { File.join("\x00x", "metadata.gz") }.should.raise(ArgumentError) { |e| + e.message.should == 'string contains null byte' + } + -> { File.join("metadata.gz", "\x00x") }.should.raise(ArgumentError) { |e| + e.message.should == 'string contains null byte' + } + end end |
