rules_engine 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/VERSION +1 -1
  2. data/lib/rules_engine.rb +2 -2
  3. data/lib/rules_engine/discovery.rb +1 -1
  4. data/lib/rules_engine/process/runner.rb +3 -3
  5. data/lib/rules_engine/rule/definition.rb +85 -0
  6. data/lib/rules_engine/rule/outcome.rb +19 -0
  7. data/rails_generators/manifests/complex.rb +30 -0
  8. data/rails_generators/manifests/complex.yml +24 -0
  9. data/rails_generators/manifests/simple.rb +26 -0
  10. data/rails_generators/manifests/simple.yml +21 -0
  11. data/rails_generators/rules_engine_generator.rb +2 -2
  12. data/rails_generators/templates/app/models/re_rule.rb +4 -4
  13. data/rails_generators/templates/app/models/re_rule_expected_outcome.rb +1 -1
  14. data/rails_generators/templates/app/rules/complex.rb +133 -0
  15. data/rails_generators/templates/app/rules/simple.rb +83 -0
  16. data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_edit.html.erb +0 -0
  17. data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_help.html.erb +0 -0
  18. data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_new.html.erb +0 -0
  19. data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_script.html.erb +0 -0
  20. data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_title.html.erb +0 -0
  21. data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_word.html.erb +0 -0
  22. data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_words.html.erb +0 -0
  23. data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_workflow.html.erb +0 -0
  24. data/rails_generators/templates/app/views/re_rule_definitions/simple/_edit.html.erb +1 -0
  25. data/rails_generators/templates/app/views/re_rule_definitions/simple/_form.html.erb +16 -0
  26. data/rails_generators/templates/app/views/re_rule_definitions/simple/_help.html.erb +1 -0
  27. data/rails_generators/templates/app/views/re_rule_definitions/simple/_new.html.erb +1 -0
  28. data/rails_generators/templates/doc/README.rules_engine +1 -1
  29. data/rails_generators/templates/spec/lib/rules/{rule_complex_spec.rb → complex_spec.rb} +30 -30
  30. data/rails_generators/templates/spec/lib/rules/simple_spec.rb +161 -0
  31. data/rails_generators/templates/spec/models/re_rule_expected_outcome_spec.rb +3 -3
  32. data/rails_generators/templates/spec/models/re_rule_spec.rb +11 -11
  33. data/spec/railsenv/app/rules/mock_rule.rb +9 -10
  34. data/spec/railsenv/log/debug.log +1356 -0
  35. data/spec/railsenv/log/test.log +78 -0
  36. data/spec/rules_engine/discovery_spec.rb +17 -7
  37. data/spec/rules_engine/process/runner_spec.rb +8 -8
  38. data/spec/rules_engine/{rule_spec.rb → rule/definition_spec.rb} +17 -17
  39. metadata +27 -27
  40. data/lib/rules_engine/rule.rb +0 -84
  41. data/lib/rules_engine/rule_outcome.rb +0 -17
  42. data/rails_generators/manifests/rule_complex.rb +0 -30
  43. data/rails_generators/manifests/rule_complex.yml +0 -24
  44. data/rails_generators/manifests/rule_simple.rb +0 -26
  45. data/rails_generators/manifests/rule_simple.yml +0 -21
  46. data/rails_generators/templates/app/rules/rule_complex.rb +0 -130
  47. data/rails_generators/templates/app/rules/rule_simple.rb +0 -79
  48. data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_edit.html.erb +0 -1
  49. data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_form.html.erb +0 -16
  50. data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_help.html.erb +0 -1
  51. data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_new.html.erb +0 -1
  52. data/rails_generators/templates/spec/lib/rules/rule_simple_spec.rb +0 -161
@@ -0,0 +1 @@
1
+ <%%= render '/re_rule_definitions/rule_<%=rule_name%>/form' %>
@@ -0,0 +1,16 @@
1
+ <%%= re_text_field "Simple Title",
2
+ "rule_<%=rule_name%>_title",
3
+ params[:rule_<%=rule_name%>_title] || @re_rule.rule.title,
4
+ :size => 30,
5
+ :required => true,
6
+ :error => @re_rule.rule.errors[:rule_<%=rule_name%>_title],
7
+ :span => '4x13' %>
8
+
9
+
10
+ <%%= re_text_field "Description",
11
+ "rule_<%=rule_name%>_description",
12
+ params[:rule_<%=rule_name%>_description] || @re_rule.rule.description,
13
+ :size => 40,
14
+ :required => false,
15
+ :error => @re_rule.rule.errors[:rule_<%=rule_name%>_description],
16
+ :span => '4x13' %>
@@ -0,0 +1 @@
1
+ <p> Simple : This rule does nothing </p>
@@ -0,0 +1 @@
1
+ <%%= render '/re_rule_definitions/rule_<%=rule_name%>/form' %>
@@ -150,7 +150,7 @@ class ApplicationController < ActionController::Base
150
150
 
