mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@83063a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1e658d45e1
commit
3fa5bd38af
494 changed files with 4133 additions and 3109 deletions
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/eql.rb', __FILE__)
|
|||
|
||||
|
||||
describe "BigDecimal#===" do
|
||||
it_behaves_like(:bigdecimal_eql, :===)
|
||||
it_behaves_like :bigdecimal_eql, :===
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/eql.rb', __FILE__)
|
||||
|
||||
describe "BigDecimal#eql?" do
|
||||
it_behaves_like(:bigdecimal_eql, :eql?)
|
||||
it_behaves_like :bigdecimal_eql, :eql?
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/eql.rb', __FILE__)
|
|||
|
||||
|
||||
describe "BigDecimal#==" do
|
||||
it_behaves_like(:bigdecimal_eql, :==)
|
||||
it_behaves_like :bigdecimal_eql, :==
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/power', __FILE__)
|
|||
require 'bigdecimal'
|
||||
|
||||
describe "BigDecimal#**" do
|
||||
it_behaves_like(:bigdecimal_power, :**)
|
||||
it_behaves_like :bigdecimal_power, :**
|
||||
end
|
||||
|
||||
describe "BigDecimal#exponent" do
|
||||
|
|
|
@ -2,11 +2,11 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/modulo', __FILE__)
|
||||
|
||||
describe "BigDecimal#%" do
|
||||
it_behaves_like(:bigdecimal_modulo, :%)
|
||||
it_behaves_like(:bigdecimal_modulo_zerodivisionerror, :%)
|
||||
it_behaves_like :bigdecimal_modulo, :%
|
||||
it_behaves_like :bigdecimal_modulo_zerodivisionerror, :%
|
||||
end
|
||||
|
||||
describe "BigDecimal#modulo" do
|
||||
it_behaves_like(:bigdecimal_modulo, :modulo)
|
||||
it_behaves_like(:bigdecimal_modulo_zerodivisionerror, :modulo)
|
||||
it_behaves_like :bigdecimal_modulo, :modulo
|
||||
it_behaves_like :bigdecimal_modulo_zerodivisionerror, :modulo
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/power', __FILE__)
|
||||
|
||||
describe "BigDecimal#power" do
|
||||
it_behaves_like(:bigdecimal_power, :power)
|
||||
it_behaves_like :bigdecimal_power, :power
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/to_int', __FILE__)
|
|||
require 'bigdecimal'
|
||||
|
||||
describe "BigDecimal#to_i" do
|
||||
it_behaves_like(:bigdecimal_to_int, :to_i)
|
||||
it_behaves_like :bigdecimal_to_int, :to_i
|
||||
end
|
||||
|
|
|
@ -4,5 +4,5 @@ require 'bigdecimal'
|
|||
|
||||
|
||||
describe "BigDecimal#to_int" do
|
||||
it_behaves_like(:bigdecimal_to_int, :to_int)
|
||||
it_behaves_like :bigdecimal_to_int, :to_int
|
||||
end
|
||||
|
|
|
@ -4,5 +4,5 @@ require 'cgi'
|
|||
require File.expand_path('../shared/http_header', __FILE__)
|
||||
|
||||
describe "CGI#http_header" do
|
||||
it_behaves_like(:cgi_http_header, :http_header)
|
||||
it_behaves_like :cgi_http_header, :http_header
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/civil', __FILE__)
|
|||
require 'date'
|
||||
|
||||
describe "Date#civil" do
|
||||
it_behaves_like(:date_civil, :civil)
|
||||
it_behaves_like :date_civil, :civil
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ require File.expand_path('../shared/commercial', __FILE__)
|
|||
|
||||
describe "Date#commercial" do
|
||||
|
||||
it_behaves_like(:date_commercial, :commercial)
|
||||
it_behaves_like :date_commercial, :commercial
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -4,5 +4,5 @@ require File.expand_path('../shared/civil', __FILE__)
|
|||
require File.expand_path('../shared/new_bang', __FILE__)
|
||||
|
||||
describe "Date.new" do
|
||||
it_behaves_like(:date_civil, :new)
|
||||
it_behaves_like :date_civil, :new
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/constants', __FILE__)
|
|||
require File.expand_path('../shared/update', __FILE__)
|
||||
|
||||
describe "Digest::MD5#<<" do
|
||||
it_behaves_like(:md5_update, :<<)
|
||||
it_behaves_like :md5_update, :<<
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/constants', __FILE__)
|
|||
require File.expand_path('../shared/update', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#<<" do
|
||||
it_behaves_like(:sha256_update, :<<)
|
||||
it_behaves_like :sha256_update, :<<
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/constants', __FILE__)
|
|||
require File.expand_path('../shared/update', __FILE__)
|
||||
|
||||
describe "Digest::SHA384#<<" do
|
||||
it_behaves_like(:sha384_update, :<<)
|
||||
it_behaves_like :sha384_update, :<<
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/constants', __FILE__)
|
|||
require File.expand_path('../shared/update', __FILE__)
|
||||
|
||||
describe "Digest::SHA512#<<" do
|
||||
it_behaves_like(:sha512_update, :<<)
|
||||
it_behaves_like :sha512_update, :<<
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/windows', __FILE__)
|
|||
require 'etc'
|
||||
|
||||
describe "Etc.endgrent" do
|
||||
it_behaves_like(:etc_on_windows, :endgrent)
|
||||
it_behaves_like :etc_on_windows, :endgrent
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/windows', __FILE__)
|
|||
require 'etc'
|
||||
|
||||
describe "Etc.endpwent" do
|
||||
it_behaves_like(:etc_on_windows, :endpwent)
|
||||
it_behaves_like :etc_on_windows, :endpwent
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/windows', __FILE__)
|
|||
require 'etc'
|
||||
|
||||
describe "Etc.getgrent" do
|
||||
it_behaves_like(:etc_on_windows, :getgrent)
|
||||
it_behaves_like :etc_on_windows, :getgrent
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/windows', __FILE__)
|
|||
require 'etc'
|
||||
|
||||
describe "Etc.getpwent" do
|
||||
it_behaves_like(:etc_on_windows, :getpwent)
|
||||
it_behaves_like :etc_on_windows, :getpwent
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/windows', __FILE__)
|
|||
require 'etc'
|
||||
|
||||
describe "Etc.group" do
|
||||
it_behaves_like(:etc_on_windows, :group)
|
||||
it_behaves_like :etc_on_windows, :group
|
||||
|
||||
platform_is_not :windows do
|
||||
it "raises a RuntimeError for parallel iteration" do
|
||||
|
|
|
@ -47,5 +47,42 @@ with_feature :fiber_library do
|
|||
fiber = Fiber.new { fiber.resume }
|
||||
lambda { fiber.transfer }.should raise_error(FiberError)
|
||||
end
|
||||
|
||||
it "works if Fibers in different Threads each transfer to a Fiber in the same Thread" do
|
||||
# This catches a bug where Fibers are running on a thread-pool
|
||||
# and Fibers from a different Ruby Thread reuse the same native thread.
|
||||
# Caching the Ruby Thread based on the native thread is not correct in that case,
|
||||
# and the check for "fiber called across threads" in Fiber#transfer
|
||||
# might be incorrect based on that.
|
||||
2.times do
|
||||
Thread.new do
|
||||
io_fiber = Fiber.new do |calling_fiber|
|
||||
calling_fiber.transfer
|
||||
end
|
||||
io_fiber.transfer(Fiber.current)
|
||||
value = Object.new
|
||||
io_fiber.transfer(value).should equal value
|
||||
end.join
|
||||
end
|
||||
end
|
||||
|
||||
it "transfers control between a non-main thread's root fiber to a child fiber and back again" do
|
||||
states = []
|
||||
thread = Thread.new do
|
||||
f1 = Fiber.new do |f0|
|
||||
states << 0
|
||||
value2 = f0.transfer(1)
|
||||
states << value2
|
||||
3
|
||||
end
|
||||
|
||||
value1 = f1.transfer(Fiber.current)
|
||||
states << value1
|
||||
value3 = f1.transfer(2)
|
||||
states << value3
|
||||
end
|
||||
thread.join
|
||||
states.should == [0, 1, 2, 3]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require 'getoptlong'
|
|||
require File.expand_path('../shared/each', __FILE__)
|
||||
|
||||
describe "GetoptLong#each_option" do
|
||||
it_behaves_like(:getoptlong_each, :each_option)
|
||||
it_behaves_like :getoptlong_each, :each_option
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require 'getoptlong'
|
|||
require File.expand_path('../shared/each', __FILE__)
|
||||
|
||||
describe "GetoptLong#each" do
|
||||
it_behaves_like(:getoptlong_each, :each)
|
||||
it_behaves_like :getoptlong_each, :each
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require 'getoptlong'
|
|||
require File.expand_path('../shared/get', __FILE__)
|
||||
|
||||
describe "GetoptLong#get_option" do
|
||||
it_behaves_like(:getoptlong_get, :get_option)
|
||||
it_behaves_like :getoptlong_get, :get_option
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require 'getoptlong'
|
|||
require File.expand_path('../shared/get', __FILE__)
|
||||
|
||||
describe "GetoptLong#get" do
|
||||
it_behaves_like(:getoptlong_get, :get)
|
||||
it_behaves_like :getoptlong_get, :get
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/identity', __FILE__)
|
||||
|
||||
describe "Matrix.I" do
|
||||
it_behaves_like(:matrix_identity, :I)
|
||||
it_behaves_like :matrix_identity, :I
|
||||
end
|
||||
|
|
|
@ -1,35 +1,37 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require 'matrix'
|
||||
|
||||
describe "Matrix#antisymmetric?" do
|
||||
it "returns true for an antisymmetric Matrix" do
|
||||
Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should be_true
|
||||
end
|
||||
|
||||
it "returns true for a 0x0 empty matrix" do
|
||||
Matrix.empty.antisymmetric?.should be_true
|
||||
end
|
||||
|
||||
it "returns false for non-antisymmetric matrices" do
|
||||
[
|
||||
Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
|
||||
Matrix[[1, -2, 3], [2, 0, 6], [-3, -6, 0]], # wrong diagonal element
|
||||
Matrix[[0, 2, -3], [2, 0, 6], [-3, 6, 0]] # only signs wrong
|
||||
].each do |matrix|
|
||||
matrix.antisymmetric?.should be_false
|
||||
ruby_version_is "2.6" do
|
||||
describe "Matrix#antisymmetric?" do
|
||||
it "returns true for an antisymmetric Matrix" do
|
||||
Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
it "raises an error for rectangular matrices" do
|
||||
[
|
||||
Matrix[[0], [0]],
|
||||
Matrix[[0, 0]],
|
||||
Matrix.empty(0, 2),
|
||||
Matrix.empty(2, 0),
|
||||
].each do |rectangular_matrix|
|
||||
lambda {
|
||||
rectangular_matrix.antisymmetric?
|
||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||
it "returns true for a 0x0 empty matrix" do
|
||||
Matrix.empty.antisymmetric?.should be_true
|
||||
end
|
||||
|
||||
it "returns false for non-antisymmetric matrices" do
|
||||
[
|
||||
Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
|
||||
Matrix[[1, -2, 3], [2, 0, 6], [-3, -6, 0]], # wrong diagonal element
|
||||
Matrix[[0, 2, -3], [2, 0, 6], [-3, 6, 0]] # only signs wrong
|
||||
].each do |matrix|
|
||||
matrix.antisymmetric?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
it "raises an error for rectangular matrices" do
|
||||
[
|
||||
Matrix[[0], [0]],
|
||||
Matrix[[0, 0]],
|
||||
Matrix.empty(0, 2),
|
||||
Matrix.empty(2, 0),
|
||||
].each do |rectangular_matrix|
|
||||
lambda {
|
||||
rectangular_matrix.antisymmetric?
|
||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/collect', __FILE__)
|
||||
|
||||
describe "Matrix#collect" do
|
||||
it_behaves_like(:collect, :collect)
|
||||
it_behaves_like :collect, :collect
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/conjugate', __FILE__)
|
||||
|
||||
describe "Matrix#conj" do
|
||||
it_behaves_like(:matrix_conjugate, :conj)
|
||||
it_behaves_like :matrix_conjugate, :conj
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/conjugate', __FILE__)
|
||||
|
||||
describe "Matrix#conjugate" do
|
||||
it_behaves_like(:matrix_conjugate, :conjugate)
|
||||
it_behaves_like :matrix_conjugate, :conjugate
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/determinant', __FILE__)
|
|||
require 'matrix'
|
||||
|
||||
describe "Matrix#det" do
|
||||
it_behaves_like(:determinant, :det)
|
||||
it_behaves_like :determinant, :det
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/determinant', __FILE__)
|
|||
require 'matrix'
|
||||
|
||||
describe "Matrix#determinant" do
|
||||
it_behaves_like(:determinant, :determinant)
|
||||
it_behaves_like :determinant, :determinant
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/equal_value', __FILE__)
|
|||
require 'matrix'
|
||||
|
||||
describe "Matrix#eql?" do
|
||||
it_behaves_like(:equal, :eql?)
|
||||
it_behaves_like :equal, :eql?
|
||||
|
||||
it "returns false if some elements are == but not eql?" do
|
||||
Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should be_false
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/equal_value', __FILE__)
|
|||
require 'matrix'
|
||||
|
||||
describe "Matrix#==" do
|
||||
it_behaves_like(:equal, :==)
|
||||
it_behaves_like :equal, :==
|
||||
|
||||
it "returns true if some elements are == but not eql?" do
|
||||
Matrix[[1, 2],[3, 4]].should == Matrix[[1, 2],[3, 4.0]]
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/identity', __FILE__)
|
||||
|
||||
describe "Matrix.identity" do
|
||||
it_behaves_like(:matrix_identity, :identity)
|
||||
it_behaves_like :matrix_identity, :identity
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/imaginary', __FILE__)
|
||||
|
||||
describe "Matrix#imag" do
|
||||
it_behaves_like(:matrix_imaginary, :imag)
|
||||
it_behaves_like :matrix_imaginary, :imag
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/imaginary', __FILE__)
|
||||
|
||||
describe "Matrix#imaginary" do
|
||||
it_behaves_like(:matrix_imaginary, :imaginary)
|
||||
it_behaves_like :matrix_imaginary, :imaginary
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/inverse', __FILE__)
|
||||
|
||||
describe "Matrix#inv" do
|
||||
it_behaves_like(:inverse, :inv)
|
||||
it_behaves_like :inverse, :inv
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/inverse', __FILE__)
|
||||
|
||||
describe "Matrix#inverse" do
|
||||
it_behaves_like(:inverse, :inverse)
|
||||
it_behaves_like :inverse, :inverse
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/collect', __FILE__)
|
||||
|
||||
describe "Matrix#map" do
|
||||
it_behaves_like(:collect, :map)
|
||||
it_behaves_like :collect, :map
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/rectangular', __FILE__)
|
||||
|
||||
describe "Matrix#rect" do
|
||||
it_behaves_like(:matrix_rectangular, :rect)
|
||||
it_behaves_like :matrix_rectangular, :rect
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/rectangular', __FILE__)
|
||||
|
||||
describe "Matrix#rectangular" do
|
||||
it_behaves_like(:matrix_rectangular, :rectangular)
|
||||
it_behaves_like :matrix_rectangular, :rectangular
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/transpose', __FILE__)
|
||||
|
||||
describe "Matrix#transpose" do
|
||||
it_behaves_like(:matrix_transpose, :t)
|
||||
it_behaves_like :matrix_transpose, :t
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/trace', __FILE__)
|
|||
require 'matrix'
|
||||
|
||||
describe "Matrix#tr" do
|
||||
it_behaves_like(:trace, :tr)
|
||||
it_behaves_like :trace, :tr
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/trace', __FILE__)
|
|||
require 'matrix'
|
||||
|
||||
describe "Matrix#trace" do
|
||||
it_behaves_like(:trace, :trace)
|
||||
it_behaves_like :trace, :trace
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/transpose', __FILE__)
|
||||
|
||||
describe "Matrix#transpose" do
|
||||
it_behaves_like(:matrix_transpose, :transpose)
|
||||
it_behaves_like :matrix_transpose, :transpose
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/identity', __FILE__)
|
||||
|
||||
describe "Matrix.unit" do
|
||||
it_behaves_like(:matrix_identity, :unit)
|
||||
it_behaves_like :matrix_identity, :unit
|
||||
end
|
||||
|
|
|
@ -88,4 +88,322 @@ describe "Net::FTP#initialize" do
|
|||
@ftp.send(:initialize, "localhost", "rubyspec", "rocks", "account")
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is '2.4' do
|
||||
before :each do
|
||||
@ftp.stub!(:login)
|
||||
end
|
||||
|
||||
describe 'when the host' do
|
||||
describe 'is set' do
|
||||
describe 'and port option' do
|
||||
describe 'is set' do
|
||||
it 'tries to connect to the host on the specified port' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ port: 8080 })
|
||||
@ftp.should_receive(:connect).with('localhost', 8080)
|
||||
|
||||
@ftp.send(:initialize, 'localhost', options)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is not set' do
|
||||
it 'tries to connect to the host without a port' do
|
||||
@ftp.should_receive(:connect).with("localhost", *@port_args)
|
||||
|
||||
@ftp.send(:initialize, 'localhost')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the username option' do
|
||||
describe 'is set' do
|
||||
describe 'and the password option' do
|
||||
describe 'is set' do
|
||||
describe 'and the account option' do
|
||||
describe 'is set' do
|
||||
it 'tries to log in with the supplied parameters' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret', account: 'b' })
|
||||
@ftp.should_receive(:login).with('a', 'topsecret', 'b')
|
||||
|
||||
@ftp.send(:initialize, 'localhost', options)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is unset' do
|
||||
it 'tries to log in with the supplied parameters' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret' })
|
||||
@ftp.should_receive(:login).with('a', 'topsecret', nil)
|
||||
|
||||
@ftp.send(:initialize, 'localhost', options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is unset' do
|
||||
describe 'and the account option' do
|
||||
describe 'is set' do
|
||||
it 'tries to log in with the supplied parameters' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ username: 'a', account: 'b' })
|
||||
@ftp.should_receive(:login).with('a', nil, 'b')
|
||||
|
||||
@ftp.send(:initialize, 'localhost', options)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is unset' do
|
||||
it 'tries to log in with the supplied parameters' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ username: 'a'})
|
||||
@ftp.should_receive(:login).with('a', nil, nil)
|
||||
|
||||
@ftp.send(:initialize, 'localhost', options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is not set' do
|
||||
it 'does not try to log in' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({})
|
||||
@ftp.should_not_receive(:login)
|
||||
|
||||
@ftp.send(:initialize, 'localhost', options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is unset' do
|
||||
it 'does not try to connect' do
|
||||
@ftp.should_not_receive(:connect)
|
||||
|
||||
@ftp.send(:initialize)
|
||||
end
|
||||
|
||||
it 'does not try to log in' do
|
||||
@ftp.should_not_receive(:login)
|
||||
|
||||
@ftp.send(:initialize)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the passive option' do
|
||||
describe 'is set' do
|
||||
describe 'to true' do
|
||||
it 'sets passive to true' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ passive: true })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.passive.should == true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'to false' do
|
||||
it 'sets passive to false' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ passive: false })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.passive.should == false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is unset' do
|
||||
it 'sets passive to false' do
|
||||
@ftp.send(:initialize)
|
||||
@ftp.passive.should == false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the debug_mode option' do
|
||||
describe 'is set' do
|
||||
describe 'to true' do
|
||||
it 'sets debug_mode to true' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ debug_mode: true })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.debug_mode.should == true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'to false' do
|
||||
it 'sets debug_mode to false' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ debug_mode: false })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.debug_mode.should == false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is unset' do
|
||||
it 'sets debug_mode to false' do
|
||||
@ftp.send(:initialize)
|
||||
@ftp.debug_mode.should == false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the open_timeout option' do
|
||||
describe 'is set' do
|
||||
it 'sets open_timeout to the specified value' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ open_timeout: 42 })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.open_timeout.should == 42
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is not set' do
|
||||
it 'sets open_timeout to nil' do
|
||||
@ftp.send(:initialize)
|
||||
@ftp.open_timeout.should == nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the read_timeout option' do
|
||||
describe 'is set' do
|
||||
it 'sets read_timeout to the specified value' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ read_timeout: 100 })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.read_timeout.should == 100
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is not set' do
|
||||
it 'sets read_timeout to the default value' do
|
||||
@ftp.send(:initialize)
|
||||
@ftp.read_timeout.should == 60
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the ssl_handshake_timeout option' do
|
||||
describe 'is set' do
|
||||
it 'sets ssl_handshake_timeout to the specified value' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ ssl_handshake_timeout: 23 })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.ssl_handshake_timeout.should == 23
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is not set' do
|
||||
it 'sets ssl_handshake_timeout to nil' do
|
||||
@ftp.send(:initialize)
|
||||
@ftp.ssl_handshake_timeout.should == nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the ssl option' do
|
||||
describe 'is set' do
|
||||
describe "and the ssl option's value is true" do
|
||||
it 'initializes ssl_context to a blank SSLContext object' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ ssl: true })
|
||||
|
||||
ssl_context = OpenSSL::SSL::SSLContext.allocate
|
||||
ssl_context.stub!(:set_params)
|
||||
|
||||
OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context)
|
||||
ssl_context.should_receive(:set_params).with({})
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.instance_variable_get(:@ssl_context).should == ssl_context
|
||||
end
|
||||
end
|
||||
|
||||
describe "and the ssl option's value is a hash" do
|
||||
it 'initializes ssl_context to a configured SSLContext object' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ ssl: {key: 'value'} })
|
||||
|
||||
ssl_context = OpenSSL::SSL::SSLContext.allocate
|
||||
ssl_context.stub!(:set_params)
|
||||
|
||||
OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context)
|
||||
ssl_context.should_receive(:set_params).with({key: 'value'})
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.instance_variable_get(:@ssl_context).should == ssl_context
|
||||
end
|
||||
end
|
||||
|
||||
describe 'and private_data_connection' do
|
||||
describe 'is set' do
|
||||
it 'sets private_data_connection to that value' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ ssl: true, private_data_connection: 'true' })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.instance_variable_get(:@private_data_connection).should == 'true'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is not set' do
|
||||
it 'sets private_data_connection to nil' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ ssl: true })
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.instance_variable_get(:@private_data_connection).should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is not set' do
|
||||
it 'sets ssl_context to nil' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({})
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.instance_variable_get(:@ssl_context).should == nil
|
||||
end
|
||||
|
||||
describe 'private_data_connection' do
|
||||
describe 'is set' do
|
||||
it 'raises an ArgumentError' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({ private_data_connection: true })
|
||||
|
||||
-> {
|
||||
@ftp.send(:initialize, nil, options)
|
||||
}.should raise_error(ArgumentError, /private_data_connection can be set to true only when ssl is enabled/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'is not set' do
|
||||
it 'sets private_data_connection to false' do
|
||||
options = mock('ftp initialize options')
|
||||
options.should_receive(:to_hash).and_return({})
|
||||
|
||||
@ftp.send(:initialize, nil, options)
|
||||
@ftp.instance_variable_get(:@private_data_connection).should == false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,9 +49,9 @@ describe :rexml_document_add, shared: true do
|
|||
end
|
||||
|
||||
describe "REXML::Document#add" do
|
||||
it_behaves_like(:rexml_document_add, :add)
|
||||
it_behaves_like :rexml_document_add, :add
|
||||
end
|
||||
|
||||
describe "REXML::Document#<<" do
|
||||
it_behaves_like(:rexml_document_add, :<<)
|
||||
it_behaves_like :rexml_document_add, :<<
|
||||
end
|
||||
|
|
|
@ -8,9 +8,9 @@ describe :document_expanded_name, shared: true do
|
|||
end
|
||||
|
||||
describe "REXML::Document#expanded_name" do
|
||||
it_behaves_like(:document_expanded_name, :expanded_name)
|
||||
it_behaves_like :document_expanded_name, :expanded_name
|
||||
end
|
||||
|
||||
describe "REXML::Document#name" do
|
||||
it_behaves_like(:document_expanded_name, :name)
|
||||
it_behaves_like :document_expanded_name, :name
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/block_scanf.rb', __FILE__)
|
|||
require 'scanf'
|
||||
|
||||
describe "IO#block_scanf" do
|
||||
it_behaves_like(:scanf_io_block_scanf, :block_scanf)
|
||||
it_behaves_like :scanf_io_block_scanf, :block_scanf
|
||||
end
|
||||
|
|
|
@ -31,5 +31,5 @@ describe "IO#scanf" do
|
|||
end
|
||||
|
||||
describe "IO#scanf with block" do
|
||||
it_behaves_like(:scanf_io_block_scanf, :scanf)
|
||||
it_behaves_like :scanf_io_block_scanf, :scanf
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/block_scanf.rb', __FILE__)
|
|||
require 'scanf'
|
||||
|
||||
describe "String#block_scanf" do
|
||||
it_behaves_like(:scanf_string_block_scanf, :block_scanf)
|
||||
it_behaves_like :scanf_string_block_scanf, :block_scanf
|
||||
end
|
||||
|
|
|
@ -49,5 +49,5 @@ describe "String#scanf" do
|
|||
end
|
||||
|
||||
describe "String#scanf with block" do
|
||||
it_behaves_like(:scanf_string_block_scanf, :scanf)
|
||||
it_behaves_like :scanf_string_block_scanf, :scanf
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/to_sockaddr', __FILE__)
|
|||
require 'socket'
|
||||
|
||||
describe "Addrinfo#to_s" do
|
||||
it_behaves_like(:socket_addrinfo_to_sockaddr, :to_s)
|
||||
it_behaves_like :socket_addrinfo_to_sockaddr, :to_s
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/to_sockaddr', __FILE__)
|
|||
require 'socket'
|
||||
|
||||
describe "Addrinfo#to_sockaddr" do
|
||||
it_behaves_like(:socket_addrinfo_to_sockaddr, :to_sockaddr)
|
||||
it_behaves_like :socket_addrinfo_to_sockaddr, :to_sockaddr
|
||||
end
|
||||
|
|
|
@ -5,5 +5,5 @@ require File.expand_path('../shared/codepoints', __FILE__)
|
|||
|
||||
# See redmine #1667
|
||||
describe "StringIO#codepoints" do
|
||||
it_behaves_like(:stringio_codepoints, :codepoints)
|
||||
it_behaves_like :stringio_codepoints, :codepoints
|
||||
end
|
||||
|
|
|
@ -5,6 +5,6 @@ require File.expand_path('../shared/codepoints', __FILE__)
|
|||
|
||||
# See redmine #1667
|
||||
describe "StringIO#each_codepoint" do
|
||||
it_behaves_like(:stringio_codepoints, :codepoints)
|
||||
it_behaves_like :stringio_codepoints, :codepoints
|
||||
end
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/bol.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#beginning_of_line?" do
|
||||
it_behaves_like(:strscan_bol, :beginning_of_line?)
|
||||
it_behaves_like :strscan_bol, :beginning_of_line?
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/bol.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#bol?" do
|
||||
it_behaves_like(:strscan_bol, :bol?)
|
||||
it_behaves_like :strscan_bol, :bol?
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/terminate.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#clear" do
|
||||
it_behaves_like(:strscan_terminate, :clear)
|
||||
it_behaves_like :strscan_terminate, :clear
|
||||
|
||||
it "warns in verbose mode that the method is obsolete" do
|
||||
s = StringScanner.new("abc")
|
||||
|
|
|
@ -3,9 +3,9 @@ require File.expand_path('../shared/concat.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#concat" do
|
||||
it_behaves_like(:strscan_concat, :concat)
|
||||
it_behaves_like :strscan_concat, :concat
|
||||
end
|
||||
|
||||
describe "StringScanner#concat when passed a Fixnum" do
|
||||
it_behaves_like(:strscan_concat_fixnum, :concat)
|
||||
it_behaves_like :strscan_concat_fixnum, :concat
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/eos.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#empty?" do
|
||||
it_behaves_like(:strscan_eos, :empty?)
|
||||
it_behaves_like :strscan_eos, :empty?
|
||||
|
||||
it "warns in verbose mode that the method is obsolete" do
|
||||
s = StringScanner.new("abc")
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/eos.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#eos?" do
|
||||
it_behaves_like(:strscan_eos, :eos?)
|
||||
it_behaves_like :strscan_eos, :eos?
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/matched_size.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#matched_size" do
|
||||
it_behaves_like(:strscan_matched_size, :matched_size)
|
||||
it_behaves_like :strscan_matched_size, :matched_size
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@ require File.expand_path('../shared/peek.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#peek" do
|
||||
it_behaves_like(:strscan_peek, :peek)
|
||||
it_behaves_like :strscan_peek, :peek
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/peek.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#peep" do
|
||||
it_behaves_like(:strscan_peek, :peep)
|
||||
it_behaves_like :strscan_peek, :peep
|
||||
|
||||
it "warns in verbose mode that the method is obsolete" do
|
||||
s = StringScanner.new("abc")
|
||||
|
|
|
@ -3,9 +3,9 @@ require File.expand_path('../shared/pos.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#pointer" do
|
||||
it_behaves_like(:strscan_pos, :pointer)
|
||||
it_behaves_like :strscan_pos, :pointer
|
||||
end
|
||||
|
||||
describe "StringScanner#pointer=" do
|
||||
it_behaves_like(:strscan_pos_set, :pointer=)
|
||||
it_behaves_like :strscan_pos_set, :pointer=
|
||||
end
|
||||
|
|
|
@ -3,9 +3,9 @@ require File.expand_path('../shared/pos.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#pos" do
|
||||
it_behaves_like(:strscan_pos, :pos)
|
||||
it_behaves_like :strscan_pos, :pos
|
||||
end
|
||||
|
||||
describe "StringScanner#pos=" do
|
||||
it_behaves_like(:strscan_pos_set, :pos=)
|
||||
it_behaves_like :strscan_pos_set, :pos=
|
||||
end
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/rest_size.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#rest_size" do
|
||||
it_behaves_like(:strscan_rest_size, :rest_size)
|
||||
it_behaves_like :strscan_rest_size, :rest_size
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path('../shared/rest_size.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#restsize" do
|
||||
it_behaves_like(:strscan_rest_size, :restsize)
|
||||
it_behaves_like :strscan_rest_size, :restsize
|
||||
|
||||
it "warns in verbose mode that the method is obsolete" do
|
||||
s = StringScanner.new("abc")
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../shared/terminate.rb', __FILE__)
|
|||
require 'strscan'
|
||||
|
||||
describe "StringScanner#terminate" do
|
||||
it_behaves_like(:strscan_terminate, :terminate)
|
||||
it_behaves_like :strscan_terminate, :terminate
|
||||
end
|
||||
|
|
|
@ -15,7 +15,8 @@ class WeakRefSpec
|
|||
weak = nil
|
||||
10_000.times do
|
||||
weaks << make_weakref
|
||||
10.times { GC.start }
|
||||
GC.start
|
||||
GC.start
|
||||
break if weak = weaks.find { |w| !w.weakref_alive? }
|
||||
end
|
||||
weak
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue