Sha256: 2cac08227b56ccd233a163807e8b629aa536d1a01b2a842be120f5b4befadeb3

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

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

include RubyOnAcid

describe RepeatFactory do
  
  before :each do
    @it = RepeatFactory.new
  end
  
  it "Requests a value from the source factory and repeats it a given number of times" do
    source_factory = mock('Factory')
    source_factory.should_receive(:get_unit).exactly(3).times.and_return(0.0, 1.0, 0.5)
    @it.source_factory = source_factory
    @it.repeat_count = 2
    @it.get_unit(:x).should == 0.0
    @it.get_unit(:x).should == 0.0
    @it.get_unit(:x).should == 1.0
    @it.get_unit(:x).should == 1.0
    @it.get_unit(:x).should == 0.5
  end
  
  it "Tracks repeats on a per-key basis" do
    source_factory = mock('Factory')
    source_factory.should_receive(:get_unit).exactly(4).times.and_return(0.0, 1.0, 0.5, 0.75)
    @it.source_factory = source_factory
    @it.repeat_count = 2
    @it.get_unit(:x).should == 0.0
    @it.get_unit(:y).should == 1.0
    @it.get_unit(:x).should == 0.0
    @it.get_unit(:y).should == 1.0
    @it.get_unit(:x).should == 0.5
    @it.get_unit(:y).should == 0.75
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubyonacid-0.3.1 spec/factories/repeat_spec.rb
rubyonacid-0.3.0 spec/factories/repeat_spec.rb
rubyonacid-0.2.0 spec/factories/repeat_spec.rb
rubyonacid-0.1.2 spec/generators/repeat_spec.rb
rubyonacid-0.1.1 spec/generators/repeat_spec.rb
rubyonacid-0.1.0 spec/generators/repeat_spec.rb