151
151
  ######################################
152
152
  # 9. Create a Complex Rule
153
- ./script/generate rules_engine rule_complex match_words
153
+ ./script/generate rules_engine complex match_words
154
154
 
155
155
  ######################################
156
156
  # 10. Run the Tests
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
- describe <%=rule_class%> do
3
+ describe RulesEngine::Rule::<%=rule_class%> do
4
4
 
5
5
  def valid_attributes
6
6
  {
@@ -17,34 +17,34 @@ describe <%=rule_class%> do
17
17
  end
18
18
 
19
19
  it "should be discoverable" do
20
- RulesEngine::Discovery.rule_class("<%=rule_class%>").should == <%=rule_class%>
20
+ RulesEngine::Discovery.rule_class("RulesEngine::Rule::<%=rule_class%>").should == RulesEngine::Rule::<%=rule_class%>
21
21
  end
22
22
 
23
23
  describe "the expected class options" do
24
24
  it "should be in the 'General' group" do
25
- <%=rule_class%>.options[:group].should == "General"
25
+ RulesEngine::Rule::<%=rule_class%>.options[:group].should == "General"
26
26
  end
27
27
 
28
- it "should have the diplay name of '<%=rule_class%> Rule'" do
29
- <%=rule_class%>.options[:display_name].should == "<%=rule_class%> Rule"
28
+ it "should have the diplay name of '<%=rule_class%>'" do
29
+ RulesEngine::Rule::<%=rule_class%>.options[:display_name].should == "<%=rule_class%>"
30
30
  end
31
31
 
32
32
  it "should have the help template of '/re_rule_definitions/<%=rule_name%>/help'" do
33
- <%=rule_class%>.options[:help_partial].should == '/re_rule_definitions/<%=rule_name%>/help'
33
+ RulesEngine::Rule::<%=rule_class%>.options[:help_partial].should == '/re_rule_definitions/<%=rule_name%>/help'
34
34
  end
35
35
 
36
36
  it "should have the new template of '/re_rule_definitions/<%=rule_name%>/new'" do
37
- <%=rule_class%>.options[:new_partial].should == '/re_rule_definitions/<%=rule_name%>/new'
37
+ RulesEngine::Rule::<%=rule_class%>.options[:new_partial].should == '/re_rule_definitions/<%=rule_name%>/new'
38
38
  end
39
39
 
40
40
  it "should have the edit view partial template of '/re_rule_definitions/<%=rule_name%>/edit'" do
41
- <%=rule_class%>.options[:edit_partial].should == '/re_rule_definitions/<%=rule_name%>/edit'
41
+ RulesEngine::Rule::<%=rule_class%>.options[:edit_partial].should == '/re_rule_definitions/<%=rule_name%>/edit'
42
42
  end
43
43
  end
44
44
 
45
45
  describe "setting the rule data" do
46
46
  before(:each) do
47
- @<%=rule_name%> = <%=rule_class%>.new
47
+ @<%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
48
48
  @<%=rule_name%>.data = valid_json_data
49
49
  end
50
50
 
@@ -99,13 +99,13 @@ describe <%=rule_class%> do
99
99
 
100
100
  describe "the summary" do
101
101
  it "should be singluar if there is one word" do
102
- <%=rule_name%> = <%=rule_class%>.new
102
+ <%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
103
103
  <%=rule_name%>.stub!(:words).and_return(["one"])
104
104
  <%=rule_name%>.summary.should == "Match the word one"
105
105
  end
106
106
 
107
107
  it "should be plural if there are multiple words" do
108
- <%=rule_name%> = <%=rule_class%>.new
108
+ <%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
109
109
  <%=rule_name%>.stub!(:words).and_return(["one", "two", "three"])
110
110
  <%=rule_name%>.summary.should == "Match the words one, two, three"
111
111
  end
@@ -113,7 +113,7 @@ describe <%=rule_class%> do
113
113
 
114
114
  describe "the data" do
115
115
  it "should be converted to a json string" do
116
- <%=rule_name%> = <%=rule_class%>.new
116
+ <%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
117
117
  <%=rule_name%>.should_receive(:title).and_return(["mock title"])
118
118
  <%=rule_name%>.should_receive(:words).and_return(["one", "two"])
119
119
  <%=rule_name%>.should_receive(:workflow_action).and_return(["workflow action"])
@@ -124,41 +124,41 @@ describe <%=rule_class%> do
124
124
 
125
125
  describe "the expected_outcomes" do
126
126
  it "should be next" do
127
- <%=rule_name%> = <%=rule_class%>.new
127
+ <%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
128
128
  <%=rule_name%>.should_receive(:workflow_action).and_return('next')
129
- <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::RuleOutcome::OUTCOME_NEXT]
129
+ <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::Rule::Outcome::NEXT]
130
130
  end
