Sha256: c35b510b66ed9b06465c39037ac74d32750d942acb36eced2cf378f58341a8b1

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ImmediateChange do
  describe '.new' do
    context 'empty hash given' do
      it 'should raise HashedArgMissingError' do
        expect { ImmediateChange.new({}) }.to raise_error(HashedArgMissingError)
      end
    end

    context ':end_value given' do
      it 'should raise HashedArgMissingError' do
        expect { ImmediateChange.new(:end_value => 1) }.to_not raise_error
      end
    end
  end

  describe '#transition_function' do
    it 'should return a Proc with arity of 1' do
      [ 2, 5.5 ].each do |value|
        ImmediateChange.new(:end_value => value).transition_function([0,0]).arity.should eq(1)
      end
    end

    it 'should return a Proc, that returns the given constant value regardless of the argument' do
      [ 2, 5.5 ].each do |value|
        f = ImmediateChange.new(:end_value => value).transition_function([0,0])
        f.call(1).should eq(value)
        f.call(1000).should eq(value)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
variation-0.2.1 spec/changes/immediate_change_spec.rb
variation-0.2.0 spec/changes/immediate_change_spec.rb