Sha256: 0a38ebeb1112f661895ba6dfa5421a3ba2c9f7dc196a2276c458c08b68c8496f

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

require File.join(File.dirname(__FILE__), '/../../spec_helper')

describe Threading do
  
  before(:each) do
    @window = stub :window, :things => []
    @threaded = test_class_with(Threading).new @window
  end
  
  describe "sometimes" do
    it "should only call the block's content every x times" do
      @threaded.stub! :threaded => nil
      
      @threaded.sometimes(:some_id, :some_time) { :some_result }.should == :some_result
      @threaded.sometimes(:some_id, :some_time) { :some_result }.should == nil
      
      @threaded.instance_variable_set(:'@__sometimes_some_id', false)
      @threaded.sometimes(:some_id, :some_time) { :some_result }.should == :some_result
    end
  end
  
  describe "threaded" do
    before(:each) do
      @scheduling = stub :scheduling
      @window.stub! :scheduling => @scheduling
    end
    it "should delegate to the window's scheduling" do
      some_block = lambda {}
      @scheduling.should_receive(:add).once.with :some_time, &some_block
      
      @threaded.threaded :some_time, &some_block
    end
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gosu_extensions-0.3.8 spec/lib/core/threading_spec.rb
gosu_extensions-0.3.7 spec/lib/core/threading_spec.rb
gosu_extensions-0.3.6 spec/lib/core/threading_spec.rb
gosu_extensions-0.3.5 spec/lib/core/threading_spec.rb
gosu_extensions-0.3.4 spec/lib/core/threading_spec.rb
gosu_extensions-0.3.3 spec/lib/core/threading_spec.rb