Sha256: 929c9f21099967f9c6bfb2c89343339571d15f6d79e02b910749f545c5c605b6

Contents?: true

Size: 1.65 KB

Versions: 5

Compression:

Stored size: 1.65 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe LoopDance do 

  describe "setup" do
  end

  describe "finds minimal interval"

  describe "examples" do 

    before(:all) do
      class Dancer1 < LoopDance::Dancer
        every 2.seconds do
        end
        every 4.seconds do
        end
        every 6.seconds do
        end
        every 10.seconds do
        end
      end
    end


    it { Dancer1.tasks.count.should == 4 }
    it { Dancer1.timeout.should == 2 }
    it { LoopDance::Dancer.tasks.should be_blank }
    it { Dancer1.maximal_timeout.should == 10 }


    describe "another dancer not change first dancer's tasks" do
      
      before(:all) do
        class Dancer2 < LoopDance::Dancer
          every 6.seconds do
          end
          every 11.seconds do
          end
        end
      end

      it { Dancer2.tasks.count.should == 2 }
      it { Dancer2.timeout.should == 1 }
      it { Dancer2.maximal_timeout.should == 11 }
      
    end

    describe "find right minimal timeout" do
      
      before(:all) do
        class Dancer3 < LoopDance::Dancer
          every 6.seconds do
          end
          every 9.seconds do
          end
        end
      end

      it { Dancer3.tasks.count.should == 2 }
      it { Dancer3.timeout.should == 3 }
      it { Dancer3.maximal_timeout.should == 9 }
      
    end

    describe "method stop stops the loop" do
      
      before(:all) do
        class Dancer < LoopDance::Dancer
          every 2.seconds do
            stop
          end
        end
      end

      it { Dancer.dance }
      it { Dancer.maximal_timeout.should == 2 }
      
    end


    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
loop_dance-0.2.5 spec/dancer_spec.rb
loop_dance-0.2.4 spec/dancer_spec.rb
loop_dance-0.2.3 spec/dancer_spec.rb
loop_dance-0.2.2 spec/dancer_spec.rb
loop_dance-0.2.0 spec/dancer_spec.rb