diff options
Diffstat (limited to 'spec/ruby/core/dir/shared')
| -rw-r--r-- | spec/ruby/core/dir/shared/chroot.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/core/dir/shared/closed.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/core/dir/shared/delete.rb | 8 | ||||
| -rw-r--r-- | spec/ruby/core/dir/shared/exist.rb | 24 | ||||
| -rw-r--r-- | spec/ruby/core/dir/shared/glob.rb | 12 | ||||
| -rw-r--r-- | spec/ruby/core/dir/shared/open.rb | 18 | ||||
| -rw-r--r-- | spec/ruby/core/dir/shared/path.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/core/dir/shared/pos.rb | 10 | ||||
| -rw-r--r-- | spec/ruby/core/dir/shared/pwd.rb | 4 |
9 files changed, 42 insertions, 42 deletions
diff --git a/spec/ruby/core/dir/shared/chroot.rb b/spec/ruby/core/dir/shared/chroot.rb index a8f7c10a19..e4e6103799 100644 --- a/spec/ruby/core/dir/shared/chroot.rb +++ b/spec/ruby/core/dir/shared/chroot.rb @@ -18,7 +18,7 @@ describe :dir_chroot_as_root, shared: true do compilations_ci = ENV["GITHUB_WORKFLOW"] == "Compilations" it "can be used to change the process' root directory" do - -> { Dir.send(@method, __dir__) }.should_not raise_error + -> { Dir.send(@method, __dir__) }.should_not.raise File.should.exist?("/#{File.basename(__FILE__)}") end unless compilations_ci @@ -27,7 +27,7 @@ describe :dir_chroot_as_root, shared: true do end it "raises an Errno::ENOENT exception if the directory doesn't exist" do - -> { Dir.send(@method, 'xgwhwhsjai2222jg') }.should raise_error(Errno::ENOENT) + -> { Dir.send(@method, 'xgwhwhsjai2222jg') }.should.raise(Errno::ENOENT) end it "can be escaped from with ../" do diff --git a/spec/ruby/core/dir/shared/closed.rb b/spec/ruby/core/dir/shared/closed.rb index 17d8332c2a..c868fd6e6d 100644 --- a/spec/ruby/core/dir/shared/closed.rb +++ b/spec/ruby/core/dir/shared/closed.rb @@ -4,6 +4,6 @@ describe :dir_closed, shared: true do dir = Dir.open DirSpecs.mock_dir dir.close dir.send(@method) {} - }.should raise_error(IOError) + }.should.raise(IOError) end end diff --git a/spec/ruby/core/dir/shared/delete.rb b/spec/ruby/core/dir/shared/delete.rb index a81b059759..ba013e8615 100644 --- a/spec/ruby/core/dir/shared/delete.rb +++ b/spec/ruby/core/dir/shared/delete.rb @@ -20,13 +20,13 @@ describe :dir_delete, shared: true do it "raises an Errno::ENOTEMPTY when trying to remove a nonempty directory" do -> do Dir.send @method, DirSpecs.mock_rmdir("nonempty") - end.should raise_error(Errno::ENOTEMPTY) + end.should.raise(Errno::ENOTEMPTY) end it "raises an Errno::ENOENT when trying to remove a non-existing directory" do -> do Dir.send @method, DirSpecs.nonexistent - end.should raise_error(Errno::ENOENT) + end.should.raise(Errno::ENOENT) end it "raises an Errno::ENOTDIR when trying to remove a non-directory" do @@ -34,7 +34,7 @@ describe :dir_delete, shared: true do touch(file) -> do Dir.send @method, file - end.should raise_error(Errno::ENOTDIR) + end.should.raise(Errno::ENOTDIR) end # this won't work on Windows, since chmod(0000) does not remove all permissions @@ -46,7 +46,7 @@ describe :dir_delete, shared: true do File.chmod(0000, parent) -> do Dir.send @method, child - end.should raise_error(Errno::EACCES) + end.should.raise(Errno::EACCES) end end end diff --git a/spec/ruby/core/dir/shared/exist.rb b/spec/ruby/core/dir/shared/exist.rb index 3097f57715..4ceaccea66 100644 --- a/spec/ruby/core/dir/shared/exist.rb +++ b/spec/ruby/core/dir/shared/exist.rb @@ -1,52 +1,52 @@ describe :dir_exist, shared: true do it "returns true if the given directory exists" do - Dir.send(@method, __dir__).should be_true + Dir.send(@method, __dir__).should == true end it "returns true for '.'" do - Dir.send(@method, '.').should be_true + Dir.send(@method, '.').should == true end it "returns true for '..'" do - Dir.send(@method, '..').should be_true + Dir.send(@method, '..').should == true end it "understands non-ASCII paths" do subdir = File.join(tmp("\u{9876}\u{665}")) - Dir.send(@method, subdir).should be_false + Dir.send(@method, subdir).should == false Dir.mkdir(subdir) - Dir.send(@method, subdir).should be_true + Dir.send(@method, subdir).should == true Dir.rmdir(subdir) end it "understands relative paths" do - Dir.send(@method, __dir__ + '/../').should be_true + Dir.send(@method, __dir__ + '/../').should == true end it "returns false if the given directory doesn't exist" do - Dir.send(@method, 'y26dg27n2nwjs8a/').should be_false + Dir.send(@method, 'y26dg27n2nwjs8a/').should == false end it "doesn't require the name to have a trailing slash" do dir = __dir__ dir.sub!(/\/$/,'') - Dir.send(@method, dir).should be_true + Dir.send(@method, dir).should == true end it "doesn't expand paths" do skip "$HOME not valid directory" unless ENV['HOME'] && File.directory?(ENV['HOME']) - Dir.send(@method, File.expand_path('~')).should be_true - Dir.send(@method, '~').should be_false + Dir.send(@method, File.expand_path('~')).should == true + Dir.send(@method, '~').should == false end it "returns false if the argument exists but is a file" do File.should.exist?(__FILE__) - Dir.send(@method, __FILE__).should be_false + Dir.send(@method, __FILE__).should == false end it "doesn't set $! when file doesn't exist" do Dir.send(@method, "/path/to/non/existent/dir") - $!.should be_nil + $!.should == nil end it "calls #to_path on non String arguments" do diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb index b1fc924f08..86aa105259 100644 --- a/spec/ruby/core/dir/shared/glob.rb +++ b/spec/ruby/core/dir/shared/glob.rb @@ -13,7 +13,7 @@ describe :dir_glob, shared: true do it "raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII" do pattern = "files*".dup.force_encoding Encoding::UTF_16BE - -> { Dir.send(@method, pattern) }.should raise_error(Encoding::CompatibilityError) + -> { Dir.send(@method, pattern) }.should.raise(Encoding::CompatibilityError) end it "calls #to_path to convert a pattern" do @@ -24,7 +24,7 @@ describe :dir_glob, shared: true do end it "raises an ArgumentError if the string contains \\0" do - -> {Dir.send(@method, "file_o*\0file_t*")}.should raise_error ArgumentError, /nul-separated/ + -> {Dir.send(@method, "file_o*\0file_t*")}.should.raise ArgumentError, /nul-separated/ end it "result is sorted by default" do @@ -43,9 +43,9 @@ describe :dir_glob, shared: true do end it "raises an ArgumentError if sort: is not true or false" do - -> { Dir.send(@method, '*', sort: 0) }.should raise_error ArgumentError, /expected true or false/ - -> { Dir.send(@method, '*', sort: nil) }.should raise_error ArgumentError, /expected true or false/ - -> { Dir.send(@method, '*', sort: 'false') }.should raise_error ArgumentError, /expected true or false/ + -> { Dir.send(@method, '*', sort: 0) }.should.raise ArgumentError, /expected true or false/ + -> { Dir.send(@method, '*', sort: nil) }.should.raise ArgumentError, /expected true or false/ + -> { Dir.send(@method, '*', sort: 'false') }.should.raise ArgumentError, /expected true or false/ end it "matches non-dotfiles with '*'" do @@ -373,7 +373,7 @@ describe :dir_glob, shared: true do it "raises TypeError when cannot convert value to string" do -> { Dir.send(@method, "*", base: []) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "handles '' as current directory path" do diff --git a/spec/ruby/core/dir/shared/open.rb b/spec/ruby/core/dir/shared/open.rb index 920845cba1..9ac3a40694 100644 --- a/spec/ruby/core/dir/shared/open.rb +++ b/spec/ruby/core/dir/shared/open.rb @@ -1,18 +1,18 @@ describe :dir_open, shared: true do it "returns a Dir instance representing the specified directory" do dir = Dir.send(@method, DirSpecs.mock_dir) - dir.should be_kind_of(Dir) + dir.should.is_a?(Dir) dir.close end it "raises a SystemCallError if the directory does not exist" do -> do Dir.send @method, DirSpecs.nonexistent - end.should raise_error(SystemCallError) + end.should.raise(SystemCallError) end it "may take a block which is yielded to with the Dir instance" do - Dir.send(@method, DirSpecs.mock_dir) {|dir| dir.should be_kind_of(Dir)} + Dir.send(@method, DirSpecs.mock_dir) {|dir| dir.should.is_a?(Dir)} end it "returns the value of the block if a block is given" do @@ -21,7 +21,7 @@ describe :dir_open, shared: true do it "closes the Dir instance when the block exits if given a block" do closed_dir = Dir.send(@method, DirSpecs.mock_dir) { |dir| dir } - -> { closed_dir.read }.should raise_error(IOError) + -> { closed_dir.read }.should.raise(IOError) end it "closes the Dir instance when the block exits the block even due to an exception" do @@ -32,9 +32,9 @@ describe :dir_open, shared: true do closed_dir = dir raise "dir specs" end - end.should raise_error(RuntimeError, "dir specs") + end.should.raise(RuntimeError, "dir specs") - -> { closed_dir.read }.should raise_error(IOError) + -> { closed_dir.read }.should.raise(IOError) end it "calls #to_path on non-String arguments" do @@ -45,7 +45,7 @@ describe :dir_open, shared: true do it "accepts an options Hash" do dir = Dir.send(@method, DirSpecs.mock_dir, encoding: "utf-8") {|d| d } - dir.should be_kind_of(Dir) + dir.should.is_a?(Dir) end it "calls #to_hash to convert the options object" do @@ -53,12 +53,12 @@ describe :dir_open, shared: true do options.should_receive(:to_hash).and_return({ encoding: Encoding::UTF_8 }) dir = Dir.send(@method, DirSpecs.mock_dir, **options) {|d| d } - dir.should be_kind_of(Dir) + dir.should.is_a?(Dir) end it "ignores the :encoding option if it is nil" do dir = Dir.send(@method, DirSpecs.mock_dir, encoding: nil) {|d| d } - dir.should be_kind_of(Dir) + dir.should.is_a?(Dir) end platform_is_not :windows do diff --git a/spec/ruby/core/dir/shared/path.rb b/spec/ruby/core/dir/shared/path.rb index 494dcca775..7647c04421 100644 --- a/spec/ruby/core/dir/shared/path.rb +++ b/spec/ruby/core/dir/shared/path.rb @@ -22,7 +22,7 @@ describe :dir_path, shared: true do path = DirSpecs.mock_dir.force_encoding Encoding::IBM866 dir = Dir.open path begin - dir.send(@method).encoding.should equal(Encoding::IBM866) + dir.send(@method).encoding.should.equal?(Encoding::IBM866) ensure dir.close end diff --git a/spec/ruby/core/dir/shared/pos.rb b/spec/ruby/core/dir/shared/pos.rb index 2165932d99..11712cc75d 100644 --- a/spec/ruby/core/dir/shared/pos.rb +++ b/spec/ruby/core/dir/shared/pos.rb @@ -8,9 +8,9 @@ describe :dir_pos, shared: true do end it "returns an Integer representing the current position in the directory" do - @dir.send(@method).should be_kind_of(Integer) - @dir.send(@method).should be_kind_of(Integer) - @dir.send(@method).should be_kind_of(Integer) + @dir.send(@method).should.is_a?(Integer) + @dir.send(@method).should.is_a?(Integer) + @dir.send(@method).should.is_a?(Integer) end it "returns a different Integer if moved from previous position" do @@ -18,8 +18,8 @@ describe :dir_pos, shared: true do @dir.read b = @dir.send(@method) - a.should be_kind_of(Integer) - b.should be_kind_of(Integer) + a.should.is_a?(Integer) + b.should.is_a?(Integer) a.should_not == b end diff --git a/spec/ruby/core/dir/shared/pwd.rb b/spec/ruby/core/dir/shared/pwd.rb index 2a8d7fe790..ed47fe382a 100644 --- a/spec/ruby/core/dir/shared/pwd.rb +++ b/spec/ruby/core/dir/shared/pwd.rb @@ -37,9 +37,9 @@ describe :dir_pwd, shared: true do it "returns a String with the filesystem encoding" do enc = Dir.send(@method).encoding if @fs_encoding == Encoding::US_ASCII - [Encoding::US_ASCII, Encoding::BINARY].should include(enc) + [Encoding::US_ASCII, Encoding::BINARY].should.include?(enc) else - enc.should equal(@fs_encoding) + enc.should.equal?(@fs_encoding) end end end |
