davidlee-state-fu 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +40 -0
- data/README.textile +174 -0
- data/Rakefile +87 -0
- data/lib/no_stdout.rb +32 -0
- data/lib/state-fu.rb +93 -0
- data/lib/state_fu/binding.rb +262 -0
- data/lib/state_fu/core_ext.rb +23 -0
- data/lib/state_fu/event.rb +98 -0
- data/lib/state_fu/exceptions.rb +42 -0
- data/lib/state_fu/fu_space.rb +50 -0
- data/lib/state_fu/helper.rb +189 -0
- data/lib/state_fu/hooks.rb +28 -0
- data/lib/state_fu/interface.rb +139 -0
- data/lib/state_fu/lathe.rb +247 -0
- data/lib/state_fu/logger.rb +10 -0
- data/lib/state_fu/machine.rb +159 -0
- data/lib/state_fu/method_factory.rb +95 -0
- data/lib/state_fu/persistence/active_record.rb +27 -0
- data/lib/state_fu/persistence/attribute.rb +46 -0
- data/lib/state_fu/persistence/base.rb +98 -0
- data/lib/state_fu/persistence/session.rb +7 -0
- data/lib/state_fu/persistence.rb +50 -0
- data/lib/state_fu/sprocket.rb +27 -0
- data/lib/state_fu/state.rb +45 -0
- data/lib/state_fu/transition.rb +213 -0
- data/spec/helper.rb +86 -0
- data/spec/integration/active_record_persistence_spec.rb +189 -0
- data/spec/integration/class_accessor_spec.rb +127 -0
- data/spec/integration/event_definition_spec.rb +74 -0
- data/spec/integration/ex_machine_for_accounts_spec.rb +79 -0
- data/spec/integration/example_01_document_spec.rb +127 -0
- data/spec/integration/example_02_string_spec.rb +87 -0
- data/spec/integration/instance_accessor_spec.rb +100 -0
- data/spec/integration/machine_duplication_spec.rb +95 -0
- data/spec/integration/requirement_reflection_spec.rb +201 -0
- data/spec/integration/sanity_spec.rb +31 -0
- data/spec/integration/state_definition_spec.rb +177 -0
- data/spec/integration/transition_spec.rb +1060 -0
- data/spec/spec.opts +7 -0
- data/spec/units/binding_spec.rb +145 -0
- data/spec/units/event_spec.rb +232 -0
- data/spec/units/exceptions_spec.rb +75 -0
- data/spec/units/fu_space_spec.rb +95 -0
- data/spec/units/lathe_spec.rb +567 -0
- data/spec/units/machine_spec.rb +237 -0
- data/spec/units/method_factory_spec.rb +359 -0
- data/spec/units/sprocket_spec.rb +71 -0
- data/spec/units/state_spec.rb +50 -0
- metadata +122 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
|
2
|
+
|
|
3
|
+
## See state_and_event_common_spec.rb for behaviour shared between
|
|
4
|
+
## StateFu::State and StateFu::Event
|
|
5
|
+
##
|
|
6
|
+
|
|
7
|
+
describe StateFu::State do
|
|
8
|
+
include MySpecHelper
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
@machine = Object.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "instance methods" do
|
|
15
|
+
before do
|
|
16
|
+
@state = StateFu::State.new( @machine, :flux, {:meta => "wibble"} )
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe ".events" do
|
|
20
|
+
|
|
21
|
+
it "should call machine.events.from(self)" do
|
|
22
|
+
machine_events = Object.new
|
|
23
|
+
mock( @machine ).events { machine_events }
|
|
24
|
+
mock( machine_events ).from( @state ) { nil }
|
|
25
|
+
@state.events
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe ".event" do
|
|
31
|
+
|
|
32
|
+
it "should act as a proxy for lathe.event without a block" do
|
|
33
|
+
lathe = Object.new
|
|
34
|
+
mock( @state ).lathe { lathe }
|
|
35
|
+
mock( lathe ).event( :evt_name, :from => :old, :to => :new ) { nil }
|
|
36
|
+
@state.event( :evt_name, :from => :old, :to => :new )
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should act as a proxy for lathe.event with a block" do
|
|
40
|
+
lathe = Object.new
|
|
41
|
+
block = lambda{}
|
|
42
|
+
stub( @state ).lathe { lathe }
|
|
43
|
+
args = [:evt_name, {:from => :old, :to => :new}]
|
|
44
|
+
mock( lathe ).event( *args ) {}
|
|
45
|
+
@state.event( *args ){ puts "TODO: can't find a way to test the block is passed" }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: davidlee-state-fu
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- David Lee
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-05-04 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: A rich library for state-oriented programming with state machines / workflows
|
|
17
|
+
email: david@rubyist.net.au
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- LICENSE
|
|
24
|
+
- README.textile
|
|
25
|
+
files:
|
|
26
|
+
- Rakefile
|
|
27
|
+
- lib/no_stdout.rb
|
|
28
|
+
- lib/state-fu.rb
|
|
29
|
+
- lib/state_fu/binding.rb
|
|
30
|
+
- lib/state_fu/core_ext.rb
|
|
31
|
+
- lib/state_fu/event.rb
|
|
32
|
+
- lib/state_fu/exceptions.rb
|
|
33
|
+
- lib/state_fu/fu_space.rb
|
|
34
|
+
- lib/state_fu/helper.rb
|
|
35
|
+
- lib/state_fu/hooks.rb
|
|
36
|
+
- lib/state_fu/interface.rb
|
|
37
|
+
- lib/state_fu/lathe.rb
|
|
38
|
+
- lib/state_fu/logger.rb
|
|
39
|
+
- lib/state_fu/machine.rb
|
|
40
|
+
- lib/state_fu/method_factory.rb
|
|
41
|
+
- lib/state_fu/persistence.rb
|
|
42
|
+
- lib/state_fu/persistence/active_record.rb
|
|
43
|
+
- lib/state_fu/persistence/attribute.rb
|
|
44
|
+
- lib/state_fu/persistence/base.rb
|
|
45
|
+
- lib/state_fu/persistence/session.rb
|
|
46
|
+
- lib/state_fu/sprocket.rb
|
|
47
|
+
- lib/state_fu/state.rb
|
|
48
|
+
- lib/state_fu/transition.rb
|
|
49
|
+
- spec/helper.rb
|
|
50
|
+
- spec/integration/active_record_persistence_spec.rb
|
|
51
|
+
- spec/integration/class_accessor_spec.rb
|
|
52
|
+
- spec/integration/event_definition_spec.rb
|
|
53
|
+
- spec/integration/ex_machine_for_accounts_spec.rb
|
|
54
|
+
- spec/integration/example_01_document_spec.rb
|
|
55
|
+
- spec/integration/example_02_string_spec.rb
|
|
56
|
+
- spec/integration/instance_accessor_spec.rb
|
|
57
|
+
- spec/integration/machine_duplication_spec.rb
|
|
58
|
+
- spec/integration/requirement_reflection_spec.rb
|
|
59
|
+
- spec/integration/sanity_spec.rb
|
|
60
|
+
- spec/integration/state_definition_spec.rb
|
|
61
|
+
- spec/integration/transition_spec.rb
|
|
62
|
+
- spec/spec.opts
|
|
63
|
+
- spec/units/binding_spec.rb
|
|
64
|
+
- spec/units/event_spec.rb
|
|
65
|
+
- spec/units/exceptions_spec.rb
|
|
66
|
+
- spec/units/fu_space_spec.rb
|
|
67
|
+
- spec/units/lathe_spec.rb
|
|
68
|
+
- spec/units/machine_spec.rb
|
|
69
|
+
- spec/units/method_factory_spec.rb
|
|
70
|
+
- spec/units/sprocket_spec.rb
|
|
71
|
+
- spec/units/state_spec.rb
|
|
72
|
+
- LICENSE
|
|
73
|
+
- README.textile
|
|
74
|
+
has_rdoc: true
|
|
75
|
+
homepage: http://github.com/davidlee/state-fu
|
|
76
|
+
post_install_message:
|
|
77
|
+
rdoc_options:
|
|
78
|
+
- --charset=UTF-8
|
|
79
|
+
require_paths:
|
|
80
|
+
- lib
|
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: "0"
|
|
86
|
+
version:
|
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: "0"
|
|
92
|
+
version:
|
|
93
|
+
requirements: []
|
|
94
|
+
|
|
95
|
+
rubyforge_project: state-fu
|
|
96
|
+
rubygems_version: 1.2.0
|
|
97
|
+
signing_key:
|
|
98
|
+
specification_version: 2
|
|
99
|
+
summary: A rich library for state-oriented programming with state machines / workflows
|
|
100
|
+
test_files:
|
|
101
|
+
- spec/units/machine_spec.rb
|
|
102
|
+
- spec/units/sprocket_spec.rb
|
|
103
|
+
- spec/units/event_spec.rb
|
|
104
|
+
- spec/units/lathe_spec.rb
|
|
105
|
+
- spec/units/binding_spec.rb
|
|
106
|
+
- spec/units/state_spec.rb
|
|
107
|
+
- spec/units/method_factory_spec.rb
|
|
108
|
+
- spec/units/exceptions_spec.rb
|
|
109
|
+
- spec/units/fu_space_spec.rb
|
|
110
|
+
- spec/helper.rb
|
|
111
|
+
- spec/integration/example_01_document_spec.rb
|
|
112
|
+
- spec/integration/transition_spec.rb
|
|
113
|
+
- spec/integration/class_accessor_spec.rb
|
|
114
|
+
- spec/integration/instance_accessor_spec.rb
|
|
115
|
+
- spec/integration/requirement_reflection_spec.rb
|
|
116
|
+
- spec/integration/machine_duplication_spec.rb
|
|
117
|
+
- spec/integration/state_definition_spec.rb
|
|
118
|
+
- spec/integration/event_definition_spec.rb
|
|
119
|
+
- spec/integration/sanity_spec.rb
|
|
120
|
+
- spec/integration/active_record_persistence_spec.rb
|
|
121
|
+
- spec/integration/example_02_string_spec.rb
|
|
122
|
+
- spec/integration/ex_machine_for_accounts_spec.rb
|