summaryrefslogtreecommitdiff
path: root/spec/ruby/library/pathname
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/pathname')
-rw-r--r--spec/ruby/library/pathname/birthtime_spec.rb4
-rw-r--r--spec/ruby/library/pathname/empty_spec.rb8
-rw-r--r--spec/ruby/library/pathname/glob_spec.rb12
-rw-r--r--spec/ruby/library/pathname/inspect_spec.rb2
-rw-r--r--spec/ruby/library/pathname/new_spec.rb12
-rw-r--r--spec/ruby/library/pathname/pathname_spec.rb4
-rw-r--r--spec/ruby/library/pathname/realdirpath_spec.rb2
-rw-r--r--spec/ruby/library/pathname/realpath_spec.rb2
-rw-r--r--spec/ruby/library/pathname/relative_path_from_spec.rb4
9 files changed, 29 insertions, 21 deletions
diff --git a/spec/ruby/library/pathname/birthtime_spec.rb b/spec/ruby/library/pathname/birthtime_spec.rb
index 109c112303..387f0aa54d 100644
--- a/spec/ruby/library/pathname/birthtime_spec.rb
+++ b/spec/ruby/library/pathname/birthtime_spec.rb
@@ -4,13 +4,13 @@ require 'pathname'
describe "Pathname#birthtime" do
platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birth time for self" do
- Pathname.new(__FILE__).birthtime.should be_kind_of(Time)
+ Pathname.new(__FILE__).birthtime.should.is_a?(Time)
end
end
platform_is :openbsd do
it "raises an NotImplementedError" do
- -> { Pathname.new(__FILE__).birthtime }.should raise_error(NotImplementedError)
+ -> { Pathname.new(__FILE__).birthtime }.should.raise(NotImplementedError)
end
end
end
diff --git a/spec/ruby/library/pathname/empty_spec.rb b/spec/ruby/library/pathname/empty_spec.rb
index 4deade5b64..9f0305a0f0 100644
--- a/spec/ruby/library/pathname/empty_spec.rb
+++ b/spec/ruby/library/pathname/empty_spec.rb
@@ -15,18 +15,18 @@ describe 'Pathname#empty?' do
end
it 'returns true when file is not empty' do
- Pathname.new(__FILE__).empty?.should be_false
+ Pathname.new(__FILE__).empty?.should == false
end
it 'returns false when the directory is not empty' do
- Pathname.new(__dir__).empty?.should be_false
+ Pathname.new(__dir__).empty?.should == false
end
it 'return true when file is empty' do
- Pathname.new(@file).empty?.should be_true
+ Pathname.new(@file).empty?.should == true
end
it 'returns true when directory is empty' do
- Pathname.new(@dir).empty?.should be_true
+ Pathname.new(@dir).empty?.should == true
end
end
diff --git a/spec/ruby/library/pathname/glob_spec.rb b/spec/ruby/library/pathname/glob_spec.rb
index ced810fa90..e20e6f8f85 100644
--- a/spec/ruby/library/pathname/glob_spec.rb
+++ b/spec/ruby/library/pathname/glob_spec.rb
@@ -21,6 +21,10 @@ describe 'Pathname.glob' do
Pathname.glob(@dir + 'lib/*.js').should == []
end
+ it 'returns [] when the pathname does not exist' do
+ Pathname.glob('i_dont_exist/lib/*.js').should == []
+ end
+
it 'returns matching file paths' do
Pathname.glob(@dir + 'lib/*i*.rb').sort.should == [Pathname.new(@file_1), Pathname.new(@file_2)].sort
end
@@ -37,7 +41,7 @@ describe 'Pathname.glob' do
it "raises an ArgumentError when supplied a keyword argument other than :base" do
-> {
Pathname.glob('*i*.rb', foo: @dir + 'lib')
- }.should raise_error(ArgumentError, /unknown keyword: :?foo/)
+ }.should.raise(ArgumentError, "unknown keyword: :foo")
end
it "does not raise an ArgumentError when supplied a flag and :base keyword argument" do
@@ -67,13 +71,17 @@ describe 'Pathname#glob' do
Pathname.new(@dir).glob('lib/*.js').should == []
end
+ it 'returns [] when the pathname does not exist' do
+ Pathname.new('./i_dont_exist').glob('lib/*.js').should == []
+ end
+
it 'returns matching file paths' do
Pathname.new(@dir).glob('lib/*i*.rb').sort.should == [Pathname.new(@file_1), Pathname.new(@file_2)].sort
end
it 'yields matching file paths to block' do
ary = []
- Pathname.new(@dir).glob('lib/*i*.rb') { |p| ary << p }.should be_nil
+ Pathname.new(@dir).glob('lib/*i*.rb') { |p| ary << p }.should == nil
ary.sort.should == [Pathname.new(@file_1), Pathname.new(@file_2)].sort
end
diff --git a/spec/ruby/library/pathname/inspect_spec.rb b/spec/ruby/library/pathname/inspect_spec.rb
index 304746fbe5..3abba6cbb5 100644
--- a/spec/ruby/library/pathname/inspect_spec.rb
+++ b/spec/ruby/library/pathname/inspect_spec.rb
@@ -4,7 +4,7 @@ require 'pathname'
describe "Pathname#inspect" do
it "returns a consistent String" do
result = Pathname.new('/tmp').inspect
- result.should be_an_instance_of(String)
+ result.should.instance_of?(String)
result.should == "#<Pathname:/tmp>"
end
end
diff --git a/spec/ruby/library/pathname/new_spec.rb b/spec/ruby/library/pathname/new_spec.rb
index 36226ed515..3ef9d9b76d 100644
--- a/spec/ruby/library/pathname/new_spec.rb
+++ b/spec/ruby/library/pathname/new_spec.rb
@@ -3,18 +3,18 @@ require 'pathname'
describe "Pathname.new" do
it "returns a new Pathname Object with 1 argument" do
- Pathname.new('').should be_kind_of(Pathname)
+ Pathname.new('').should.is_a?(Pathname)
end
it "raises an ArgumentError when called with \0" do
- -> { Pathname.new("\0")}.should raise_error(ArgumentError)
+ -> { Pathname.new("\0")}.should.raise(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- -> { Pathname.new(nil) }.should raise_error(TypeError)
- -> { Pathname.new(0) }.should raise_error(TypeError)
- -> { Pathname.new(true) }.should raise_error(TypeError)
- -> { Pathname.new(false) }.should raise_error(TypeError)
+ -> { Pathname.new(nil) }.should.raise(TypeError)
+ -> { Pathname.new(0) }.should.raise(TypeError)
+ -> { Pathname.new(true) }.should.raise(TypeError)
+ -> { Pathname.new(false) }.should.raise(TypeError)
end
it "initializes with an object with to_path" do
diff --git a/spec/ruby/library/pathname/pathname_spec.rb b/spec/ruby/library/pathname/pathname_spec.rb
index 0fb2881468..6fa6fd2bcb 100644
--- a/spec/ruby/library/pathname/pathname_spec.rb
+++ b/spec/ruby/library/pathname/pathname_spec.rb
@@ -3,11 +3,11 @@ require 'pathname'
describe "Kernel#Pathname" do
it "is a private instance method" do
- Kernel.should have_private_instance_method(:Pathname)
+ Kernel.private_instance_methods(false).should.include?(:Pathname)
end
it "is also a public method" do
- Kernel.should have_method(:Pathname)
+ Kernel.should.respond_to?(:Pathname)
end
it "returns same argument when called with a pathname argument" do
diff --git a/spec/ruby/library/pathname/realdirpath_spec.rb b/spec/ruby/library/pathname/realdirpath_spec.rb
index a9e44e354e..e50741a737 100644
--- a/spec/ruby/library/pathname/realdirpath_spec.rb
+++ b/spec/ruby/library/pathname/realdirpath_spec.rb
@@ -4,7 +4,7 @@ require 'pathname'
describe "Pathname#realdirpath" do
it "returns a Pathname" do
- Pathname.pwd.realdirpath.should be_an_instance_of(Pathname)
+ Pathname.pwd.realdirpath.should.instance_of?(Pathname)
end
end
diff --git a/spec/ruby/library/pathname/realpath_spec.rb b/spec/ruby/library/pathname/realpath_spec.rb
index f2c654308e..d8b87f57d0 100644
--- a/spec/ruby/library/pathname/realpath_spec.rb
+++ b/spec/ruby/library/pathname/realpath_spec.rb
@@ -4,7 +4,7 @@ require 'pathname'
describe "Pathname#realpath" do
it "returns a Pathname" do
- Pathname.pwd.realpath.should be_an_instance_of(Pathname)
+ Pathname.pwd.realpath.should.instance_of?(Pathname)
end
end
diff --git a/spec/ruby/library/pathname/relative_path_from_spec.rb b/spec/ruby/library/pathname/relative_path_from_spec.rb
index 133a149849..7cbd22c3d6 100644
--- a/spec/ruby/library/pathname/relative_path_from_spec.rb
+++ b/spec/ruby/library/pathname/relative_path_from_spec.rb
@@ -7,11 +7,11 @@ describe "Pathname#relative_path_from" do
end
it "raises an error when the two paths do not share a common prefix" do
- -> { relative_path_str('/usr', 'foo') }.should raise_error(ArgumentError)
+ -> { relative_path_str('/usr', 'foo') }.should.raise(ArgumentError)
end
it "raises an error when the base directory has .." do
- -> { relative_path_str('a', '..') }.should raise_error(ArgumentError)
+ -> { relative_path_str('a', '..') }.should.raise(ArgumentError)
end
it "returns a path relative from root" do