131
131
 
132
132
  it "should be stop success" do
133
- <%=rule_name%> = <%=rule_class%>.new
133
+ <%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
134
134
  <%=rule_name%>.should_receive(:workflow_action).and_return('stop_success')
135
- <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS]
135
+ <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::Rule::Outcome::STOP_SUCCESS]
136
136
  end
137
137
 
138
138
  it "should be stop failure" do
139
- <%=rule_name%> = <%=rule_class%>.new
139
+ <%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
140
140
  <%=rule_name%>.should_receive(:workflow_action).and_return('stop_failure')
141
- <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE]
141
+ <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::Rule::Outcome::STOP_FAILURE]
142
142
  end
143
143
 
144
144
  it "should be start workflow" do
145
- <%=rule_name%> = <%=rule_class%>.new
145
+ <%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
146
146
  <%=rule_name%>.should_receive(:workflow_action).and_return('start_workflow')
147
147
  <%=rule_name%>.should_receive(:workflow).and_return('mock workflow')
148
- <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW, :workflow_code => "mock workflow"]
148
+ <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::Rule::Outcome::START_WORKFLOW, :workflow_code => "mock workflow"]
149
149
  end
150
150
 
151
151
  it "should be next be default" do
152
- <%=rule_name%> = <%=rule_class%>.new
152
+ <%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
153
153
  <%=rule_name%>.should_receive(:workflow_action).and_return('this is not valid')
154
- <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::RuleOutcome::OUTCOME_NEXT]
154
+ <%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::Rule::Outcome::NEXT]
155
155
  end
156
156
 
157
157
  end
158
158
 
159
159
  describe "setting the rule attributes" do
160
160
  before(:each) do
161
- @<%=rule_name%> = <%=rule_class%>.new
161
+ @<%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
162
162
  end
163
163
 
164
164
  it "should be valid with valid attributes" do
@@ -272,16 +272,16 @@ describe <%=rule_class%> do
272
272
 
273
273
  describe "processing the rule" do
274
274
  before(:each) do
275
- @<%=rule_name%> = <%=rule_class%>.new
275
+ @<%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
276
276
  @<%=rule_name%>.stub!(:words).and_return(["found", "word"])
277
277
  end
278
278
 
279
279
  it "should do nothing if there is no tweet" do
280
- @<%=rule_name%>.process(1001, {}).outcome.should == RulesEngine::RuleOutcome::OUTCOME_NEXT
280
+ @<%=rule_name%>.process(1001, {}).outcome.should == RulesEngine::Rule::Outcome::NEXT
281
281
  end
282
282
 
283
283
  it "should do nothing if there is no match" do
284
- @<%=rule_name%>.process(@job, {:tweet => "not here"}).outcome.should == RulesEngine::RuleOutcome::OUTCOME_NEXT
284
+ @<%=rule_name%>.process(@job, {:tweet => "not here"}).outcome.should == RulesEngine::Rule::Outcome::NEXT
285
285
  end
286
286
 
287
287
  describe "a match found" do
@@ -305,24 +305,24 @@ describe <%=rule_class%> do
305
305
  describe "matching workflow actions" do
306
306
  it "should return next" do
307
307
  @<%=rule_name%>.should_receive(:workflow_action).and_return('next')
308
- @<%=rule_name%>.process(1001, @matched_data).outcome.should == RulesEngine::RuleOutcome::OUTCOME_NEXT
308
+ @<%=rule_name%>.process(1001, @matched_data).outcome.should == RulesEngine::Rule::Outcome::NEXT
309
309
  end
