Sha256: 6dcbb32b8d26d6859bca666ee94e9361b030dd4a146ec0b502bb1256584a4566

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

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

include RubyOnAcid

describe SineFactory do
  
  
  before :each do
    @it = SineFactory.new
  end
  
  it_should_behave_like "a factory"
  
  it "loops between 0 and 1" do
    @it.interval = 1.0
    @it.get_unit(:x).should be_close(0.920, MARGIN)
    @it.get_unit(:x).should be_close(0.954, MARGIN)
    @it.get_unit(:x).should be_close(0.570, MARGIN)
    @it.get_unit(:x).should be_close(0.122, MARGIN)
    @it.get_unit(:x).should be_close(0.020, MARGIN)
    @it.get_unit(:x).should be_close(0.360, MARGIN)
  end
  
  it "can take a different interval" do
    @it.interval = 0.5
    @it.get_unit(:x).should be_close(0.740, MARGIN)
    @it.get_unit(:x).should be_close(0.920, MARGIN)
  end
  
  it "handles multiple keys" do
    @it.interval = 1.0
    @it.get_unit(:x).should be_close(0.920, MARGIN)
    @it.get_unit(:y).should be_close(0.920, MARGIN)
    @it.get_unit(:x).should be_close(0.954, MARGIN)
    @it.get_unit(:y).should be_close(0.954, MARGIN)
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

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