Sha256: ccc5a3b7ac3e6654321199d96c99e99f64c19d35ee721f57105f0287243f3c47

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

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

include RubyOnAcid

describe SineFactory do
  
  MARGIN = 0.01
  
  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.500, MARGIN)
    @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.500, MARGIN)
    @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.1.2 spec/generators/sine_spec.rb
rubyonacid-0.1.1 spec/generators/sine_spec.rb
rubyonacid-0.1.0 spec/generators/sine_spec.rb