Sha256: 9ebea8560cb7d63c01a3bc4ebcb9e6e005656c0ff42d527737ade9b4fe38bce2

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../helper")

describe "extending bindings and transitions with Lathe#helper" do

  include MySpecHelper

  before(:each) do
    reset!
    make_pristine_class('Klass')

    @machine = Klass.machine do
      state :normal, :colour => 'green'
      state :bad,    :colour => 'red'
      event( :worsen, :colour => 'orange' ) { from :normal => :bad }
    end
    @obj = Klass.new
    @binding       = @obj.state_fu

  end # before

  describe "accessing sprocket options" do
    describe "state#[]" do
      it "should return state.options[key]" do
        @machine.states[:normal][:colour].should == 'green'
      end
    end
    describe "event#[]" do
      it "should return event.options[key]" do
        @machine.events[:worsen][:colour].should == 'orange'
      end
    end

    describe "state#[]=" do
      it "should update state.options" do
        @machine.states[:normal][:flavour] = 'lime'
        @machine.states[:normal][:flavour].should == 'lime'
      end
    end
    describe "event#[]=" do
      it "should update event.options" do
        @machine.events[:worsen][:flavour] = 'orange'
        @machine.events[:worsen][:flavour].should == 'orange'
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
davidlee-state-fu-0.3.1 spec/features/state_and_array_options_accessor_spec.rb