diff options
Diffstat (limited to 'spec/ruby/core/numeric/shared')
-rw-r--r-- | spec/ruby/core/numeric/shared/step.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/spec/ruby/core/numeric/shared/step.rb b/spec/ruby/core/numeric/shared/step.rb index f058c64a50..0fb2336bf5 100644 --- a/spec/ruby/core/numeric/shared/step.rb +++ b/spec/ruby/core/numeric/shared/step.rb @@ -258,19 +258,24 @@ describe :numeric_step, :shared => true do end describe "when no block is given" do - it "returns an Enumerator when step is 0" do - 1.send(@method, *@step_args.call(2, 0)).should be_an_instance_of(Enumerator::ArithmeticSequence) + step_enum_class = Enumerator + ruby_version_is "2.6" do + step_enum_class = Enumerator::ArithmeticSequence end - it "returns an Enumerator when not passed a block and self > stop" do - 1.send(@method, *@step_args.call(0, 2)).should be_an_instance_of(Enumerator::ArithmeticSequence) + it "returns an #{step_enum_class} when step is 0" do + 1.send(@method, *@step_args.call(2, 0)).should be_an_instance_of(step_enum_class) end - it "returns an Enumerator when not passed a block and self < stop" do - 1.send(@method, *@step_args.call(2, 3)).should be_an_instance_of(Enumerator::ArithmeticSequence) + it "returns an #{step_enum_class} when not passed a block and self > stop" do + 1.send(@method, *@step_args.call(0, 2)).should be_an_instance_of(step_enum_class) end - it "returns an Enumerator that uses the given step" do + it "returns an #{step_enum_class} when not passed a block and self < stop" do + 1.send(@method, *@step_args.call(2, 3)).should be_an_instance_of(step_enum_class) + end + + it "returns an #{step_enum_class} that uses the given step" do 0.send(@method, *@step_args.call(5, 2)).to_a.should eql [0, 2, 4] end |