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:
parent
75bfc6440d
commit
1d15d5f080
4370 changed files with 0 additions and 0 deletions
35
spec/ruby/core/enumerator/yielder/append_spec.rb
Normal file
35
spec/ruby/core/enumerator/yielder/append_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
|
||||
describe "Enumerator::Yielder#<<" do
|
||||
# TODO: There's some common behavior between yield and <<; move to a shared spec
|
||||
it "yields the value to the block" do
|
||||
ary = []
|
||||
y = Enumerator::Yielder.new {|x| ary << x}
|
||||
y << 1
|
||||
|
||||
ary.should == [1]
|
||||
end
|
||||
|
||||
it "doesn't double-wrap Arrays" do
|
||||
yields = []
|
||||
y = Enumerator::Yielder.new {|args| yields << args }
|
||||
y << [1]
|
||||
yields.should == [[1]]
|
||||
end
|
||||
|
||||
it "returns self" do
|
||||
y = Enumerator::Yielder.new {|x| x + 1}
|
||||
(y << 1).should equal(y)
|
||||
end
|
||||
|
||||
it "requires multiple arguments" do
|
||||
Enumerator::Yielder.instance_method(:<<).arity.should < 0
|
||||
end
|
||||
|
||||
it "yields with passed arguments" do
|
||||
yields = []
|
||||
y = Enumerator::Yielder.new {|*args| yields << args }
|
||||
y.<<(1, 2)
|
||||
yields.should == [[1, 2]]
|
||||
end
|
||||
end
|
18
spec/ruby/core/enumerator/yielder/initialize_spec.rb
Normal file
18
spec/ruby/core/enumerator/yielder/initialize_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# -*- encoding: us-ascii -*-
|
||||
|
||||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
|
||||
describe "Enumerator::Yielder#initialize" do
|
||||
before :each do
|
||||
@class = Enumerator::Yielder
|
||||
@uninitialized = @class.allocate
|
||||
end
|
||||
|
||||
it "is a private method" do
|
||||
@class.should have_private_instance_method(:initialize, false)
|
||||
end
|
||||
|
||||
it "returns self when given a block" do
|
||||
@uninitialized.send(:initialize) {}.should equal(@uninitialized)
|
||||
end
|
||||
end
|
16
spec/ruby/core/enumerator/yielder/yield_spec.rb
Normal file
16
spec/ruby/core/enumerator/yielder/yield_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
|
||||
describe "Enumerator::Yielder#yield" do
|
||||
it "yields the value to the block" do
|
||||
ary = []
|
||||
y = Enumerator::Yielder.new {|x| ary << x}
|
||||
y.yield 1
|
||||
|
||||
ary.should == [1]
|
||||
end
|
||||
|
||||
it "returns the result of the block for the given value" do
|
||||
y = Enumerator::Yielder.new {|x| x + 1}
|
||||
y.yield(1).should == 2
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue