1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Move spec/rubyspec to spec/ruby for consistency

* Other ruby implementations use the spec/ruby directory.
  [Misc #13792] [ruby-core:82287]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-09-20 20:18:52 +00:00
parent 75bfc6440d
commit 1d15d5f080
4370 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,21 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#_close" do
before :each do
@tempfile = Tempfile.new("specs")
end
after :each do
@tempfile.close!
end
it "is protected" do
Tempfile.should have_protected_instance_method(:_close)
end
it "closes self" do
@tempfile.send(:_close)
@tempfile.closed?.should be_true
end
end

View file

@ -0,0 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile.callback" do
it "needs to be reviewed for spec completeness"
end

View file

@ -0,0 +1,57 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#close when passed no argument or [false]" do
before :each do
@tempfile = Tempfile.new("specs", tmp(""))
end
after :each do
@tempfile.close!
end
it "closes self" do
@tempfile.close
@tempfile.closed?.should be_true
end
it "does not unlink self" do
path = @tempfile.path
@tempfile.close
File.exist?(path).should be_true
end
end
describe "Tempfile#close when passed [true]" do
before :each do
@tempfile = Tempfile.new("specs", tmp(""))
end
it "closes self" do
@tempfile.close(true)
@tempfile.closed?.should be_true
end
it "unlinks self" do
path = @tempfile.path
@tempfile.close(true)
File.exist?(path).should be_false
end
end
describe "Tempfile#close!" do
before :each do
@tempfile = Tempfile.new("specs", tmp(""))
end
it "closes self" do
@tempfile.close!
@tempfile.closed?.should be_true
end
it "unlinks self" do
path = @tempfile.path
@tempfile.close!
File.exist?(path).should be_false
end
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/unlink', __FILE__)
require 'tempfile'
describe "Tempfile#delete" do
it_behaves_like :tempfile_unlink, :delete
end

View file

@ -0,0 +1,41 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#initialize" do
before :each do
@tempfile = Tempfile.allocate
end
after :each do
@tempfile.close!
end
it "opens a new tempfile with the passed name in the passed directory" do
@tempfile.send(:initialize, "basename", tmp(""))
File.exist?(@tempfile.path).should be_true
tmpdir = tmp("")
path = @tempfile.path
platform_is :windows do
# on Windows, both types of slashes are OK,
# but the tmp helper always uses '/'
path.gsub!('\\', '/')
end
path[0, tmpdir.length].should == tmpdir
path.should include("basename")
end
platform_is_not :windows do
it "sets the permisssions on the tempfile to 0600" do
@tempfile.send(:initialize, "basename", tmp(""))
File.stat(@tempfile.path).mode.should == 0100600
end
end
it "accepts encoding options" do
@tempfile.send(:initialize, ['shiftjis', 'yml'], encoding: 'SHIFT_JIS')
@tempfile.external_encoding.should == Encoding::Shift_JIS
end
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/length', __FILE__)
require 'tempfile'
describe "Tempfile#length" do
it_behaves_like :tempfile_length, :length
end

View file

@ -0,0 +1,82 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#open" do
before :each do
@tempfile = Tempfile.new("specs")
@tempfile.puts("Test!")
end
after :each do
@tempfile.close!
end
it "reopens self" do
@tempfile.close
@tempfile.open
@tempfile.closed?.should be_false
end
it "reopens self in read and write mode and does not truncate" do
@tempfile.open
@tempfile.puts("Another Test!")
@tempfile.open
@tempfile.readline.should == "Another Test!\n"
end
end
describe "Tempfile.open" do
after :each do
@tempfile.close! if @tempfile
end
it "returns a new, open Tempfile instance" do
@tempfile = Tempfile.open("specs")
# Delegation messes up .should be_an_instance_of(Tempfile)
@tempfile.instance_of?(Tempfile).should be_true
end
it "is passed an array [base, suffix] as first argument" do
Tempfile.open(["specs", ".tt"]) { |tempfile| @tempfile = tempfile }
@tempfile.path.should =~ /specs.*\.tt$/
end
end
describe "Tempfile.open when passed a block" do
before :each do
ScratchPad.clear
end
after :each do
# Tempfile.open with block does not unlink
@tempfile.close! if @tempfile
end
it "yields a new, open Tempfile instance to the block" do
Tempfile.open("specs") do |tempfile|
@tempfile = tempfile
ScratchPad.record :yielded
# Delegation messes up .should be_an_instance_of(Tempfile)
tempfile.instance_of?(Tempfile).should be_true
tempfile.closed?.should be_false
end
ScratchPad.recorded.should == :yielded
end
it "returns the value of the block" do
value = Tempfile.open("specs") do |tempfile|
@tempfile = tempfile
"return"
end
value.should == "return"
end
it "closes the yielded Tempfile after the block" do
Tempfile.open("specs") { |tempfile| @tempfile = tempfile }
@tempfile.closed?.should be_true
end
end

View file

@ -0,0 +1,26 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#path" do
before :each do
@tempfile = Tempfile.new("specs", tmp(""))
end
after :each do
@tempfile.close!
end
it "returns the path to the tempfile" do
tmpdir = tmp("")
path = @tempfile.path
platform_is :windows do
# on Windows, both types of slashes are OK,
# but the tmp helper always uses '/'
path.gsub!('\\', '/')
end
path[0, tmpdir.length].should == tmpdir
path.should include("specs")
end
end

View file

@ -0,0 +1,21 @@
describe :tempfile_length, shared: true do
before :each do
@tempfile = Tempfile.new("specs")
end
after :each do
@tempfile.close!
end
it "returns the size of self" do
@tempfile.send(@method).should eql(0)
@tempfile.print("Test!")
@tempfile.send(@method).should eql(5)
end
it "returns the size of self even if self is closed" do
@tempfile.print("Test!")
@tempfile.close
@tempfile.send(@method).should eql(5)
end
end

View file

@ -0,0 +1,12 @@
describe :tempfile_unlink, shared: true do
before :each do
@tempfile = Tempfile.new("specs")
end
it "unlinks self" do
@tempfile.close
path = @tempfile.path
@tempfile.send(@method)
File.exist?(path).should be_false
end
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/length', __FILE__)
require 'tempfile'
describe "Tempfile#size" do
it_behaves_like :tempfile_length, :size
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/unlink', __FILE__)
require 'tempfile'
describe "Tempfile#unlink" do
it_behaves_like :tempfile_unlink, :unlink
end