workflow_kit 0.0.1.apha
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/.gitignore +7 -0
- data/.rspec +1 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +153 -0
- data/Guardfile +22 -0
- data/MIT-LICENSE +22 -0
- data/README.md +53 -0
- data/Rakefile +42 -0
- data/app/assets/images/workflow_kit/.gitkeep +0 -0
- data/app/assets/javascripts/workflow_kit/application.js +15 -0
- data/app/assets/javascripts/workflow_kit/workflows.js +2 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/assets/stylesheets/workflow_kit/application.css +13 -0
- data/app/assets/stylesheets/workflow_kit/workflows.css +4 -0
- data/app/controllers/workflow_kit/application_controller.rb +5 -0
- data/app/controllers/workflow_kit/workflows_controller.rb +96 -0
- data/app/helpers/workflow_kit/application_helper.rb +4 -0
- data/app/helpers/workflow_kit/workflows_helper.rb +4 -0
- data/app/models/workflow_kit/brick.rb +45 -0
- data/app/models/workflow_kit/parameter.rb +34 -0
- data/app/models/workflow_kit/parameterable.rb +40 -0
- data/app/models/workflow_kit/step.rb +27 -0
- data/app/models/workflow_kit/workflow.rb +20 -0
- data/app/views/workflow_kit/workflows/_form.html.erb +25 -0
- data/app/views/workflow_kit/workflows/edit.html.erb +6 -0
- data/app/views/workflow_kit/workflows/index.html.erb +25 -0
- data/app/views/workflow_kit/workflows/new.html.erb +5 -0
- data/app/views/workflow_kit/workflows/show.html.erb +29 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20120721135535_create_workflow_kit_workflows.rb +10 -0
- data/db/migrate/20120721140135_create_workflow_kit_steps.rb +11 -0
- data/db/migrate/20120721140613_create_workflow_kit_parameters.rb +11 -0
- data/lib/tasks/workflow_kit_tasks.rake +4 -0
- data/lib/workflow_kit/engine.rb +6 -0
- data/lib/workflow_kit/version.rb +3 -0
- data/lib/workflow_kit.rb +4 -0
- data/script/rails +8 -0
- data/spec/models/brick_spec.rb +39 -0
- data/spec/models/parameter_spec.rb +69 -0
- data/spec/models/parameterable_spec.rb +58 -0
- data/spec/models/step_spec.rb +39 -0
- data/spec/models/workflow_spec.rb +38 -0
- data/spec/spec_helper.rb +43 -0
- data/spec/support/factory.rb +49 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/demo_app.css.sass +31 -0
- data/test/dummy/app/assets/stylesheets/nifty.css +79 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/error_messages_helper.rb +23 -0
- data/test/dummy/app/helpers/layout_helper.rb +22 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/message.rb +3 -0
- data/test/dummy/app/models/workflow_kit/brick_a.rb +12 -0
- data/test/dummy/app/models/workflow_kit/brick_b.rb +12 -0
- data/test/dummy/app/models/workflow_kit/brick_c.rb +12 -0
- data/test/dummy/app/models/workflow_kit/test_brick.rb +12 -0
- data/test/dummy/app/views/layouts/application.html.erb +18 -0
- data/test/dummy/app/views/workflow_kit/workflows/index.html.erb +48 -0
- data/test/dummy/config/application.rb +58 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +7 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20120721225047_create_messages.rb +9 -0
- data/test/dummy/db/schema.rb +46 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/messages.yml +7 -0
- data/test/dummy/test/unit/message_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/workflow_kit.gemspec +50 -0
- metadata +360 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module WorkflowKit
|
|
2
|
+
class Workflow < ActiveRecord::Base
|
|
3
|
+
|
|
4
|
+
attr_accessible :description, :name, :parameters
|
|
5
|
+
|
|
6
|
+
has_many :steps, dependent: :destroy, order: :sequence_index
|
|
7
|
+
|
|
8
|
+
extend WorkflowKit::Parameterable
|
|
9
|
+
has_many_parameters
|
|
10
|
+
|
|
11
|
+
def execute( params = {} )
|
|
12
|
+
params = {} unless params
|
|
13
|
+
params = params.merge( self.parameters_to_hash ) if self.parameters.count > 0
|
|
14
|
+
self.steps.collect do |step|
|
|
15
|
+
step.execute( params )
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<%= form_for(@workflow) do |f| %>
|
|
2
|
+
<% if @workflow.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@workflow.errors.count, "error") %> prohibited this workflow from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @workflow.errors.full_messages.each do |msg| %>
|
|
8
|
+
<li><%= msg %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="field">
|
|
15
|
+
<%= f.label :name %><br />
|
|
16
|
+
<%= f.text_field :name %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="field">
|
|
19
|
+
<%= f.label :description %><br />
|
|
20
|
+
<%= f.text_area :description %>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="actions">
|
|
23
|
+
<%= f.submit %>
|
|
24
|
+
</div>
|
|
25
|
+
<% end %>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<h1>Listing workflows</h1>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Name</th>
|
|
6
|
+
<th>Description</th>
|
|
7
|
+
<th></th>
|
|
8
|
+
<th></th>
|
|
9
|
+
<th></th>
|
|
10
|
+
</tr>
|
|
11
|
+
|
|
12
|
+
<% @workflows.each do |workflow| %>
|
|
13
|
+
<tr>
|
|
14
|
+
<td><%= workflow.name %></td>
|
|
15
|
+
<td><%= workflow.description %></td>
|
|
16
|
+
<td><%= link_to 'Show', workflow %></td>
|
|
17
|
+
<td><%= link_to 'Edit', edit_workflow_path(workflow) %></td>
|
|
18
|
+
<td><%= link_to 'Destroy', workflow, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
|
19
|
+
</tr>
|
|
20
|
+
<% end %>
|
|
21
|
+
</table>
|
|
22
|
+
|
|
23
|
+
<br />
|
|
24
|
+
|
|
25
|
+
<%= link_to 'New Workflow', new_workflow_path %>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
|
2
|
+
|
|
3
|
+
<h1>Workflow: <%=h @workflow.name %></h1>
|
|
4
|
+
|
|
5
|
+
<p>
|
|
6
|
+
<b>Name:</b>
|
|
7
|
+
<%=h @workflow.name %>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p>
|
|
11
|
+
<b>Description:</b>
|
|
12
|
+
<%=h @workflow.description %>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<h2>Steps to Execute</h2>
|
|
16
|
+
|
|
17
|
+
<div class="workflow_steps">
|
|
18
|
+
<ol>
|
|
19
|
+
<% for step in @workflow.steps %>
|
|
20
|
+
<li>
|
|
21
|
+
<span class="brick-name"><%= step.brick.name %></span>
|
|
22
|
+
<span class="brick-description"><%= step.brick.description %></span>
|
|
23
|
+
</li>
|
|
24
|
+
<% end %>
|
|
25
|
+
</ol>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<%= link_to 'Edit', edit_workflow_path(@workflow) %> |
|
|
29
|
+
<%= link_to 'Back', workflows_path %>
|
data/config/routes.rb
ADDED
data/lib/workflow_kit.rb
ADDED
data/script/rails
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/workflow_kit/engine', __FILE__)
|
|
6
|
+
|
|
7
|
+
require 'rails/all'
|
|
8
|
+
require 'rails/engine/commands'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe WorkflowKit::Brick do
|
|
5
|
+
|
|
6
|
+
describe "Instance" do
|
|
7
|
+
|
|
8
|
+
before { @boil_water_brick = WorkflowKit::BoilWaterBrick.new } # in spec/support/factory.rb
|
|
9
|
+
subject { @boil_water_brick }
|
|
10
|
+
|
|
11
|
+
it { should respond_to( :name ) }
|
|
12
|
+
it { should respond_to( :description ) }
|
|
13
|
+
|
|
14
|
+
describe "#execute" do
|
|
15
|
+
it "should execute the brick" do
|
|
16
|
+
@boil_water_brick.execute( :aim_temperature => "100 °C" ).should ==
|
|
17
|
+
"Fill a large pot with water, put it on a cooker and wait until a temperature of 100 °C is reached."
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "Class" do
|
|
24
|
+
|
|
25
|
+
subject { WorkflowKit::Brick }
|
|
26
|
+
|
|
27
|
+
describe ".all" do
|
|
28
|
+
subject { WorkflowKit::Brick.all }
|
|
29
|
+
it "should list all inherited classes, i.e. the different kind of WorkflowBricks" do
|
|
30
|
+
subject.should ==
|
|
31
|
+
[WorkflowKit::BoilWaterBrick, WorkflowKit::BoilSpaghettiBrick, WorkflowKit::ServeSpaghettiBrick]
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe WorkflowKit::Parameter do
|
|
4
|
+
|
|
5
|
+
describe "Instance" do
|
|
6
|
+
|
|
7
|
+
before { @parameter = WorkflowKit::Parameter.new }
|
|
8
|
+
subject { @parameter }
|
|
9
|
+
|
|
10
|
+
it { should respond_to( :key ) }
|
|
11
|
+
it { should respond_to( :key= ) }
|
|
12
|
+
it { should respond_to( :value ) }
|
|
13
|
+
it { should respond_to( :value= ) }
|
|
14
|
+
|
|
15
|
+
describe "#value" do
|
|
16
|
+
describe "for numbers" do
|
|
17
|
+
it "should return an integer" do
|
|
18
|
+
subject.value = "123"
|
|
19
|
+
subject.value.should be_kind_of( Integer )
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
describe "for strings" do
|
|
23
|
+
it "should return a string" do
|
|
24
|
+
subject.value = "abc"
|
|
25
|
+
subject.value.should be_kind_of( String )
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
describe "for bools" do
|
|
29
|
+
it "should return a boolean" do
|
|
30
|
+
subject.value = "true"
|
|
31
|
+
subject.value.should be_kind_of( TrueClass )
|
|
32
|
+
subject.value = "false"
|
|
33
|
+
subject.value.should be_kind_of( FalseClass ) # there is no Boolean in Ruby.
|
|
34
|
+
# see: http://stackoverflow.com/questions/3192978/why-does-ruby-have-trueclass-and-falseclass-instead-of-a-single-boolean-class
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "#to_hash" do
|
|
40
|
+
before { @parameter = WorkflowKit::Parameter.new( key: "KEY", value: "VALUE" ) }
|
|
41
|
+
subject { @parameter.to_hash }
|
|
42
|
+
it { should == { :KEY => "VALUE" } }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "Class" do
|
|
48
|
+
|
|
49
|
+
subject { WorkflowKit::Parameter }
|
|
50
|
+
|
|
51
|
+
describe ".to_hash( parameters )" do
|
|
52
|
+
|
|
53
|
+
before do
|
|
54
|
+
@parameters = [ WorkflowKit::Parameter.new( key: "first_key", value: "first_value" ),
|
|
55
|
+
WorkflowKit::Parameter.new( key: "second_key", value: "second_value" ) ]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
subject { WorkflowKit::Parameter.to_hash }
|
|
59
|
+
|
|
60
|
+
it "should return a hash of parameters" do
|
|
61
|
+
WorkflowKit::Parameter.to_hash( @parameters ).should ==
|
|
62
|
+
{ first_key: "first_value", second_key: "second_value" }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe WorkflowKit::Parameterable do
|
|
4
|
+
|
|
5
|
+
describe "Class" do
|
|
6
|
+
|
|
7
|
+
subject { WorkflowKit::Workflow } # since this class extends WorkflowKit::Parameterable
|
|
8
|
+
|
|
9
|
+
it { should respond_to ( :has_many_parameters ) }
|
|
10
|
+
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "Instance" do
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
@parameterable = WorkflowKit::Workflow.new # since workflows as parameterable, i.e. can have parameters
|
|
17
|
+
@parameterable.parameters = { test_key: "test_value" }
|
|
18
|
+
end
|
|
19
|
+
subject { @parameterable }
|
|
20
|
+
|
|
21
|
+
describe "#parameters" do
|
|
22
|
+
subject { @parameterable.parameters }
|
|
23
|
+
it { should be_kind_of( Array ) }
|
|
24
|
+
its( :first ) { should be_kind_of WorkflowKit::Parameter }
|
|
25
|
+
its( 'first.key' ) { should == :test_key }
|
|
26
|
+
its( 'first.value' ) { should == "test_value" }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "#parameters_to_hash" do
|
|
30
|
+
subject { @parameterable.parameters_to_hash }
|
|
31
|
+
it { should be_kind_of( Hash ) }
|
|
32
|
+
it { should == { test_key: "test_value" } }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "#parameter_hash" do
|
|
36
|
+
subject { @parameterable.parameter_hash }
|
|
37
|
+
it { should == @parameterable.parameters_to_hash }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "#parameters=" do
|
|
41
|
+
it "should transform a parameter hash into WorkflowKit::Parameter objects" do
|
|
42
|
+
@parameterable.parameters = { first_key: "first_value", second_key: "second_value" }
|
|
43
|
+
@parameterable.parameters.should be_kind_of( Array )
|
|
44
|
+
@parameterable.parameters.first.should be_kind_of( WorkflowKit::Parameter )
|
|
45
|
+
@parameterable.parameters.first.key.should == :first_key
|
|
46
|
+
end
|
|
47
|
+
it "should also accept WorkflowKit::Parameter objects" do
|
|
48
|
+
@parameterable.parameters =
|
|
49
|
+
[ WorkflowKit::Parameter.new( key: :first_key, value: "first_value" ) ]
|
|
50
|
+
@parameterable.parameters.should be_kind_of( Array )
|
|
51
|
+
@parameterable.parameters.first.should be_kind_of( WorkflowKit::Parameter )
|
|
52
|
+
@parameterable.parameters.first.key.should == :first_key
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe WorkflowKit::Step do
|
|
5
|
+
|
|
6
|
+
before do
|
|
7
|
+
@workflow = create_workflow # in spec/support/factory.rb
|
|
8
|
+
@step = @workflow.steps.first
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
subject { @step }
|
|
12
|
+
|
|
13
|
+
it { should respond_to( :sequence_index ) }
|
|
14
|
+
it { should respond_to( :sequence_index= ) }
|
|
15
|
+
it { should respond_to( :brick_name ) }
|
|
16
|
+
it { should respond_to( :brick_name= ) }
|
|
17
|
+
it { should respond_to( :parameters ) }
|
|
18
|
+
|
|
19
|
+
describe "#workflow" do
|
|
20
|
+
subject { @step.workflow }
|
|
21
|
+
it { should == @workflow }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "#execute" do
|
|
25
|
+
subject { @step.execute }
|
|
26
|
+
it "should execute the step" do
|
|
27
|
+
subject.should ==
|
|
28
|
+
"Fill a large pot with water, put it on a cooker and wait until a temperature of 100 °C is reached."
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "#brick" do
|
|
33
|
+
subject { @step.brick }
|
|
34
|
+
it { should be_kind_of( WorkflowKit::Brick ) }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe WorkflowKit::Workflow do
|
|
5
|
+
|
|
6
|
+
before { @workflow = WorkflowKit::Factory.create_workflow } # in spec/support/factory.rb
|
|
7
|
+
subject { @workflow }
|
|
8
|
+
|
|
9
|
+
for method in [ :name, :name=, :description, :description= ]
|
|
10
|
+
it { should respond_to( method ) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#steps" do
|
|
14
|
+
subject { @workflow.steps }
|
|
15
|
+
it "should list the sequence entries" do
|
|
16
|
+
subject.count.should == 3
|
|
17
|
+
end
|
|
18
|
+
it { should be_kind_of( Array ) }
|
|
19
|
+
its( :first ) { should be_kind_of( WorkflowKit::Step ) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "#execute" do
|
|
23
|
+
|
|
24
|
+
it "should produce the proper recipe" do # according to spec/support/factory.rb
|
|
25
|
+
subject.execute.join( " " ).should ==
|
|
26
|
+
"Fill a large pot with water, put it on a cooker and wait until a temperature of 100 °C is reached. " +
|
|
27
|
+
"Add spaghetti and boil them for 10 minutes. Sieve spaghetti, put them on a plate, and serve them with " +
|
|
28
|
+
"some yummy ham-cheese-cream sauce."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should accept a parameter hash" do
|
|
32
|
+
subject.execute( a: 1, b: 2, c: "3" ).should_not be_nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
|
3
|
+
|
|
4
|
+
require File.expand_path("../../test/dummy/config/environment", __FILE__)
|
|
5
|
+
|
|
6
|
+
require 'workflow_kit'
|
|
7
|
+
require 'rails/all'
|
|
8
|
+
|
|
9
|
+
require 'rspec/rails'
|
|
10
|
+
require 'rspec/autorun'
|
|
11
|
+
|
|
12
|
+
require 'support/factory'
|
|
13
|
+
include WorkflowKit::Factory
|
|
14
|
+
|
|
15
|
+
#require '../app/models/workflow_kit/parameterable'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
19
|
+
# in spec/support/ and its subdirectories.
|
|
20
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
|
21
|
+
|
|
22
|
+
RSpec.configure do |config|
|
|
23
|
+
# ## Mock Framework
|
|
24
|
+
#
|
|
25
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
26
|
+
#
|
|
27
|
+
# config.mock_with :mocha
|
|
28
|
+
# config.mock_with :flexmock
|
|
29
|
+
# config.mock_with :rr
|
|
30
|
+
|
|
31
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
32
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
33
|
+
|
|
34
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
35
|
+
# examples within a transaction, remove the following line or assign false
|
|
36
|
+
# instead of true.
|
|
37
|
+
config.use_transactional_fixtures = true
|
|
38
|
+
|
|
39
|
+
# If true, the base class of anonymous controllers will be inferred
|
|
40
|
+
# automatically. This will be the default behavior in future versions of
|
|
41
|
+
# rspec-rails.
|
|
42
|
+
config.infer_base_class_for_anonymous_controllers = false
|
|
43
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
module WorkflowKit
|
|
3
|
+
module Factory
|
|
4
|
+
|
|
5
|
+
def create_workflow
|
|
6
|
+
workflow = Workflow.create( name: "Cook Spaghetti",
|
|
7
|
+
description: "An example workflow to demonstrate how to use workflows in the `workflow_kit` gem." )
|
|
8
|
+
|
|
9
|
+
workflow.steps.create( brick_name: "BoilWaterBrick", parameters: { :aim_temperature => '100 °C' } )
|
|
10
|
+
workflow.steps.create( brick_name: "BoilSpaghettiBrick", parameters: { :time_to_boil => '10 minutes' } )
|
|
11
|
+
workflow.steps.create( brick_name: "ServeSpaghettiBrick" )
|
|
12
|
+
|
|
13
|
+
return workflow
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class BoilWaterBrick < Brick
|
|
19
|
+
def description
|
|
20
|
+
"Fill a large pot with water, put it on a cooker " +
|
|
21
|
+
"and wait until the given temperature is reached."
|
|
22
|
+
end
|
|
23
|
+
def execute( params )
|
|
24
|
+
return self.description
|
|
25
|
+
.gsub( "the given temperature", "a temperature of " + params[ :aim_temperature ] )
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class BoilSpaghettiBrick < Brick
|
|
30
|
+
def description
|
|
31
|
+
"Add spaghetti and boil them for the given time."
|
|
32
|
+
end
|
|
33
|
+
def execute( params )
|
|
34
|
+
return self.description
|
|
35
|
+
.gsub( "the given time", params[ :time_to_boil ] )
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class ServeSpaghettiBrick < Brick
|
|
40
|
+
def description
|
|
41
|
+
"Sieve spaghetti, put them on a plate, and serve them with " +
|
|
42
|
+
"some yummy ham-cheese-cream sauce."
|
|
43
|
+
end
|
|
44
|
+
def execute( params )
|
|
45
|
+
return self.description
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|