310
310
 
311
311
  it "should return stop_success" do
312
312
  @<%=rule_name%>.should_receive(:workflow_action).and_return('stop_success')
313
- @<%=rule_name%>.process(1001, @matched_data).outcome.should == RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS
313
+ @<%=rule_name%>.process(1001, @matched_data).outcome.should == RulesEngine::Rule::Outcome::STOP_SUCCESS
314
314
  end
315
315
 
316
316
  it "should return stop_failure" do
317
317
  @<%=rule_name%>.should_receive(:workflow_action).and_return('stop_failure')
318
- @<%=rule_name%>.process(1001, @matched_data).outcome.should == RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE
318
+ @<%=rule_name%>.process(1001, @matched_data).outcome.should == RulesEngine::Rule::Outcome::STOP_FAILURE
319
319
  end
320
320
 
321
321
  it "should return start workflow with the workflow_code" do
322
322
  @<%=rule_name%>.should_receive(:workflow_action).and_return('start_workflow')
323
323
  @<%=rule_name%>.should_receive(:workflow).and_return('mock_workflow')
324
324
  <%=rule_name%>_outcome = @<%=rule_name%>.process(1001, @matched_data)
325
- <%=rule_name%>_outcome.outcome.should == RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW
325
+ <%=rule_name%>_outcome.outcome.should == RulesEngine::Rule::Outcome::START_WORKFLOW
326
326
  <%=rule_name%>_outcome.workflow_code.should == "mock_workflow"
327
327
  end
328
328
  end
