Sha256: 014eb221f95dd6753230fb0f7fdd55253f8fd5e9f36d7ae9d8e06fcef09c0d61

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'spec_helper')
require "shared_factory_specs"
require 'rubyonacid/factories/loop'

include RubyOnAcid

describe LoopFactory do
  
  MARGIN = 0.01
  
  before :each do
    @it = LoopFactory.new
  end
  
  it_should_behave_like "a factory"
  
  it "Loops to 0 if increment is positive" do
    @it.interval = 0.3
    @it.get_unit(:x).should be_close(0.3, MARGIN)
    @it.get_unit(:x).should be_close(0.6, MARGIN)
    @it.get_unit(:x).should be_close(0.9, MARGIN)
    @it.get_unit(:x).should be_close(0.2, MARGIN)
    @it.get_unit(:x).should be_close(0.5, MARGIN)
  end
  
  it "Loops to 1 if increment is negative" do
    @it.interval = -0.3
    @it.get_unit(:x).should be_close(0.7, MARGIN)
    @it.get_unit(:x).should be_close(0.4, MARGIN)
    @it.get_unit(:x).should be_close(0.1, MARGIN)
    @it.get_unit(:x).should be_close(0.8, MARGIN)
    @it.get_unit(:x).should be_close(0.5, MARGIN)
  end
  
  it "handles multiple keys" do
    @it.interval = 0.3
    @it.get_unit(:x).should be_close(0.3, MARGIN)
    @it.get_unit(:y).should be_close(0.3, MARGIN)
    @it.get_unit(:x).should be_close(0.6, MARGIN)
    @it.get_unit(:y).should be_close(0.6, MARGIN)
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubyonacid-0.1.2 spec/generators/loop_spec.rb
rubyonacid-0.1.1 spec/generators/loop_spec.rb
rubyonacid-0.1.0 spec/generators/loop_spec.rb