Skip to content

Commit

Permalink
update of blat spec, and spec for overriding transitions_to on events…
Browse files Browse the repository at this point in the history
…, removal of the begining of the blat code coz can't remember what i was trying to do (yet)

git-svn-id: svn://yeahnah.org/workflow/trunk@67 bd2358d6-94b4-11dc-a27b-d93154198e44
  • Loading branch information
ryan-allen committed May 5, 2008
1 parent ea2933a commit 09ffde9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
6 changes: 1 addition & 5 deletions lib/workflow.rb
Expand Up @@ -94,11 +94,7 @@ def blat(meta = {}, &specification)

def state(name, meta = {:meta => {}}, &events_and_etc)
# meta[:meta] to keep the API consistent..., gah
if states(name)
states(name) += State.new(name, meta[:meta])
else
@states << State.new(name, meta[:meta])
end
self.states << State.new(name, meta[:meta])
instance_eval(&events_and_etc) if events_and_etc
end

Expand Down
35 changes: 14 additions & 21 deletions specs/documentation_validation_spec.rb
Expand Up @@ -391,50 +391,43 @@ class Item < ActiveRecord::Base; include Workflow; end
on_entry { |*args| }
end
state :third do
event :prevous, :transitions_to => :second
event :previous, :transitions_to => :second
end
on_transition { |*args| }
end
end

def workflow
Workflow.new('blatting')
@workflow = Workflow.new('blatting')
end

def blat(&with)
Workflow.specify('blatting', &with)
end

it 'can introduce new states' do
workflow.states.should == [:first, :second, :third]
@workflow.states.should == [:first, :second, :third]
blat { state :fourth }
workflow.states.should == [:first, :second, :third, :fourth]
@workflow.states.should == [:first, :second, :third, :fourth]
end

it 'can introduce new events in states' do
workflow.states(:third).events == [:previous]
@workflow.states(:third).events == [:previous]
blat { state(:third) { event :next, :transitions_to => :first } }
workflow.states(:third).events.should == [:previous, :next]
@workflow.states(:third).events.should == [:previous, :next]
end

it 'can change transitions_to in existing events' do
@workflow.state(:third).events(:previous).transitions_to.should == :second
blat { state state(:third) { event :previous, :transitions_to => :first } }
@workflow.state(:third).events(:previous).transitions_to.should == :first
end

it 'can change transitions_to in existing events'
it 'can replace on_entry hooks'
it 'can replace on_exit hooks'
it 'can replace on_transition hooks'

it 'merges instance meta'
it 'merges state meta'
it 'merges event meta'

end

end









end

0 comments on commit 09ffde9

Please sign in to comment.