@@ -0,0 +1,161 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe RulesEngine::Rule::Simple do
4
+
5
+ def valid_attributes
6
+ {
7
+ :rule_<%=rule_name%>_title => 'Valid Title'
8
+ # :rule_<%=rule_name%>_description => 'Valid Description'
9
+ }
10
+ end
11
+
12
+ def valid_json_data
13
+ '["Valid Title", "Valid Description"]'
14
+ end
15
+
16
+ it "should be discoverable" do
17
+ RulesEngine::Discovery.rule_class("RulesEngine::Rule::Simple").should == RulesEngine::Rule::Simple
18
+ end
19
+
20
+ describe "the expected class options" do
21
+ it "should be in the 'General' group" do
22
+ RulesEngine::Rule::Simple.options[:group].should == "General"
23
+ end
24
+
25
+ it "should have the diplay name of 'Simple'" do
26
+ RulesEngine::Rule::Simple.options[:display_name].should == "Simple"
27
+ end
28
+
29
+ it "should have the help template of '/re_rule_definitions/rule_<%=rule_name%>/help'" do
30
+ RulesEngine::Rule::Simple.options[:help_partial].should == '/re_rule_definitions/rule_<%=rule_name%>/help'
31
+ end
32
+
33
+ it "should have the new template of '/re_rule_definitions/rule_<%=rule_name%>/new'" do
34
+ RulesEngine::Rule::Simple.options[:new_partial].should == '/re_rule_definitions/rule_<%=rule_name%>/new'
35
+ end
36
+
37
+ it "should have the edit view partial template of '/re_rule_definitions/rule_<%=rule_name%>/edit'" do
38
+ RulesEngine::Rule::Simple.options[:edit_partial].should == '/re_rule_definitions/rule_<%=rule_name%>/edit'
39
+ end
40
+ end
41
+
42
+ describe "setting the rule data" do
43
+ before(:each) do
44
+ @rule_<%=rule_name%> = RulesEngine::Rule::Simple.new
45
+ @rule_<%=rule_name%>.data = valid_json_data
46
+ end
47
+
48
+ describe "the data is valid" do
49
+ it "should be valid" do
50
+ @rule_<%=rule_name%>.should be_valid
51
+ end
52
+
53
+ it "should set the title" do
54
+ @rule_<%=rule_name%>.title.should == "Valid Title"
55
+ end
56
+
57
+ it "should set the description" do
58
+ @rule_<%=rule_name%>.description.should == "Valid Description"
59
+ end
60
+ end
61
+
62
+ describe "the data is nil" do
63
+ it "should set the title to nil" do
64
+ @rule_<%=rule_name%>.title.should_not be_nil
65
+ @rule_<%=rule_name%>.data = nil
66
+ @rule_<%=rule_name%>.title.should be_nil
67
+ end
68
+
69
+ it "should set the description to nil" do
70
+ @rule_<%=rule_name%>.title.should_not be_nil
71
+ @rule_<%=rule_name%>.data = nil
72
+ @rule_<%=rule_name%>.description.should be_nil
73
+ end
74
+ end
75
+ end
76
+
77
+ describe "the summary" do
78
+ describe "description set" do
79
+ it "should be the rule description" do
80
+ rule_<%=rule_name%> = RulesEngine::Rule::Simple.new
81
+ rule_<%=rule_name%>.should_receive(:description).and_return("mock description")
82
+ rule_<%=rule_name%>.summary.should == "mock description"
83
+ end
84
+ end
85
+ describe "description not set" do
86
+ it "should be Does Nothing" do
87
+ rule_<%=rule_name%> = RulesEngine::Rule::Simple.new
88
+ rule_<%=rule_name%>.should_receive(:description).and_return(nil)
89
+ rule_<%=rule_name%>.summary.should == "Does Nothing"
90
+ end
91
+ end
92
+ end
93
+
94
+ describe "the data" do
95
+ it "should be converted to a json string" do
96
+ rule_<%=rule_name%> = RulesEngine::Rule::Simple.new
97
+ rule_<%=rule_name%>.should_receive(:title).and_return("mock title")
98
+ rule_<%=rule_name%>.should_receive(:description).and_return("mock description")
99
+ rule_<%=rule_name%>.data.should == '["mock title","mock description"]'
100
+ end
101
+ end
102
+
103
+ describe "the expected_outcomes" do
104
+ it "should be outcome next" do
105
+ rule_<%=rule_name%> = RulesEngine::Rule::Simple.new
106
+ rule_<%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::Rule::Outcome::NEXT]
107
+ end
108
+ end
109
+
110
+ describe "setting the rule attributes" do
111
+ before(:each) do
112
+ @rule_<%=rule_name%> = RulesEngine::Rule::Simple.new
113
+ end
114
+
115
+ it "should be valid with valid attributes" do
116
+ @rule_<%=rule_name%>.attributes = valid_attributes
117
+ @rule_<%=rule_name%>.should be_valid
118
+ end
119
+
120
+ describe "setting the rule_<%=rule_name%>_title" do
121
+ it "should set the title" do
122
+ @rule_<%=rule_name%>.attributes = valid_attributes
123
+ @rule_<%=rule_name%>.title.should == 'Valid Title'
124
+ end
125
+
126
+ it "should not be valid if the 'rule_<%=rule_name%>_title' attribute is missing" do
127
+ @rule_<%=rule_name%>.attributes = valid_attributes.except(:rule_<%=rule_name%>_title)
128
+ @rule_<%=rule_name%>.should_not be_valid
129
+ @rule_<%=rule_name%>.errors.should include(:rule_<%=rule_name%>_title)
130
+ end
131
+
132
+ it "should not be valid if the 'rule_<%=rule_name%>_title' attribute is blank" do
133
+ @rule_<%=rule_name%>.attributes = valid_attributes.merge(:rule_<%=rule_name%>_title => "")
134
+ @rule_<%=rule_name%>.should_not be_valid
135
+ @rule_<%=rule_name%>.errors.should include(:rule_<%=rule_name%>_title)
136
+ end
137
+ end
138
+
139
+ describe "setting the rule_<%=rule_name%>_description" do
140
+ it "should set the description" do
141
+ @rule_<%=rule_name%>.attributes = valid_attributes.merge(:rule_<%=rule_name%>_description => 'Valid Description')
142
+ @rule_<%=rule_name%>.description.should == 'Valid Description'
143
+ end
144
+ end
145
+ end
146
+
147
+ describe "after a rule is created" do
148
+ # xit "There is nothing to do here"
149
+ end
150
+
151
+ describe "after a rule is created" do
152
+ # xit "There is nothing to do here"
153
+ end
154
+
155
+ describe "processing the rule" do
156
+ it "should do nothing" do
157
+ @rule_<%=rule_name%> = RulesEngine::Rule::Simple.new
158
+ @rule_<%=rule_name%>.process(1001, {}).outcome.should == RulesEngine::Rule::Outcome::NEXT
159
+ end
160
+ end
161
+ end
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
3
  describe ReRuleExpectedOutcome do
4
4
  def valid_attributes
5
5
  {
6
- :outcome => RulesEngine::RuleOutcome::OUTCOME_NEXT
6
+ :outcome => RulesEngine::Rule::Outcome::NEXT
7
7
  }
8
8
  end
9
9
 
