call_center 0.1.0 → 0.1.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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/call_center.gemspec
CHANGED
@@ -18,9 +18,12 @@ module CallCenter
|
|
18
18
|
|
19
19
|
def inject(options)
|
20
20
|
current_stack = @stack.dup
|
21
|
-
|
21
|
+
|
22
|
+
evaluator = Evaluator.new(current_stack) { |model|
|
22
23
|
current_stack.map { |conditional| conditional.evaluate(model) }.all?
|
23
|
-
}
|
24
|
+
}
|
25
|
+
|
26
|
+
options.merge(:if => evaluator)
|
24
27
|
end
|
25
28
|
|
26
29
|
class Conditional
|
@@ -36,6 +39,15 @@ module CallCenter
|
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
42
|
+
class Evaluator < Proc
|
43
|
+
attr_reader :stack
|
44
|
+
|
45
|
+
def initialize(stack)
|
46
|
+
@stack = stack
|
47
|
+
super()
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
39
51
|
class IfConditional < Conditional
|
40
52
|
def if?
|
41
53
|
true
|
@@ -104,7 +104,13 @@ module CallCenter
|
|
104
104
|
stub_methods = (after_transition_methods(s_m) | if_and_unless_conditions(s_m)).uniq - without
|
105
105
|
object.reset_mocha
|
106
106
|
stub_methods.each do |m|
|
107
|
-
|
107
|
+
if m.instance_of?(CallCenter::ConditionalStack::Evaluator)
|
108
|
+
m.stack.map(&:name).each do |name|
|
109
|
+
object.stubs(name)
|
110
|
+
end
|
111
|
+
else
|
112
|
+
object.stubs(m)
|
113
|
+
end
|
108
114
|
end
|
109
115
|
end
|
110
116
|
|
@@ -2,19 +2,38 @@ require 'minitest/helper'
|
|
2
2
|
require 'call_center/test/minitest/dsl'
|
3
3
|
|
4
4
|
require 'test/examples/call'
|
5
|
+
require 'test/examples/dynamic_transition_call'
|
5
6
|
|
6
7
|
describe CallCenter::Test::MiniTest::DSL do
|
7
|
-
subject { Call.new }
|
8
|
-
let(:call_center_state_field) { :state }
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
describe Call do
|
10
|
+
subject { Call.new }
|
11
|
+
let(:call_center_state_field) { :state }
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
it_should_flow { on(:incoming_call).from(:initial).to(:routing).if(:agents_available?) }
|
14
|
+
it_should_flow { on(:incoming_call).from(:initial).to(:voicemail).unless(:agents_available?) }
|
15
|
+
it_should_render { is(:initial).expects(:notify).selects("Response>Say", "Hello World") }
|
16
16
|
|
17
|
-
|
17
|
+
it_should_flow { on(:customer_hangs_up).from(:voicemail).to(:voicemail_completed) }
|
18
|
+
it_should_render { is(:voicemail).expects(:notify).selects("Response>Say", "Hello World").selects("Response>Record[action=/voice/calls/flow?event=voicemail_complete&actor=customer]") }
|
19
|
+
|
20
|
+
it_should_flow { on(:something_crazy_happens).from(:initial).to(:uh_oh) }
|
21
|
+
|
22
|
+
it_should_flow { on(:customer_hangs_up).from(:cancelled).to(:cancelled).expects(:cancelled) { |e| e.never } }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe DynamicTransitionCall do
|
26
|
+
subject { DynamicTransitionCall.new }
|
27
|
+
let(:call_center_state_field) { :state }
|
28
|
+
|
29
|
+
it_should_flow { on(:incoming_call).from(:initial).to(:routing_on_client).if(:agents_available?).unless(:via_phone?) }
|
30
|
+
it_should_flow { on(:incoming_call).from(:initial).to(:routing_on_phone).if(:agents_available?).if(:via_phone?) }
|
31
|
+
|
32
|
+
it_should_flow { on(:incoming_call).from(:initial).to(:voicemail).unless(:agents_available?).unless(:voicemail_full?) }
|
33
|
+
it_should_flow { on(:incoming_call).from(:initial).to(:cancelled).unless(:agents_available?).if(:voicemail_full?) }
|
34
|
+
|
35
|
+
it_should_flow { on(:picks_up).from(:routing_on_client).to(:in_conference).unless(:out_of_area?) }
|
36
|
+
it_should_flow { on(:picks_up).from(:routing_on_client).to(:cancelled).if(:out_of_area?) }
|
37
|
+
end
|
18
38
|
|
19
|
-
it_should_flow { on(:customer_hangs_up).from(:cancelled).to(:cancelled).expects(:cancelled) { |e| e.never } }
|
20
39
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: call_center
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Henry Hsu
|