Sha256: f5c38cc7581ceca6225567e155815497c92d31f5f9e3188d1231ccf02236f549

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

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

include RubyOnAcid

describe IncrementFactory do
  
  
  before :each do
    @it = IncrementFactory.new
  end
  
  it_should_behave_like "a factory"
  
  it "Stops at 1 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(1.0, MARGIN)
    @it.get_unit(:x).should be_close(1.0, MARGIN)
  end
  
  it "Stops at 0 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.0, MARGIN)
    @it.get_unit(:x).should be_close(0.0, 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

4 entries across 4 versions & 1 rubygems

Version Path
rubyonacid-0.4.0 spec/factories/increment_spec.rb
rubyonacid-0.3.1 spec/factories/increment_spec.rb
rubyonacid-0.3.0 spec/factories/increment_spec.rb
rubyonacid-0.2.0 spec/factories/increment_spec.rb