summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/enumerator_spec.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-27 12:30:05 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-27 12:30:05 +0000
commit9dc121cc577ae7a010bca7efedb79088e3cf7331 (patch)
treec11a153c7eac91a1e19ed058d5c28f0f7d583622 /spec/ruby/optional/capi/enumerator_spec.rb
parentfc1f3f14d386b557281ff9a8f19da060befe182e (diff)
Update to ruby/spec@a454137
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/optional/capi/enumerator_spec.rb')
-rw-r--r--spec/ruby/optional/capi/enumerator_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/enumerator_spec.rb b/spec/ruby/optional/capi/enumerator_spec.rb
index 42510c122d..9ed68c9063 100644
--- a/spec/ruby/optional/capi/enumerator_spec.rb
+++ b/spec/ruby/optional/capi/enumerator_spec.rb
@@ -36,4 +36,31 @@ describe "C-API Enumerator function" do
enumerator.each {}
end
end
+
+ describe "rb_enumeratorize_with_size" do
+
+ it "enumerates the given object" do
+ enumerator = @s.rb_enumeratorize_with_size(@enumerable, :each)
+ enumerated = []
+ enumerator.each { |i| enumerated << i }
+ enumerated.should == @enumerable
+ end
+
+ it "uses the given method for enumeration" do
+ enumerator = @s.rb_enumeratorize_with_size(@enumerable, :awesome_each)
+ @enumerable.should_receive(:awesome_each)
+ enumerator.each {}
+ end
+
+ it "passes the given arguments to the enumeration method" do
+ enumerator = @s.rb_enumeratorize_with_size(@enumerable, :each, :arg1, :arg2)
+ @enumerable.should_receive(:each).with(:arg1, :arg2)
+ enumerator.each {}
+ end
+
+ it "uses the size function to report the size" do
+ enumerator = @s.rb_enumeratorize_with_size(@enumerable, :each, :arg1, :arg2)
+ enumerator.size.should == 7
+ end
+ end
end