1 require File.dirname(__FILE__) + '/../spec_helper'
3 describe "The loop expression" do
5 it "repeats the given block until a break is called" do
9 break if outer_loop == 10
11 outer_loop.should == 10
14 it "executes code in its own scope" do
19 lambda { inner_loop }.should raise_error(NameError)
22 it "returns the value passed to break if interrupted by break" do
28 it "returns nil if interrupted by break with no arguments" do
34 it "skips to end of body with next" do
45 it "restarts the current iteration with redo" do
56 it "uses a spaghetti nightmare of redo, next and break" do
66 a.should == [1, 1, 2, 1, 2, 3, 1, 2, 3]