From 070cbe22b70ec2bec36c7cfc84b726510afa306f Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 29 Sep 2019 19:13:37 +0200 Subject: Update to ruby/spec@34e6246 --- spec/ruby/core/dir/chdir_spec.rb | 4 +-- spec/ruby/core/dir/mkdir_spec.rb | 4 +-- spec/ruby/core/dir/shared/chroot.rb | 6 ++-- spec/ruby/core/dir/shared/exist.rb | 2 +- spec/ruby/core/dir/shared/glob.rb | 4 +-- spec/ruby/core/file/link_spec.rb | 2 +- spec/ruby/core/file/new_spec.rb | 26 ++++++++-------- spec/ruby/core/file/open_spec.rb | 42 +++++++++++++------------- spec/ruby/core/file/rename_spec.rb | 8 ++--- spec/ruby/core/file/shared/path.rb | 3 +- spec/ruby/core/file/shared/unlink.rb | 10 +++--- spec/ruby/core/file/world_readable_spec.rb | 2 +- spec/ruby/core/file/world_writable_spec.rb | 2 +- spec/ruby/core/io/advise_spec.rb | 3 +- spec/ruby/core/io/reopen_spec.rb | 4 +-- spec/ruby/core/io/shared/binwrite.rb | 8 ++--- spec/ruby/core/io/shared/tty.rb | 3 +- spec/ruby/core/io/write_nonblock_spec.rb | 6 ++-- spec/ruby/core/kernel/caller_locations_spec.rb | 2 +- spec/ruby/core/kernel/shared/require.rb | 8 ++--- spec/ruby/core/string/dump_spec.rb | 4 +-- spec/ruby/core/string/end_with_spec.rb | 21 ++++++------- spec/ruby/core/string/start_with_spec.rb | 36 +++++++++++----------- 23 files changed, 104 insertions(+), 106 deletions(-) (limited to 'spec/ruby/core') diff --git a/spec/ruby/core/dir/chdir_spec.rb b/spec/ruby/core/dir/chdir_spec.rb index e9b8274382..729ac403e3 100644 --- a/spec/ruby/core/dir/chdir_spec.rb +++ b/spec/ruby/core/dir/chdir_spec.rb @@ -95,8 +95,8 @@ describe "Dir.chdir" do it "raises an Errno::ENOENT if the original directory no longer exists" do dir1 = tmp('/testdir1') dir2 = tmp('/testdir2') - File.exist?(dir1).should == false - File.exist?(dir2).should == false + File.should_not.exist?(dir1) + File.should_not.exist?(dir2) Dir.mkdir dir1 Dir.mkdir dir2 begin diff --git a/spec/ruby/core/dir/mkdir_spec.rb b/spec/ruby/core/dir/mkdir_spec.rb index 58767a5aa0..c6e2f164e2 100644 --- a/spec/ruby/core/dir/mkdir_spec.rb +++ b/spec/ruby/core/dir/mkdir_spec.rb @@ -14,9 +14,9 @@ describe "Dir.mkdir" do DirSpecs.clear_dirs begin - File.exist?('nonexisting').should == false + File.should_not.exist?('nonexisting') Dir.mkdir 'nonexisting' - File.exist?('nonexisting').should == true + File.should.exist?('nonexisting') platform_is_not :windows do Dir.mkdir 'default_perms' a = File.stat('default_perms').mode diff --git a/spec/ruby/core/dir/shared/chroot.rb b/spec/ruby/core/dir/shared/chroot.rb index 93699f93be..b14a433670 100644 --- a/spec/ruby/core/dir/shared/chroot.rb +++ b/spec/ruby/core/dir/shared/chroot.rb @@ -16,7 +16,7 @@ describe :dir_chroot_as_root, shared: true do it "can be used to change the process' root directory" do -> { Dir.send(@method, File.dirname(__FILE__)) }.should_not raise_error - File.exist?("/#{File.basename(__FILE__)}").should be_true + File.should.exist?("/#{File.basename(__FILE__)}") end it "returns 0 if successful" do @@ -29,8 +29,8 @@ describe :dir_chroot_as_root, shared: true do it "can be escaped from with ../" do Dir.send(@method, @real_root) - File.exist?(@ref_dir).should be_true - File.exist?("/#{File.basename(__FILE__)}").should be_false + File.should.exist?(@ref_dir) + File.should_not.exist?("/#{File.basename(__FILE__)}") end it "calls #to_path on non-String argument" do diff --git a/spec/ruby/core/dir/shared/exist.rb b/spec/ruby/core/dir/shared/exist.rb index fbd2c9862d..765d1b656c 100644 --- a/spec/ruby/core/dir/shared/exist.rb +++ b/spec/ruby/core/dir/shared/exist.rb @@ -39,7 +39,7 @@ describe :dir_exist, shared: true do end it "returns false if the argument exists but is a file" do - File.exist?(__FILE__).should be_true + File.should.exist?(__FILE__) Dir.send(@method, __FILE__).should be_false end diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb index 62675145df..b47e23b41c 100644 --- a/spec/ruby/core/dir/shared/glob.rb +++ b/spec/ruby/core/dir/shared/glob.rb @@ -331,14 +331,14 @@ describe :dir_glob, shared: true do it "returns [] if specified path does not exist" do path = File.join(@mock_dir, "fake-name") - File.exist?(path).should == false + File.should_not.exist?(path) Dir.send(@method, "*", base: path).should == [] end it "returns [] if specified path is a file" do path = File.join(@mock_dir, "a/b/x") - File.exist?(path).should == true + File.should.exist?(path) Dir.send(@method, "*", base: path).should == [] end diff --git a/spec/ruby/core/file/link_spec.rb b/spec/ruby/core/file/link_spec.rb index 11d4c8d25b..cc63c76aa3 100644 --- a/spec/ruby/core/file/link_spec.rb +++ b/spec/ruby/core/file/link_spec.rb @@ -16,7 +16,7 @@ describe "File.link" do platform_is_not :windows do it "link a file with another" do File.link(@file, @link).should == 0 - File.exist?(@link).should == true + File.should.exist?(@link) File.identical?(@file, @link).should == true end diff --git a/spec/ruby/core/file/new_spec.rb b/spec/ruby/core/file/new_spec.rb index e99f6ba72b..004f78503a 100644 --- a/spec/ruby/core/file/new_spec.rb +++ b/spec/ruby/core/file/new_spec.rb @@ -17,13 +17,13 @@ describe "File.new" do it "returns a new File with mode string" do @fh = File.new(@file, 'w') @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "returns a new File with mode num" do @fh = File.new(@file, @flags) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "returns a new File with modus num and permissions" do @@ -34,7 +34,7 @@ describe "File.new" do platform_is_not :windows do File.stat(@file).mode.to_s(8).should == "100744" end - File.exist?(@file).should == true + File.should.exist?(@file) end it "creates the file and returns writable descriptor when called with 'w' mode and r-o permissions" do @@ -48,7 +48,7 @@ describe "File.new" do ensure f.close end - File.exist?(@file).should == true + File.should.exist?(@file) File.read(@file).should == "test\n" end @@ -75,13 +75,13 @@ describe "File.new" do fh_copy = File.new(@fh.fileno) fh_copy.autoclose = false fh_copy.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "creates a new file when use File::EXCL mode" do @fh = File.new(@file, File::EXCL) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "raises an Errorno::EEXIST if the file exists when create a new file with File::CREAT|File::EXCL" do @@ -91,46 +91,46 @@ describe "File.new" do it "creates a new file when use File::WRONLY|File::APPEND mode" do @fh = File.new(@file, File::WRONLY|File::APPEND) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "returns a new File when use File::APPEND mode" do @fh = File.new(@file, File::APPEND) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "returns a new File when use File::RDONLY|File::APPEND mode" do @fh = File.new(@file, File::RDONLY|File::APPEND) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "returns a new File when use File::RDONLY|File::WRONLY mode" do @fh = File.new(@file, File::RDONLY|File::WRONLY) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "creates a new file when use File::WRONLY|File::TRUNC mode" do @fh = File.new(@file, File::WRONLY|File::TRUNC) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "coerces filename using to_str" do name = mock("file") name.should_receive(:to_str).and_return(@file) @fh = File.new(name, "w") - File.exist?(@file).should == true + File.should.exist?(@file) end it "coerces filename using #to_path" do name = mock("file") name.should_receive(:to_path).and_return(@file) @fh = File.new(name, "w") - File.exist?(@file).should == true + File.should.exist?(@file) end it "raises a TypeError if the first parameter can't be coerced to a string" do diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb index b6af2686e4..93f1972ac6 100644 --- a/spec/ruby/core/file/open_spec.rb +++ b/spec/ruby/core/file/open_spec.rb @@ -63,40 +63,40 @@ describe "File.open" do it "opens the file (basic case)" do @fh = File.open(@file) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens the file with unicode characters" do @fh = File.open(@unicode_path, "w") @fh.should be_kind_of(File) - File.exist?(@unicode_path).should == true + File.should.exist?(@unicode_path) end it "opens a file when called with a block" do File.open(@file) { |fh| } - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens with mode string" do @fh = File.open(@file, 'w') @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file with mode string and block" do File.open(@file, 'w') { |fh| } - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file with mode num" do @fh = File.open(@file, @flags) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file with mode num and block" do File.open(@file, 'w') { |fh| } - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file with mode and permission as nil" do @@ -113,7 +113,7 @@ describe "File.open" do platform_is_not :windows do @fh.lstat.mode.to_s(8).should == "100744" end - File.exist?(@file).should == true + File.should.exist?(@file) end # For this test we delete the file first to reset the perms @@ -124,7 +124,7 @@ describe "File.open" do platform_is_not :windows do File.stat(@file).mode.to_s(8).should == "100755" end - File.exist?(@file).should == true + File.should.exist?(@file) end it "creates the file and returns writable descriptor when called with 'w' mode and r-o permissions" do @@ -162,7 +162,7 @@ describe "File.open" do fh_copy = File.open(@fh.fileno) fh_copy.autoclose = false fh_copy.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file that no exists when use File::WRONLY mode" do @@ -206,19 +206,19 @@ describe "File.open" do it "opens a file that no exists when use File::CREAT mode" do @fh = File.open(@nonexistent, File::CREAT) { |f| f } @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file that no exists when use 'a' mode" do @fh = File.open(@nonexistent, 'a') { |f| f } @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file that no exists when use 'w' mode" do @fh = File.open(@nonexistent, 'w') { |f| f } @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end # Check the grants associated to the different open modes combinations. @@ -365,7 +365,7 @@ describe "File.open" do it "creates a new file when use File::WRONLY|File::APPEND mode" do @fh = File.open(@file, File::WRONLY|File::APPEND) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file when use File::WRONLY|File::APPEND mode" do @@ -408,7 +408,7 @@ describe "File.open" do begin @fh = File.open(@file, File::WRONLY|File::TRUNC) @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) ensure fh1.close end @@ -471,13 +471,13 @@ describe "File.open" do it "opens a file for binary read" do @fh = File.open(@file, "rb") @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file for binary write" do @fh = File.open(@file, "wb") @fh.should be_kind_of(File) - File.exist?(@file).should == true + File.should.exist?(@file) end it "opens a file for read-write and truncate the file" do @@ -523,10 +523,10 @@ describe "File.open" do io.read.should == "ruby" Dir["#{dir}/*"].should == [] end - rescue Errno::EOPNOTSUPP, Errno::EINVAL, Errno::EISDIR - # EOPNOTSUPP: no support from the filesystem - # EINVAL: presumably bug in glibc - 1.should == 1 + rescue Errno::EOPNOTSUPP + skip "no support from the filesystem" + rescue Errno::EINVAL, Errno::EISDIR + skip "presumably bug in glibc" ensure rm_r dir end diff --git a/spec/ruby/core/file/rename_spec.rb b/spec/ruby/core/file/rename_spec.rb index d903e7a0d5..f2c18d4905 100644 --- a/spec/ruby/core/file/rename_spec.rb +++ b/spec/ruby/core/file/rename_spec.rb @@ -14,11 +14,11 @@ describe "File.rename" do end it "renames a file" do - File.exist?(@old).should == true - File.exist?(@new).should == false + File.should.exist?(@old) + File.should_not.exist?(@new) File.rename(@old, @new) - File.exist?(@old).should == false - File.exist?(@new).should == true + File.should_not.exist?(@old) + File.should.exist?(@new) end it "raises an Errno::ENOENT if the source does not exist" do diff --git a/spec/ruby/core/file/shared/path.rb b/spec/ruby/core/file/shared/path.rb index 9df3416c89..cfd119f799 100644 --- a/spec/ruby/core/file/shared/path.rb +++ b/spec/ruby/core/file/shared/path.rb @@ -68,8 +68,7 @@ describe :file_path, shared: true do -> { f.send(@method) }.should raise_error(IOError) end rescue Errno::EOPNOTSUPP, Errno::EINVAL, Errno::EISDIR - # EOPNOTSUPP: no support from the filesystem - 1.should == 1 + skip "no support from the filesystem" end end end diff --git a/spec/ruby/core/file/shared/unlink.rb b/spec/ruby/core/file/shared/unlink.rb index d72ab4701f..e339e93271 100644 --- a/spec/ruby/core/file/shared/unlink.rb +++ b/spec/ruby/core/file/shared/unlink.rb @@ -21,13 +21,13 @@ describe :file_unlink, shared: true do it "deletes a single file" do File.send(@method, @file1).should == 1 - File.exist?(@file1).should == false + File.should_not.exist?(@file1) end it "deletes multiple files" do File.send(@method, @file1, @file2).should == 2 - File.exist?(@file1).should == false - File.exist?(@file2).should == false + File.should_not.exist?(@file1) + File.should_not.exist?(@file2) end it "raises a TypeError if not passed a String type" do @@ -52,10 +52,10 @@ describe :file_unlink, shared: true do it "allows deleting an open file with File::SHARE_DELETE" do path = tmp("share_delete.txt") File.open(path, mode: File::CREAT | File::WRONLY | File::BINARY | File::SHARE_DELETE) do |f| - File.exist?(path).should be_true + File.should.exist?(path) File.send(@method, path) end - File.exist?(path).should be_false + File.should_not.exist?(path) end end end diff --git a/spec/ruby/core/file/world_readable_spec.rb b/spec/ruby/core/file/world_readable_spec.rb index 7e6c60b65c..11b8e67d0b 100644 --- a/spec/ruby/core/file/world_readable_spec.rb +++ b/spec/ruby/core/file/world_readable_spec.rb @@ -6,7 +6,7 @@ describe "File.world_readable?" do it "returns nil if the file does not exist" do file = rand.to_s + $$.to_s - File.exist?(file).should be_false + File.should_not.exist?(file) File.world_readable?(file).should be_nil end end diff --git a/spec/ruby/core/file/world_writable_spec.rb b/spec/ruby/core/file/world_writable_spec.rb index 00333a98ab..d378cf2eb9 100644 --- a/spec/ruby/core/file/world_writable_spec.rb +++ b/spec/ruby/core/file/world_writable_spec.rb @@ -6,7 +6,7 @@ describe "File.world_writable?" do it "returns nil if the file does not exist" do file = rand.to_s + $$.to_s - File.exist?(file).should be_false + File.should_not.exist?(file) File.world_writable?(file).should be_nil end end diff --git a/spec/ruby/core/io/advise_spec.rb b/spec/ruby/core/io/advise_spec.rb index 59469fa164..0a845487e2 100644 --- a/spec/ruby/core/io/advise_spec.rb +++ b/spec/ruby/core/io/advise_spec.rb @@ -82,8 +82,7 @@ describe "IO#advise" do `uname -r`.chomp end if (uname.split('.').map(&:to_i) <=> [3,6]) < 0 - # [ruby-core:65355] tmpfs is not supported - 1.should == 1 + skip "[ruby-core:65355] tmpfs is not supported" else @io.advise(:willneed).should be_nil end diff --git a/spec/ruby/core/io/reopen_spec.rb b/spec/ruby/core/io/reopen_spec.rb index 975f654b66..faef80f513 100644 --- a/spec/ruby/core/io/reopen_spec.rb +++ b/spec/ruby/core/io/reopen_spec.rb @@ -161,14 +161,14 @@ describe "IO#reopen with a String" do @io = new_io @name, "w" @io.reopen(@other_name) - File.exist?(@other_name).should be_true + File.should.exist?(@other_name) end it "creates the file if it doesn't exist if the IO is opened in write mode" do @io = new_io @name, "a" @io.reopen(@other_name) - File.exist?(@other_name).should be_true + File.should.exist?(@other_name) end end diff --git a/spec/ruby/core/io/shared/binwrite.rb b/spec/ruby/core/io/shared/binwrite.rb index 29310e1eaf..3649bb47ff 100644 --- a/spec/ruby/core/io/shared/binwrite.rb +++ b/spec/ruby/core/io/shared/binwrite.rb @@ -24,9 +24,9 @@ describe :io_binwrite, shared: true do it "creates a file if missing" do fn = @filename + "xxx" begin - File.exist?(fn).should be_false + File.should_not.exist?(fn) IO.send(@method, fn, "test") - File.exist?(fn).should be_true + File.should.exist?(fn) ensure rm_r fn end @@ -35,9 +35,9 @@ describe :io_binwrite, shared: true do it "creates file if missing even if offset given" do fn = @filename + "xxx" begin - File.exist?(fn).should be_false + File.should_not.exist?(fn) IO.send(@method, fn, "test", 0) - File.exist?(fn).should be_true + File.should.exist?(fn) ensure rm_r fn end diff --git a/spec/ruby/core/io/shared/tty.rb b/spec/ruby/core/io/shared/tty.rb index 82a780a9f3..89ac08ec86 100644 --- a/spec/ruby/core/io/shared/tty.rb +++ b/spec/ruby/core/io/shared/tty.rb @@ -7,8 +7,7 @@ describe :io_tty, shared: true do # check to enabled tty File.open('/dev/tty') {} rescue Errno::ENXIO - # workaround for not configured environment like OS X - 1.should == 1 + skip "workaround for not configured environment like OS X" else File.open('/dev/tty') { |f| f.send(@method) }.should == true end diff --git a/spec/ruby/core/io/write_nonblock_spec.rb b/spec/ruby/core/io/write_nonblock_spec.rb index 18adfcfc4a..5474e5c6ce 100644 --- a/spec/ruby/core/io/write_nonblock_spec.rb +++ b/spec/ruby/core/io/write_nonblock_spec.rb @@ -68,8 +68,10 @@ describe 'IO#write_nonblock' do context "when exception option is set to false" do it "returns :wait_writable when the operation would block" do - loop { break if @write.write_nonblock("a" * 10_000, exception: false) == :wait_writable } - 1.should == 1 + loop { + break if @write.write_nonblock("a" * 10_000, exception: false) == :wait_writable + } + @write.write_nonblock("a" * 10_000, exception: false).should == :wait_writable end end diff --git a/spec/ruby/core/kernel/caller_locations_spec.rb b/spec/ruby/core/kernel/caller_locations_spec.rb index 03c05883d1..4de6c2ffd6 100644 --- a/spec/ruby/core/kernel/caller_locations_spec.rb +++ b/spec/ruby/core/kernel/caller_locations_spec.rb @@ -13,7 +13,7 @@ describe 'Kernel#caller_locations' do it 'returns an Array of caller locations using a custom offset' do locations = KernelSpecs::CallerLocationsTest.locations(2) - locations[0].absolute_path.end_with?('mspec.rb').should == true + locations[0].absolute_path.should.end_with?('mspec.rb') end it 'returns an Array of caller locations using a custom limit' do diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb index cfa1a4bbbd..52089f22fe 100644 --- a/spec/ruby/core/kernel/shared/require.rb +++ b/spec/ruby/core/kernel/shared/require.rb @@ -20,7 +20,7 @@ describe :kernel_require_basic, shared: true do it "raises a LoadError if the file does not exist" do path = File.expand_path "nonexistent.rb", CODE_LOADING_DIR - File.exist?(path).should be_false + File.should_not.exist?(path) -> { @object.send(@method, path) }.should raise_error(LoadError) ScratchPad.recorded.should == [] end @@ -41,7 +41,7 @@ describe :kernel_require_basic, shared: true do end it "raises a LoadError" do - File.exist?(@path).should be_true + File.should.exist?(@path) -> { @object.send(@method, @path) }.should raise_error(LoadError) end end @@ -247,7 +247,7 @@ describe :kernel_require, shared: true do describe "(file extensions)" do it "loads a .rb extensioned file when passed a non-extensioned path" do path = File.expand_path "load_fixture", CODE_LOADING_DIR - File.exist?(path).should be_true + File.should.exist?(path) @object.require(path).should be_true ScratchPad.recorded.should == [:loaded] end @@ -271,7 +271,7 @@ describe :kernel_require, shared: true do it "loads a .rb extensioned file when passed a non-.rb extensioned path" do path = File.expand_path "load_fixture.ext", CODE_LOADING_DIR - File.exist?(path).should be_true + File.should.exist?(path) @object.require(path).should be_true ScratchPad.recorded.should == [:loaded] end diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb index aa91114893..95eb9aa874 100644 --- a/spec/ruby/core/string/dump_spec.rb +++ b/spec/ruby/core/string/dump_spec.rb @@ -388,8 +388,8 @@ describe "String#dump" do end it "includes .force_encoding(name) if the encoding isn't ASCII compatible" do - "\u{876}".encode('utf-16be').dump.end_with?(".force_encoding(\"UTF-16BE\")").should be_true - "\u{876}".encode('utf-16le').dump.end_with?(".force_encoding(\"UTF-16LE\")").should be_true + "\u{876}".encode('utf-16be').dump.should.end_with?(".force_encoding(\"UTF-16BE\")") + "\u{876}".encode('utf-16le').dump.should.end_with?(".force_encoding(\"UTF-16LE\")") end it "keeps origin encoding" do diff --git a/spec/ruby/core/string/end_with_spec.rb b/spec/ruby/core/string/end_with_spec.rb index b7a04fdefe..9ced0ca3d2 100644 --- a/spec/ruby/core/string/end_with_spec.rb +++ b/spec/ruby/core/string/end_with_spec.rb @@ -5,33 +5,33 @@ require_relative 'fixtures/classes' describe "String#end_with?" do it "returns true only if ends match" do s = "hello" - s.end_with?('o').should be_true - s.end_with?('llo').should be_true + s.should.end_with?('o') + s.should.end_with?('llo') end it 'returns false if the end does not match' do s = 'hello' - s.end_with?('ll').should be_false + s.should_not.end_with?('ll') end it "returns true if the search string is empty" do - "hello".end_with?("").should be_true - "".end_with?("").should be_true + "hello".should.end_with?("") + "".should.end_with?("") end it "returns true only if any ending match" do - "hello".end_with?('x', 'y', 'llo', 'z').should be_true + "hello".should.end_with?('x', 'y', 'llo', 'z') end it "converts its argument using :to_str" do s = "hello" find = mock('o') find.should_receive(:to_str).and_return("o") - s.end_with?(find).should be_true + s.should.end_with?(find) end it "ignores arguments not convertible to string" do - "hello".end_with?().should be_false + "hello".should_not.end_with?() -> { "hello".end_with?(1) }.should raise_error(TypeError) -> { "hello".end_with?(["o"]) }.should raise_error(TypeError) -> { "hello".end_with?(1, nil, "o") }.should raise_error(TypeError) @@ -40,11 +40,11 @@ describe "String#end_with?" do it "uses only the needed arguments" do find = mock('h') find.should_not_receive(:to_str) - "hello".end_with?("o",find).should be_true + "hello".should.end_with?("o",find) end it "works for multibyte strings" do - "céréale".end_with?("réale").should be_true + "céréale".should.end_with?("réale") end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do @@ -53,5 +53,4 @@ describe "String#end_with?" do "あれ".end_with?(pat) end.should raise_error(Encoding::CompatibilityError) end - end diff --git a/spec/ruby/core/string/start_with_spec.rb b/spec/ruby/core/string/start_with_spec.rb index f66ec55266..1000db180c 100644 --- a/spec/ruby/core/string/start_with_spec.rb +++ b/spec/ruby/core/string/start_with_spec.rb @@ -5,29 +5,29 @@ require_relative 'fixtures/classes' describe "String#start_with?" do it "returns true only if beginning match" do s = "hello" - s.start_with?('h').should be_true - s.start_with?('hel').should be_true - s.start_with?('el').should be_false + s.should.start_with?('h') + s.should.start_with?('hel') + s.should_not.start_with?('el') end it "returns true only if any beginning match" do - "hello".start_with?('x', 'y', 'he', 'z').should be_true + "hello".should.start_with?('x', 'y', 'he', 'z') end it "returns true if the search string is empty" do - "hello".start_with?("").should be_true - "".start_with?("").should be_true + "hello".should.start_with?("") + "".should.start_with?("") end it "converts its argument using :to_str" do s = "hello" find = mock('h') find.should_receive(:to_str).and_return("h") - s.start_with?(find).should be_true + s.should.start_with?(find) end it "ignores arguments not convertible to string" do - "hello".start_with?().should be_false + "hello".should_not.start_with?() -> { "hello".start_with?(1) }.should raise_error(TypeError) -> { "hello".start_with?(["h"]) }.should raise_error(TypeError) -> { "hello".start_with?(1, nil, "h") }.should raise_error(TypeError) @@ -36,29 +36,29 @@ describe "String#start_with?" do it "uses only the needed arguments" do find = mock('h') find.should_not_receive(:to_str) - "hello".start_with?("h",find).should be_true + "hello".should.start_with?("h",find) end it "works for multibyte strings" do - "céréale".start_with?("cér").should be_true + "céréale".should.start_with?("cér") end ruby_version_is "2.5" do it "supports regexps" do regexp = /[h1]/ - "hello".start_with?(regexp).should be_true - "1337".start_with?(regexp).should be_true - "foxes are 1337".start_with?(regexp).should be_false - "chunky\n12bacon".start_with?(/12/).should be_false + "hello".should.start_with?(regexp) + "1337".should.start_with?(regexp) + "foxes are 1337".should_not.start_with?(regexp) + "chunky\n12bacon".should_not.start_with?(/12/) end it "supports regexps with ^ and $ modifiers" do regexp1 = /^\d{2}/ regexp2 = /\d{2}$/ - "12test".start_with?(regexp1).should be_true - "test12".start_with?(regexp1).should be_false - "12test".start_with?(regexp2).should be_false - "test12".start_with?(regexp2).should be_false + "12test".should.start_with?(regexp1) + "test12".should_not.start_with?(regexp1) + "12test".should_not.start_with?(regexp2) + "test12".should_not.start_with?(regexp2) end it "sets Regexp.last_match if it returns true" do -- cgit v1.2.3