stuka 0.0.10 → 0.0.11
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/stuka/commands/command.rb +0 -8
- data/lib/stuka/commands/public_commands/new_command.rb +0 -1
- data/lib/stuka/commands/public_commands/process_command.rb +2 -2
- data/lib/stuka/commands/public_commands/setup_command.rb +3 -4
- data/lib/stuka/{stuka_cli.rb → commands/stuka_cli.rb} +4 -4
- data/lib/stuka/commands/subcommands/create/{create_process.rb → create_process_file.rb} +3 -3
- data/lib/stuka/commands/subcommands/setup/setup_directories.rb +6 -6
- data/lib/stuka/external/action_finder.rb +25 -0
- data/lib/stuka/external/business_action.rb +18 -0
- data/lib/stuka/external/business_process.rb +85 -0
- data/lib/stuka/external/dispatcher.rb +27 -0
- data/lib/stuka/external/process_states/finished_state.rb +13 -0
- data/lib/stuka/external/process_states/inactive_state.rb +16 -0
- data/lib/stuka/external/process_states/started_state.rb +21 -0
- data/lib/stuka/external/process_states/starting_state.rb +16 -0
- data/lib/stuka/external/unknown_action.rb +9 -0
- data/lib/stuka/internal/domain/action.rb +32 -0
- data/lib/stuka/internal/domain/domain.rb +29 -0
- data/lib/stuka/internal/domain/process.rb +32 -0
- data/lib/stuka/internal/domain_builders/action_domain_builder.rb +19 -0
- data/lib/stuka/internal/domain_builders/domain_builder.rb +32 -0
- data/lib/stuka/internal/domain_builders/process_domain_builder.rb +17 -0
- data/lib/stuka/internal/process_cleaner.rb +0 -2
- data/lib/stuka/internal/source_builders/action_builder.rb +32 -0
- data/lib/stuka/internal/source_builders/process_builder.rb +38 -0
- data/lib/stuka/internal/source_builders/source_builder.rb +14 -0
- data/lib/stuka/internal/validator.rb +22 -7
- data/lib/stuka/paths/stuka_paths.rb +18 -0
- data/lib/stuka/templates/source/process.tt +18 -3
- data/lib/stuka/version.rb +2 -2
- data/lib/stuka.rb +0 -1
- data/spec/{commands → aceptance/commands}/new_command_spec.rb +1 -1
- data/spec/aceptance/commands/process_command_spec.rb +22 -0
- data/spec/{commands → aceptance/commands}/setup_command_spec.rb +1 -1
- data/spec/aceptance/external/action_aceptance_spec.rb +24 -0
- data/spec/aceptance/external/feed_cat_process_aceptance_spec.rb +46 -0
- data/spec/aceptance/external/processes/cat/check_food.rb +14 -0
- data/spec/aceptance/external/processes/cat/fill_up_plate.rb +14 -0
- data/spec/aceptance/external/processes/cat/go_to_store.rb +14 -0
- data/spec/aceptance/external/processes/feed_cat_process.rb +28 -0
- data/spec/spec_helper.rb +10 -2
- data/spec/unit/external/example_source/create_world.rb +28 -0
- data/spec/unit/external/example_source/kill_monster.rb +38 -0
- data/spec/unit/external/example_source/world/gather_materials.rb +13 -0
- data/spec/unit/external/example_source/world/scrap_world.rb +13 -0
- data/spec/unit/external/example_source/world/seperate_light_from_darkness.rb +13 -0
- data/spec/unit/external/finder_spec.rb +37 -0
- data/spec/unit/external/process_interface.rb +9 -0
- data/spec/unit/external/process_to_action.rb +61 -0
- data/spec/unit/external/process_to_dispatcher_spec.rb +35 -0
- data/spec/unit/external/process_to_finder_spec.rb +138 -0
- data/spec/{build/process_builder_spec.rb → unit/internal/action_builder_spec.rb} +6 -7
- data/spec/unit/internal/action_domain_builder_spec.rb +44 -0
- data/spec/unit/internal/action_spec.rb +14 -0
- data/spec/unit/internal/process_builder_spec.rb +44 -0
- data/spec/{build → unit/internal}/process_cleaner_spec.rb +2 -3
- data/spec/unit/internal/process_domain_builder_spec.rb +51 -0
- data/spec/unit/internal/process_spec.rb +14 -0
- data/spec/unit/internal/process_validator_spec.rb +42 -0
- data/spec/{build → unit/internal}/processes_dsl_test/correct_test_process.rb +12 -5
- data/stuka.gemspec +1 -1
- metadata +82 -41
- data/lib/stuka/commands/public_commands/step_command.rb +0 -25
- data/lib/stuka/commands/subcommands/create/create_action.rb +0 -16
- data/lib/stuka/internal/action.rb +0 -33
- data/lib/stuka/internal/action_builder.rb +0 -31
- data/lib/stuka/internal/action_incubator.rb +0 -37
- data/lib/stuka/internal/process.rb +0 -38
- data/lib/stuka/internal/process_builder.rb +0 -30
- data/lib/stuka/internal/process_incubator.rb +0 -37
- data/lib/stuka/stuka_paths.rb +0 -21
- data/lib/stuka/templates/definitions/step.tt +0 -8
- data/spec/build/action_builder_spec.rb +0 -23
- data/spec/build/action_incubator_spec.rb +0 -24
- data/spec/build/dsl_spec.rb +0 -44
- data/spec/build/process_incubator_spec.rb +0 -27
- data/spec/build/process_validator_spec.rb +0 -40
- data/spec/commands/process_command_spec.rb +0 -19
- data/spec/commands/step_command_spec.rb +0 -19
- /data/spec/{build/processes_dsl_test/incorrect → unit/internal/processes_dsl_test_incorrect}/incorrect_test_process.rb +0 -0
@@ -1,35 +1,50 @@
|
|
1
|
-
|
1
|
+
require 'stuka/internal/domain/process'
|
2
2
|
|
3
3
|
module Stuka
|
4
4
|
|
5
5
|
class Validator
|
6
6
|
|
7
|
-
|
7
|
+
attr_reader :message
|
8
|
+
|
9
|
+
def process_valid?(process)
|
8
10
|
|
9
11
|
Stuka::Process::ATTRS.each do |arg|
|
10
12
|
result = process.public_send(arg.to_sym)
|
11
|
-
|
13
|
+
if result.nil?
|
14
|
+
@message = "#{process} does not all required attributes"
|
15
|
+
return false
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
Stuka::Process::REQUIRED_ATTRS.each do |arg|
|
15
20
|
result = process.public_send(arg.to_sym)
|
16
|
-
|
21
|
+
if result.nil? || result.empty?
|
22
|
+
@mesasge = "#{process} has empty values of required attributes"
|
23
|
+
return false
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
true
|
20
28
|
end
|
21
29
|
|
22
|
-
def
|
30
|
+
def process_set_valid?(processes)
|
23
31
|
|
24
|
-
|
32
|
+
if processes.include? nil
|
33
|
+
@message = "processes include nil"
|
34
|
+
return false
|
35
|
+
end
|
25
36
|
|
26
37
|
names = processes.map(&:name)
|
27
38
|
|
28
|
-
|
39
|
+
if names.include?(nil) || names.include?("")
|
40
|
+
@message = "some processes have no name or empty name"
|
41
|
+
return false
|
42
|
+
end
|
29
43
|
|
30
44
|
if names.uniq.length == names.length
|
31
45
|
return true
|
32
46
|
else
|
47
|
+
@message = "multiple processes with same name defined"
|
33
48
|
return false
|
34
49
|
end
|
35
50
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
module StukaPaths
|
4
|
+
|
5
|
+
PROCESSES_DEFINITION_PATH = "#{Dir.pwd}/process_definition"
|
6
|
+
|
7
|
+
PROCESSES_SOURCE_PATH = "#{Dir.pwd}/processes"
|
8
|
+
|
9
|
+
TEST_PROCESSES_DEFINITION_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../../spec/unit/internal/processes_dsl_test"
|
10
|
+
TEST_PROCESSES_INCORRECT_DEFINITION_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../../spec/unit/internal/processes_dsl_test_incorrect"
|
11
|
+
|
12
|
+
TEST_PROCESSES_SOURCE_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../../spec/unit/internal/processes_source_test"
|
13
|
+
|
14
|
+
TEMPLATES_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../templates"
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -1,8 +1,23 @@
|
|
1
|
-
|
1
|
+
require 'stuka/external/business_process'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
class <%= @name.capitalize %> < Stuka::BusinessProcess
|
4
|
+
|
5
|
+
TRANSITION_MAP = {
|
6
|
+
<% @transitions.keys.each do |action| %>
|
7
|
+
"<%= action %>" => {
|
8
|
+
<% @transitions[action].keys.each do |action_transition| %>
|
9
|
+
<%= action_transition %>: "<%= @transitions[action][action_transition] %>",
|
10
|
+
<% end %>
|
11
|
+
},
|
5
12
|
<% end %>
|
13
|
+
}
|
14
|
+
|
15
|
+
def transition_map
|
16
|
+
TRANSITION_MAP
|
17
|
+
end
|
18
|
+
|
19
|
+
def start_action
|
20
|
+
"<%= @start_action %>"
|
6
21
|
end
|
7
22
|
|
8
23
|
end
|
data/lib/stuka/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Stuka
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.11"
|
3
|
+
end
|
data/lib/stuka.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "stuka/commands/stuka_cli"
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
describe "process file command" do
|
6
|
+
|
7
|
+
around(:each) do |example|
|
8
|
+
Stuka::StukaCli.start ["new", "test_pro"]
|
9
|
+
example.run
|
10
|
+
FileUtils.rm_rf 'test_pro'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "sets up the project" do
|
14
|
+
Dir.chdir "test_pro" do
|
15
|
+
expect { Stuka::StukaCli.start ["process", "test_process"] }.to output(%r|Process file 'test_process.rb' created|).to_stdout
|
16
|
+
|
17
|
+
definition_files = Dir["#{Stuka::StukaPaths::PROCESSES_DEFINITION_PATH}/**/*.rb"]
|
18
|
+
expect { definition_files.to include("#{Stuka::StukaPaths::PROCESSES_DEFINITION_PATH}/test_process.rb}") }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "stuka/external/business_action"
|
3
|
+
require_relative 'processes/cat/check_food'
|
4
|
+
|
5
|
+
describe "CheckFood" do
|
6
|
+
|
7
|
+
let(:process) { double(transition: nil, can_transition_to?: true) }
|
8
|
+
let(:outstream) { StringIO.new }
|
9
|
+
let(:action) { Cat::CheckFood.new(process) }
|
10
|
+
|
11
|
+
after :each do
|
12
|
+
outstream.close
|
13
|
+
end
|
14
|
+
|
15
|
+
it "calls the process if it succeeds" do
|
16
|
+
|
17
|
+
expect(process).to receive :transition
|
18
|
+
action.run({name: "George", outstream: outstream})
|
19
|
+
expect(outstream.string).to include "There is enaugh food"
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stuka/external/business_process'
|
3
|
+
require_relative 'processes/feed_cat_process'
|
4
|
+
|
5
|
+
describe "Feed cat process" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
Stuka::StukaPaths::PROCESSES_SOURCE_PATH.replace "#{File.dirname(__FILE__)}/processes"
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:process) do
|
12
|
+
|
13
|
+
FeedCatProcess.new({}) do |on|
|
14
|
+
|
15
|
+
on.success { |params|
|
16
|
+
params[:outstream].puts "yay success"
|
17
|
+
}
|
18
|
+
|
19
|
+
on.failure { |params|
|
20
|
+
params[:outstream].puts "nay failure"
|
21
|
+
}
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:outstream) { StringIO.new }
|
28
|
+
|
29
|
+
after :each do
|
30
|
+
outstream.close
|
31
|
+
end
|
32
|
+
|
33
|
+
it "process starts executing actions when it ran" do
|
34
|
+
|
35
|
+
expect(process.current_state).to eq(Stuka::BusinessProcess::PROCESS_STATES[:inactive])
|
36
|
+
|
37
|
+
process.run({name: "George", outstream: outstream})
|
38
|
+
|
39
|
+
expect(process.current_state).to eq(Stuka::BusinessProcess::PROCESS_STATES[:finished])
|
40
|
+
|
41
|
+
expect(outstream.string).to include "There is enaugh food\nGeorge's food plate filled up\nyay success\n"
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "stuka/external/business_process"
|
2
|
+
|
3
|
+
class FeedCatProcess < Stuka::BusinessProcess
|
4
|
+
|
5
|
+
TRANSITION_MAP = {
|
6
|
+
"cat::check_food" => {
|
7
|
+
has_food: "cat::fill_up_plate",
|
8
|
+
no_food: "cat::go_to_store"
|
9
|
+
},
|
10
|
+
"cat::fill_up_plate" => {
|
11
|
+
success: "process::success",
|
12
|
+
failure: "process::failure"
|
13
|
+
},
|
14
|
+
"cat::go_to_store" => {
|
15
|
+
success: "cat::fill_up_plate",
|
16
|
+
failure: "process::failure"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
def transition_map
|
21
|
+
TRANSITION_MAP
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_action
|
25
|
+
"cat::check_food"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -19,10 +19,18 @@ RSpec.configure do |config|
|
|
19
19
|
# with RSpec, but feel free to customize to your heart's content.
|
20
20
|
|
21
21
|
config.before(:each) do
|
22
|
-
|
22
|
+
require "stuka/paths/stuka_paths"
|
23
23
|
Stuka::StukaPaths::PROCESSES_DEFINITION_PATH.replace Stuka::StukaPaths::TEST_PROCESSES_DEFINITION_PATH
|
24
24
|
Stuka::StukaPaths::PROCESSES_SOURCE_PATH.replace Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH
|
25
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
original_stdout = $stdout
|
28
|
+
config.before(:all) do
|
29
|
+
# Redirect stderr and stdout
|
30
|
+
$stdout = File.new(File.join(File.dirname(__FILE__), 'stdout.txt'), 'w')
|
31
|
+
end
|
32
|
+
config.after(:all) do
|
33
|
+
$stdout = original_stdout
|
26
34
|
end
|
27
35
|
|
28
36
|
=begin
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "stuka/external/business_process"
|
2
|
+
|
3
|
+
class CreateWorld < Stuka::BusinessProcess
|
4
|
+
|
5
|
+
TRANSITION_MAP = {
|
6
|
+
"world::gather_materials" => {
|
7
|
+
success: "world::seperate_light_from_darkness",
|
8
|
+
failure: "world::scrap_world"
|
9
|
+
},
|
10
|
+
"world::seperate_light_from_darkness" => {
|
11
|
+
success: "process::success",
|
12
|
+
failure: "world::scrap_world"
|
13
|
+
},
|
14
|
+
"world::scrap_world" => {
|
15
|
+
success: "process::failure",
|
16
|
+
failure: "process::failure"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
def transition_map
|
21
|
+
TRANSITION_MAP
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_action
|
25
|
+
"world::gather_materials"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "stuka/external/business_process"
|
2
|
+
|
3
|
+
class KillMonster < Stuka::BusinessProcess
|
4
|
+
|
5
|
+
TRANSITION_MAP = {
|
6
|
+
"monster::train_hard" => {
|
7
|
+
good_with_sword: "monster::get_a_sharp_sword",
|
8
|
+
sharp_shooter: "monster::get_a_new_gun",
|
9
|
+
failure: "monster::train_fast_running"
|
10
|
+
},
|
11
|
+
"monster::get_a_sharp_sword" => {
|
12
|
+
success: "process::success",
|
13
|
+
failure: "process::failure"
|
14
|
+
},
|
15
|
+
"monster::get_a_new_gun" => {
|
16
|
+
success: "gun::get_bullets",
|
17
|
+
failure: "process::failure"
|
18
|
+
},
|
19
|
+
"gun::get_bullets" => {
|
20
|
+
success: "process::success",
|
21
|
+
failure: "process::failure"
|
22
|
+
},
|
23
|
+
"monster::train_fast_running" => {
|
24
|
+
success: "process::success",
|
25
|
+
failure: "process::failure"
|
26
|
+
}
|
27
|
+
|
28
|
+
}
|
29
|
+
|
30
|
+
def transition_map
|
31
|
+
TRANSITION_MAP
|
32
|
+
end
|
33
|
+
|
34
|
+
def start_action
|
35
|
+
"monster::train_hard"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "unit/external/example_source/create_world"
|
3
|
+
require "unit/external/process_interface"
|
4
|
+
require "stuka/external/action_finder"
|
5
|
+
|
6
|
+
require "unit/external/example_source/world/gather_materials"
|
7
|
+
require "unit/external/example_source/world/scrap_world"
|
8
|
+
require "unit/external/example_source/world/seperate_light_from_darkness"
|
9
|
+
|
10
|
+
describe Stuka::ActionFinder do
|
11
|
+
|
12
|
+
let(:finder) { Stuka::ActionFinder.new }
|
13
|
+
let(:process) { double() }
|
14
|
+
|
15
|
+
before :each do
|
16
|
+
Stuka::StukaPaths::PROCESSES_SOURCE_PATH.replace "#{File.dirname(__FILE__)}/example_source"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "finds actions" do
|
20
|
+
gather_materials = finder.find_action("world::gather_materials", process)
|
21
|
+
expect(gather_materials.class).to be(World::GatherMaterials)
|
22
|
+
expect(gather_materials.process).to be(process)
|
23
|
+
|
24
|
+
scrap_world = finder.find_action("world::scrap_world", process)
|
25
|
+
expect(scrap_world.class).to be(World::ScrapWorld)
|
26
|
+
expect(scrap_world.process).to be(process)
|
27
|
+
|
28
|
+
seperate_light_from_darkness = finder.find_action("world::seperate_light_from_darkness", process)
|
29
|
+
expect(seperate_light_from_darkness.class).to be(World::SeperateLightFromDarkness)
|
30
|
+
expect(seperate_light_from_darkness.process).to be(process)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "throws an UnknownAction error if it can't find the action class" do
|
34
|
+
expect { finder.find_action("some::unknown_action", process) }.to raise_error(Stuka::UnknownAction)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "unit/external/example_source/create_world"
|
3
|
+
require "unit/external/process_interface"
|
4
|
+
require "stuka/external/business_process"
|
5
|
+
|
6
|
+
require "unit/external/example_source/world/gather_materials"
|
7
|
+
require "unit/external/example_source/world/scrap_world"
|
8
|
+
require "unit/external/example_source/world/seperate_light_from_darkness"
|
9
|
+
|
10
|
+
describe CreateWorld do
|
11
|
+
|
12
|
+
it_behaves_like "a process"
|
13
|
+
|
14
|
+
let(:stream) { double(puts: nil) }
|
15
|
+
let(:param2) { double(param_method: nil) }
|
16
|
+
|
17
|
+
let(:gather_materials) { double(process: process) }
|
18
|
+
let(:seperate_light_from_darkness) { double(process: process) }
|
19
|
+
let(:scrap_world) { double(process: process) }
|
20
|
+
|
21
|
+
|
22
|
+
let(:process) do
|
23
|
+
|
24
|
+
CreateWorld.new() do |on|
|
25
|
+
|
26
|
+
on.success {
|
27
|
+
puts "yay success"
|
28
|
+
}
|
29
|
+
on.failure {
|
30
|
+
puts "nay failure"
|
31
|
+
}
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
before :each do
|
38
|
+
|
39
|
+
allow(gather_materials).to receive(:run) { process.transition({stream: stream, param2: param2}, :success) }
|
40
|
+
allow(seperate_light_from_darkness).to receive(:run) { process.transition({stream: stream}, :failure) }
|
41
|
+
allow(scrap_world).to receive(:run) { process.transition({stream: stream}, :success) }
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
it "starts the process with BusinessProcess#run" do
|
46
|
+
|
47
|
+
expect(World::GatherMaterials).to receive(:new).and_return(gather_materials)
|
48
|
+
expect(World::SeperateLightFromDarkness).to receive(:new).and_return(seperate_light_from_darkness)
|
49
|
+
expect(World::ScrapWorld).to receive(:new).and_return(scrap_world)
|
50
|
+
|
51
|
+
expect(gather_materials).to receive(:run).with({stream: stream, param2: param2})
|
52
|
+
expect(seperate_light_from_darkness).to receive(:run).with({stream: stream, param2: param2})
|
53
|
+
expect(scrap_world).to receive(:run).with({stream: stream})
|
54
|
+
|
55
|
+
process.run({stream: stream, param2: param2})
|
56
|
+
|
57
|
+
expect(process.current_state).to eq Stuka::BusinessProcess::PROCESS_STATES[:finished]
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "example_source/create_world"
|
3
|
+
require "stuka/external/business_process"
|
4
|
+
|
5
|
+
describe "ExampleProcess" do
|
6
|
+
|
7
|
+
let(:dispatcher) { double(success: "", failure: "", can_end_with?: true) }
|
8
|
+
let(:process) do
|
9
|
+
|
10
|
+
CreateWorld.new(dispatcher: dispatcher) do |on|
|
11
|
+
|
12
|
+
on.success {
|
13
|
+
puts "yay success"
|
14
|
+
}
|
15
|
+
on.failure {
|
16
|
+
puts "nay failure"
|
17
|
+
}
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
before :each do
|
24
|
+
Stuka::StukaPaths::PROCESSES_SOURCE_PATH.replace "#{File.dirname(__FILE__)}/example_source"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "notifies the dispatcher of any other end event" do
|
28
|
+
expect(dispatcher).to receive(:can_end_with?).with(:failure)
|
29
|
+
expect(dispatcher).to receive(:call).with(:failure, {})
|
30
|
+
process.run({})
|
31
|
+
|
32
|
+
expect(process.current_state).to eq(Stuka::BusinessProcess::PROCESS_STATES[:finished])
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|