Sha256: 289dcf4644e4f018c7fb192c89f229bfba02e958bd4b5f5204588f25543e448e

Contents?: true

Size: 1.54 KB

Versions: 11

Compression:

Stored size: 1.54 KB

Contents

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

include Fathom

describe Agent do
  
  before do
    @pr1 = PlausibleRange.new(:min => 1, :max => 2)
    @pr2 = PlausibleRange.new(:min => 10, :max => 11)
    @da = DemoAgent.new(:field1 => @pr1, :field2 => @pr2)
  end
  
  it "should be have a list of properties" do
    DemoAgent.properties.should eql([:field1, :field2])
  end
  
  it "should be able to set a seed node for each property defined in the class" do
    @da.node_for_field1.should eql(@pr1)
    @da.node_for_field2.should eql(@pr2)
  end
  
  it "should not set a seed node for a node that doesn't have a property" do
    da = DemoAgent.new(:field1 => @pr1, :field2 => @pr2, :field3 => :should_not_be_found)
    da.should_not be_respond_to(:node_for_field3)
  end
  
  it "should have a state accessor for each property" do
    @da.should be_respond_to(:field1)
    @da.should be_respond_to(:field1=)
    @da.should be_respond_to(:field2)
    @da.should be_respond_to(:field2=)
  end
  
  it "should set the initial state of each property from the seed node, if defined" do
    @pr1.should_receive(:rand).and_return(1.5)
    @pr2.should_not_receive(:rand)
    @da = DemoAgent.new(:field1 => @pr1)
    @da.field1.should eql(1.5)
    @da.field2.should be_nil
  end
  
  it "should be able to send a hard parameter and save it in a property" do
    @da = DemoAgent.new(:field1 => 2)
    @da.field1.should eql(2)
  end
  
  it "should expose the callbacks, those methods starting with on_" do
    @da.callbacks.should eql(["on_tick"])
  end
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fathom-0.3.7 spec/fathom/agent_spec.rb
fathom-0.3.6 spec/fathom/agent_spec.rb
fathom-0.3.4 spec/fathom/agent_spec.rb
fathom-0.3.3 spec/fathom/agent_spec.rb
fathom-0.3.2 spec/fathom/agent_spec.rb
fathom-0.3.1 spec/fathom/agent_spec.rb
fathom-0.3.0 spec/fathom/agent_spec.rb
fathom-0.2.3 spec/fathom/agent_spec.rb
fathom-0.2.2 spec/fathom/agent_spec.rb
fathom-0.2.1 spec/fathom/agent_spec.rb
fathom-0.2.0 spec/fathom/agent_spec.rb