diff options
Diffstat (limited to 'spec/ruby/core/numeric/shared/step.rb')
| -rw-r--r-- | spec/ruby/core/numeric/shared/step.rb | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/spec/ruby/core/numeric/shared/step.rb b/spec/ruby/core/numeric/shared/step.rb index 6c47cdeecb..977ec6de02 100644 --- a/spec/ruby/core/numeric/shared/step.rb +++ b/spec/ruby/core/numeric/shared/step.rb @@ -5,7 +5,7 @@ require_relative '../fixtures/classes' # To be able to do it, the @step ivar must contain a Proc that transforms # the step call arguments passed as positional arguments to the style of # arguments pretended to test. -describe :numeric_step, :shared => true do +describe :numeric_step, shared: true do before :each do ScratchPad.record [] @prc = -> x { ScratchPad << x } @@ -24,9 +24,9 @@ describe :numeric_step, :shared => true do 1.0.step.first(5).should == [1.0, 2.0, 3.0, 4.0, 5.0] end - describe "when self, stop and step are Fixnums" do - it "yields only Fixnums" do - @step.call(1, 5, 1) { |x| x.should be_an_instance_of(Fixnum) } + describe "when self, stop and step are Integers" do + it "yields only Integers" do + @step.call(1, 5, 1) { |x| x.should be_an_instance_of(Integer) } end describe "with a positive step" do @@ -224,7 +224,7 @@ describe :numeric_step, :shared => true do end describe "when step is a String" do - describe "with self and stop as Fixnums" do + describe "with self and stop as Integers" do it "raises an ArgumentError when step is a numeric representation" do -> { @step.call(1, 5, "1") {} }.should raise_error(ArgumentError) -> { @step.call(1, 5, "0.1") {} }.should raise_error(ArgumentError) @@ -256,16 +256,7 @@ describe :numeric_step, :shared => true do end describe "when no block is given" do - step_enum_class = Enumerator - ruby_version_is "2.6" do - step_enum_class = Enumerator::ArithmeticSequence - end - - ruby_version_is ""..."3.0" do - it "returns an #{step_enum_class} when step is 0" do - @step.call(1, 2, 0).should be_an_instance_of(step_enum_class) - end - end + step_enum_class = Enumerator::ArithmeticSequence it "returns an #{step_enum_class} when not passed a block and self > stop" do @step.call(1, 0, 2).should be_an_instance_of(step_enum_class) @@ -280,7 +271,7 @@ describe :numeric_step, :shared => true do end describe "when step is a String" do - describe "with self and stop as Fixnums" do + describe "with self and stop as Integers" do it "returns an Enumerator" do @step.call(1, 5, "foo").should be_an_instance_of(Enumerator) end @@ -296,7 +287,7 @@ describe :numeric_step, :shared => true do describe "returned Enumerator" do describe "size" do describe "when step is a String" do - describe "with self and stop as Fixnums" do + describe "with self and stop as Integers" do it "raises an ArgumentError when step is a numeric representation" do -> { @step.call(1, 5, "1").size }.should raise_error(ArgumentError) -> { @step.call(1, 5, "0.1").size }.should raise_error(ArgumentError) @@ -319,7 +310,7 @@ describe :numeric_step, :shared => true do end end - describe "when self, stop and step are Fixnums and step is positive" do + describe "when self, stop and step are Integers and step is positive" do it "returns the difference between self and stop divided by the number of steps" do @step.call(5, 10, 11).size.should == 1 @step.call(5, 10, 6).size.should == 1 @@ -336,7 +327,7 @@ describe :numeric_step, :shared => true do end end - describe "when self, stop and step are Fixnums and step is negative" do + describe "when self, stop and step are Integers and step is negative" do it "returns the difference between self and stop divided by the number of steps" do @step.call(10, 5, -11).size.should == 1 @step.call(10, 5, -6).size.should == 1 |