@@ -15,13 +15,13 @@ describe ReRuleExpectedOutcome do
15
15
 
16
16
  describe "START WORKFLOW" do
17
17
  it "should be invalid when the outcome workflow code is blank" do
18
- re_rule_expected_outcome = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
18
+ re_rule_expected_outcome = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::START_WORKFLOW)
19
19
  re_rule_expected_outcome.should_not be_valid
20
20
  re_rule_expected_outcome.errors.on(:workflow_code).should_not be_blank
21
21
  end
22
22
 
23
23
  it "should be valid when outcome workflow code is present" do
24
- re_rule_expected_outcome = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW, :workflow_code => "mock code")
24
+ re_rule_expected_outcome = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::START_WORKFLOW, :workflow_code => "mock code")
25
25
  re_rule_expected_outcome.should be_valid
26
26
  end
27
27
  end
@@ -187,32 +187,32 @@ describe ReRule do
187
187
  end
188
188
 
189
189
  it "should return the first outcome that is a OUTCOME_NEXT" do
190
- outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_NEXT)
191
- outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_NEXT)
190
+ outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::NEXT)
191
+ outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::NEXT)
192
192
  @re_rule.re_rule_expected_outcomes << outcome_1
193
193
  @re_rule.re_rule_expected_outcomes << outcome_2
194
194
  @re_rule.re_rule_expected_outcome_next.should == outcome_1
195
195
  end
196
196
 
197
197
  it "should return the first outcome that is a OUTCOME_STOP_SUCCESS" do
198
- outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS)
199
- outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS)
198
+ outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::STOP_SUCCESS)
199
+ outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::STOP_SUCCESS)
200
200
  @re_rule.re_rule_expected_outcomes << outcome_1
201
201
  @re_rule.re_rule_expected_outcomes << outcome_2
202
202
  @re_rule.re_rule_expected_outcome_success.should == outcome_1
203
203
  end
204
204
 
205
205
  it "should return the first outcome that is a OUTCOME_STOP_FAILURE" do
206
- outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE)
207
- outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE)
206
+ outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::STOP_FAILURE)
207
+ outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::STOP_FAILURE)
208
208
  @re_rule.re_rule_expected_outcomes << outcome_1
209
209
  @re_rule.re_rule_expected_outcomes << outcome_2
210
210
  @re_rule.re_rule_expected_outcome_failure.should == outcome_1
211
211
  end
212
212
 
213
213
  it "should return all outcomes that are a OUTCOME_START_WORKFLOW" do
214
- outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
215
- outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
214
+ outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::START_WORKFLOW)
215
+ outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::Rule::Outcome::START_WORKFLOW)
216
216
  @re_rule.re_rule_expected_outcomes << outcome_1
217
217
  @re_rule.re_rule_expected_outcomes << outcome_2
218
218
  @re_rule.re_rule_expected_outcomes_start_workflow.should == [outcome_1, outcome_2]
@@ -239,21 +239,21 @@ describe ReRule do
239
239
  end
240
240
 
241
241
  it "should validate the workflow is present and activated" do
242
- re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
242
+ re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::Rule::Outcome::START_WORKFLOW)
243
243
  ReWorkflow.should_receive(:find_by_code).and_return(mock("ReWorkflow", :workflow_error => nil))
244
244
  @re_rule.stub!(:re_rule_expected_outcomes).and_return([re_rule_expected_outcome])
245
245
  @re_rule.rule_error.should be_nil
246
246
  end
247
247
 
248
248
  it "should return '[workflow_code] missing' if the required workflow is missing" do
249
- re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
249
+ re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::Rule::Outcome::START_WORKFLOW)
250
250
  ReWorkflow.should_receive(:find_by_code).and_return(nil)
251
251
  @re_rule.stub!(:re_rule_expected_outcomes).and_return([re_rule_expected_outcome])
252
252
  @re_rule.rule_error.should == "mock_workflow_code missing"
253
253
  end
254
254
 
255
255
  it "should return '[workflow_code] invalid' if the required workflow has errors" do
256
- re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
256
+ re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::Rule::Outcome::START_WORKFLOW)
257
257
  ReWorkflow.should_receive(:find_by_code).and_return(mock("ReWorkflow", :workflow_error => "workflow error"))
258
258
  @re_rule.stub!(:re_rule_expected_outcomes).and_return([re_rule_expected_outcome])
259
259
  @re_rule.rule_error.should == "mock_workflow_code invalid"