diff options
Diffstat (limited to 'spec/ruby/core/argf/shared')
| -rw-r--r-- | spec/ruby/core/argf/shared/each_byte.rb | 58 | ||||
| -rw-r--r-- | spec/ruby/core/argf/shared/each_char.rb | 58 | ||||
| -rw-r--r-- | spec/ruby/core/argf/shared/each_codepoint.rb | 58 | ||||
| -rw-r--r-- | spec/ruby/core/argf/shared/each_line.rb | 62 | ||||
| -rw-r--r-- | spec/ruby/core/argf/shared/eof.rb | 24 | ||||
| -rw-r--r-- | spec/ruby/core/argf/shared/filename.rb | 28 | ||||
| -rw-r--r-- | spec/ruby/core/argf/shared/fileno.rb | 24 | ||||
| -rw-r--r-- | spec/ruby/core/argf/shared/pos.rb | 31 | ||||
| -rw-r--r-- | spec/ruby/core/argf/shared/readlines.rb | 22 |
9 files changed, 0 insertions, 365 deletions
diff --git a/spec/ruby/core/argf/shared/each_byte.rb b/spec/ruby/core/argf/shared/each_byte.rb deleted file mode 100644 index 6b1dc1dae2..0000000000 --- a/spec/ruby/core/argf/shared/each_byte.rb +++ /dev/null @@ -1,58 +0,0 @@ -describe :argf_each_byte, shared: true do - before :each do - @file1_name = fixture __FILE__, "file1.txt" - @file2_name = fixture __FILE__, "file2.txt" - - @bytes = [] - File.read(@file1_name).each_byte { |b| @bytes << b } - File.read(@file2_name).each_byte { |b| @bytes << b } - end - - it "yields each byte of all streams to the passed block" do - argf [@file1_name, @file2_name] do - bytes = [] - @argf.send(@method) { |b| bytes << b } - bytes.should == @bytes - end - end - - it "returns self when passed a block" do - argf [@file1_name, @file2_name] do - @argf.send(@method) {}.should equal(@argf) - end - end - - it "returns an Enumerator when passed no block" do - argf [@file1_name, @file2_name] do - enum = @argf.send(@method) - enum.should be_an_instance_of(Enumerator) - - bytes = [] - enum.each { |b| bytes << b } - bytes.should == @bytes - end - end - - describe "when no block is given" do - it "returns an Enumerator" do - argf [@file1_name, @file2_name] do - enum = @argf.send(@method) - enum.should be_an_instance_of(Enumerator) - - bytes = [] - enum.each { |b| bytes << b } - bytes.should == @bytes - end - end - - describe "returned Enumerator" do - describe "size" do - it "should return nil" do - argf [@file1_name, @file2_name] do - @argf.send(@method).size.should == nil - end - end - end - end - end -end diff --git a/spec/ruby/core/argf/shared/each_char.rb b/spec/ruby/core/argf/shared/each_char.rb deleted file mode 100644 index 9e333ecc5b..0000000000 --- a/spec/ruby/core/argf/shared/each_char.rb +++ /dev/null @@ -1,58 +0,0 @@ -describe :argf_each_char, shared: true do - before :each do - @file1_name = fixture __FILE__, "file1.txt" - @file2_name = fixture __FILE__, "file2.txt" - - @chars = [] - File.read(@file1_name).each_char { |c| @chars << c } - File.read(@file2_name).each_char { |c| @chars << c } - end - - it "yields each char of all streams to the passed block" do - argf [@file1_name, @file2_name] do - chars = [] - @argf.send(@method) { |c| chars << c } - chars.should == @chars - end - end - - it "returns self when passed a block" do - argf [@file1_name, @file2_name] do - @argf.send(@method) {}.should equal(@argf) - end - end - - it "returns an Enumerator when passed no block" do - argf [@file1_name, @file2_name] do - enum = @argf.send(@method) - enum.should be_an_instance_of(Enumerator) - - chars = [] - enum.each { |c| chars << c } - chars.should == @chars - end - end - - describe "when no block is given" do - it "returns an Enumerator" do - argf [@file1_name, @file2_name] do - enum = @argf.send(@method) - enum.should be_an_instance_of(Enumerator) - - chars = [] - enum.each { |c| chars << c } - chars.should == @chars - end - end - - describe "returned Enumerator" do - describe "size" do - it "should return nil" do - argf [@file1_name, @file2_name] do - @argf.send(@method).size.should == nil - end - end - end - end - end -end diff --git a/spec/ruby/core/argf/shared/each_codepoint.rb b/spec/ruby/core/argf/shared/each_codepoint.rb deleted file mode 100644 index e2a2dfff46..0000000000 --- a/spec/ruby/core/argf/shared/each_codepoint.rb +++ /dev/null @@ -1,58 +0,0 @@ -describe :argf_each_codepoint, shared: true do - before :each do - file1_name = fixture __FILE__, "file1.txt" - file2_name = fixture __FILE__, "file2.txt" - @filenames = [file1_name, file2_name] - - @codepoints = File.read(file1_name).codepoints - @codepoints.concat File.read(file2_name).codepoints - end - - it "is a public method" do - argf @filenames do - @argf.public_methods(false).should include(@method) - end - end - - it "does not require arguments" do - argf @filenames do - @argf.method(@method).arity.should == 0 - end - end - - it "returns self when passed a block" do - argf @filenames do - @argf.send(@method) {}.should equal(@argf) - end - end - - it "returns an Enumerator when passed no block" do - argf @filenames do - @argf.send(@method).should be_an_instance_of(Enumerator) - end - end - - it "yields each codepoint of all streams" do - argf @filenames do - @argf.send(@method).to_a.should == @codepoints - end - end - - describe "when no block is given" do - it "returns an Enumerator" do - argf @filenames do - @argf.send(@method).should be_an_instance_of(Enumerator) - end - end - - describe "returned Enumerator" do - describe "size" do - it "should return nil" do - argf @filenames do - @argf.send(@method).size.should == nil - end - end - end - end - end -end diff --git a/spec/ruby/core/argf/shared/each_line.rb b/spec/ruby/core/argf/shared/each_line.rb deleted file mode 100644 index c0ef77dc54..0000000000 --- a/spec/ruby/core/argf/shared/each_line.rb +++ /dev/null @@ -1,62 +0,0 @@ -describe :argf_each_line, shared: true do - before :each do - @file1_name = fixture __FILE__, "file1.txt" - @file2_name = fixture __FILE__, "file2.txt" - - @lines = File.readlines @file1_name - @lines += File.readlines @file2_name - end - - it "is a public method" do - argf [@file1_name, @file2_name] do - @argf.public_methods(false).should include(@method) - end - end - - it "requires multiple arguments" do - argf [@file1_name, @file2_name] do - @argf.method(@method).arity.should < 0 - end - end - - it "reads each line of files" do - argf [@file1_name, @file2_name] do - lines = [] - @argf.send(@method) { |b| lines << b } - lines.should == @lines - end - end - - it "returns self when passed a block" do - argf [@file1_name, @file2_name] do - @argf.send(@method) {}.should equal(@argf) - end - end - - describe "with a separator" do - it "yields each separated section of all streams" do - argf [@file1_name, @file2_name] do - @argf.send(@method, '.').to_a.should == - (File.readlines(@file1_name, '.') + File.readlines(@file2_name, '.')) - end - end - end - - describe "when no block is given" do - it "returns an Enumerator" do - argf [@file1_name, @file2_name] do - @argf.send(@method).should be_an_instance_of(Enumerator) - end - end - - describe "returned Enumerator" do - describe "size" do - it "should return nil" do - argf [@file1_name, @file2_name] do - @argf.send(@method).size.should == nil - end - end - end - end - end -end diff --git a/spec/ruby/core/argf/shared/eof.rb b/spec/ruby/core/argf/shared/eof.rb deleted file mode 100644 index 0e684f943f..0000000000 --- a/spec/ruby/core/argf/shared/eof.rb +++ /dev/null @@ -1,24 +0,0 @@ -describe :argf_eof, shared: true do - before :each do - @file1 = fixture __FILE__, "file1.txt" - @file2 = fixture __FILE__, "file2.txt" - end - - # NOTE: this test assumes that fixtures files have two lines each - it "returns true when reaching the end of a file" do - argf [@file1, @file2] do - result = [] - while @argf.gets - result << @argf.send(@method) - end - result.should == [false, true, false, true] - end - end - - it "raises IOError when called on a closed stream" do - argf [@file1] do - @argf.read - -> { @argf.send(@method) }.should raise_error(IOError) - end - end -end diff --git a/spec/ruby/core/argf/shared/filename.rb b/spec/ruby/core/argf/shared/filename.rb deleted file mode 100644 index f47c673dc0..0000000000 --- a/spec/ruby/core/argf/shared/filename.rb +++ /dev/null @@ -1,28 +0,0 @@ -describe :argf_filename, shared: true do - before :each do - @file1 = fixture __FILE__, "file1.txt" - @file2 = fixture __FILE__, "file2.txt" - end - - # NOTE: this test assumes that fixtures files have two lines each - it "returns the current file name on each file" do - argf [@file1, @file2] do - result = [] - # returns first current file even when not yet open - result << @argf.send(@method) - result << @argf.send(@method) while @argf.gets - # returns last current file even when closed - result << @argf.send(@method) - - result.map! { |f| File.expand_path(f) } - result.should == [@file1, @file1, @file1, @file2, @file2, @file2] - end - end - - # NOTE: this test assumes that fixtures files have two lines each - it "sets the $FILENAME global variable with the current file name on each file" do - script = fixture __FILE__, "filename.rb" - out = ruby_exe(script, args: [@file1, @file2]) - out.should == "#{@file1}\n#{@file1}\n#{@file2}\n#{@file2}\n#{@file2}\n" - end -end diff --git a/spec/ruby/core/argf/shared/fileno.rb b/spec/ruby/core/argf/shared/fileno.rb deleted file mode 100644 index 4350d43747..0000000000 --- a/spec/ruby/core/argf/shared/fileno.rb +++ /dev/null @@ -1,24 +0,0 @@ -describe :argf_fileno, shared: true do - before :each do - @file1 = fixture __FILE__, "file1.txt" - @file2 = fixture __FILE__, "file2.txt" - end - - # NOTE: this test assumes that fixtures files have two lines each - it "returns the current file number on each file" do - argf [@file1, @file2] do - result = [] - # returns first current file even when not yet open - result << @argf.send(@method) while @argf.gets - # returns last current file even when closed - result.map { |d| d.class }.should == [Integer, Integer, Integer, Integer] - end - end - - it "raises an ArgumentError when called on a closed stream" do - argf [@file1] do - @argf.read - -> { @argf.send(@method) }.should raise_error(ArgumentError) - end - end -end diff --git a/spec/ruby/core/argf/shared/pos.rb b/spec/ruby/core/argf/shared/pos.rb deleted file mode 100644 index 9836d5f1e4..0000000000 --- a/spec/ruby/core/argf/shared/pos.rb +++ /dev/null @@ -1,31 +0,0 @@ -describe :argf_pos, shared: true do - before :each do - @file1 = fixture __FILE__, "file1.txt" - @file2 = fixture __FILE__, "file2.txt" - end - - it "gives the correct position for each read operation" do - argf [@file1, @file2] do - size1 = File.size(@file1) - size2 = File.size(@file2) - - @argf.read(2) - @argf.send(@method).should == 2 - @argf.read(size1-2) - @argf.send(@method).should == size1 - @argf.read(6) - @argf.send(@method).should == 6 - @argf.rewind - @argf.send(@method).should == 0 - @argf.read(size2) - @argf.send(@method).should == size2 - end - end - - it "raises an ArgumentError when called on a closed stream" do - argf [@file1] do - @argf.read - -> { @argf.send(@method) }.should raise_error(ArgumentError) - end - end -end diff --git a/spec/ruby/core/argf/shared/readlines.rb b/spec/ruby/core/argf/shared/readlines.rb deleted file mode 100644 index 505fa94acb..0000000000 --- a/spec/ruby/core/argf/shared/readlines.rb +++ /dev/null @@ -1,22 +0,0 @@ -describe :argf_readlines, shared: true do - before :each do - @file1 = fixture __FILE__, "file1.txt" - @file2 = fixture __FILE__, "file2.txt" - - @lines = File.readlines(@file1) - @lines += File.readlines(@file2) - end - - it "reads all lines of all files" do - argf [@file1, @file2] do - @argf.send(@method).should == @lines - end - end - - it "returns an empty Array when end of stream reached" do - argf [@file1, @file2] do - @argf.read - @argf.send(@method).should == [] - end - end -end |
