check_mobi 1.0.2 → 1.0.3
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/lib/check_mobi/core_ext/hash.rb +2 -3
- data/lib/check_mobi/core_ext/string.rb +3 -4
- data/lib/check_mobi/resources/voice/events.rb +2 -2
- data/lib/check_mobi/version.rb +1 -1
- data/test/check_mobi/client_test.rb +1 -1
- data/test/check_mobi/core_ext/hash_test.rb +3 -3
- data/test/check_mobi/core_ext/string_test.rb +10 -10
- data/test/check_mobi/resources/voice/actions/speak_action_test.rb +3 -3
- data/test/check_mobi/resources/voice/call_test.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9faa0d186c645b4a4c6efa107ddd839f497412ff
|
4
|
+
data.tar.gz: 39556d936de9c4e327c6c6310b5890375cf082df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 015bc0bebcc56fed502ee97065a1472abcb26d2d0eb3b0d3d3fac2cb7bd50f5a44c71d3e638a7a6acac6e026075e366896c1583de8087edce984804e160673e5
|
7
|
+
data.tar.gz: 06ce250a1495304d160a0ad3f8435816556c8a373d45eb4fb67c773b63ae4f41e64a481c746ad9f50c38673cd5c4a6666cf27c04766f82ac064685472105a00d
|
@@ -1,10 +1,9 @@
|
|
1
1
|
class Hash
|
2
|
-
def
|
3
|
-
super if defined? Rails
|
2
|
+
def cm_symbolize_keys
|
4
3
|
self.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
5
4
|
end
|
6
5
|
|
7
|
-
def
|
6
|
+
def cm_stringify_keys
|
8
7
|
super if defined? Rails
|
9
8
|
self.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo}
|
10
9
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class String
|
2
|
-
def
|
3
|
-
super if defined? Rails
|
2
|
+
def cm_underscore!
|
4
3
|
self.gsub(/::/, '/').
|
5
4
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
6
5
|
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
@@ -8,7 +7,7 @@ class String
|
|
8
7
|
downcase!
|
9
8
|
end
|
10
9
|
|
11
|
-
def
|
12
|
-
dup.
|
10
|
+
def cm_underscore
|
11
|
+
dup.cm_underscore!
|
13
12
|
end
|
14
13
|
end
|
@@ -15,7 +15,7 @@ module CheckMobi
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def after_initialize # overridden by subclasses
|
18
|
-
@action = self.class.name.split('::').last.
|
18
|
+
@action = self.class.name.split('::').last.cm_underscore!
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -29,4 +29,4 @@ end
|
|
29
29
|
# @required_fields = []
|
30
30
|
# args.each {|field| @required_fields << field}
|
31
31
|
# end
|
32
|
-
# end
|
32
|
+
# end
|
data/lib/check_mobi/version.rb
CHANGED
@@ -57,7 +57,7 @@ describe CheckMobi::Client do
|
|
57
57
|
|
58
58
|
it "should accept/return form_data" do
|
59
59
|
@client.send(:set_body, form_data)
|
60
|
-
JSON.parse(@request.body).
|
60
|
+
JSON.parse(@request.body).cm_symbolize_keys.must_equal form_data
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
@@ -3,25 +3,25 @@ require_relative '../../../lib/check_mobi/core_ext/string'
|
|
3
3
|
|
4
4
|
describe String do
|
5
5
|
|
6
|
-
it 'should respond to
|
7
|
-
'TheSampleClass'.must_respond_to(:
|
8
|
-
'TheSampleClass'.must_respond_to(:
|
6
|
+
it 'should respond to cm_underscore' do
|
7
|
+
'TheSampleClass'.must_respond_to(:cm_underscore)
|
8
|
+
'TheSampleClass'.must_respond_to(:cm_underscore!)
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'should
|
12
|
-
'TheSampleClass'.
|
13
|
-
'TheSampleClass'.
|
11
|
+
it 'should cm_underscore a class string name' do
|
12
|
+
'TheSampleClass'.cm_underscore.must_equal 'the_sample_class'
|
13
|
+
'TheSampleClass'.cm_underscore!.must_equal 'the_sample_class'
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should put / on namespacing' do
|
17
|
-
'SuperTop::Parent::TheSampleClass'.
|
17
|
+
'SuperTop::Parent::TheSampleClass'.cm_underscore.must_equal 'super_top/parent/the_sample_class'
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should preserve /' do
|
21
|
-
'SuperTop/Parent/TheSampleClass'.
|
21
|
+
'SuperTop/Parent/TheSampleClass'.cm_underscore.must_equal 'super_top/parent/the_sample_class'
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should replace - with _' do
|
25
|
-
'Super-Top/Parent/The-Sample-Class'.
|
25
|
+
'Super-Top/Parent/The-Sample-Class'.cm_underscore.must_equal 'super_top/parent/the_sample_class'
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
@@ -30,7 +30,7 @@ describe CheckMobi::Resources::Voice::Actions::Speak do
|
|
30
30
|
it 'should add speak event correctly' do
|
31
31
|
@resource.events << @speak_action
|
32
32
|
@resource.events.length.must_equal 1
|
33
|
-
@resource.events.first.action.must_equal @speak_action.class.name.split('::').last.
|
33
|
+
@resource.events.first.action.must_equal @speak_action.class.name.split('::').last.cm_underscore!
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should build hashes correctly' do
|
@@ -39,7 +39,7 @@ describe CheckMobi::Resources::Voice::Actions::Speak do
|
|
39
39
|
hash.keys.must_include(:events)
|
40
40
|
hash[:events].must_be_instance_of Array
|
41
41
|
hash[:events].first.must_be_instance_of Hash
|
42
|
-
hash[:events].first[:action].must_equal @speak_action.class.name.split('::').last.
|
42
|
+
hash[:events].first[:action].must_equal @speak_action.class.name.split('::').last.cm_underscore!
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should request without text' do
|
@@ -73,4 +73,4 @@ describe CheckMobi::Resources::Voice::Actions::Speak do
|
|
73
73
|
times: 1)
|
74
74
|
end
|
75
75
|
|
76
|
-
end
|
76
|
+
end
|
@@ -30,31 +30,31 @@ describe CheckMobi::Resources::Voice::Call do
|
|
30
30
|
it 'should add speak event correctly' do
|
31
31
|
@resource.events << @speak_action
|
32
32
|
@resource.events.length.must_equal 1
|
33
|
-
@resource.events.first.action.must_equal @speak_action.class.name.split('::').last.
|
33
|
+
@resource.events.first.action.must_equal @speak_action.class.name.split('::').last.cm_underscore!
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should add play event correctly' do
|
37
37
|
@resource.events << @play_action
|
38
38
|
@resource.events.length.must_equal 1
|
39
|
-
@resource.events.first.action.must_equal @play_action.class.name.split('::').last.
|
39
|
+
@resource.events.first.action.must_equal @play_action.class.name.split('::').last.cm_underscore!
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should add send_dtmf event correctly' do
|
43
43
|
@resource.events << @send_dtmf
|
44
44
|
@resource.events.length.must_equal 1
|
45
|
-
@resource.events.first.action.must_equal @send_dtmf.class.name.split('::').last.
|
45
|
+
@resource.events.first.action.must_equal @send_dtmf.class.name.split('::').last.cm_underscore!
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should add hangup event correctly' do
|
49
49
|
@resource.events << @hangup_action
|
50
50
|
@resource.events.length.must_equal 1
|
51
|
-
@resource.events.first.action.must_equal @hangup_action.class.name.split('::').last.
|
51
|
+
@resource.events.first.action.must_equal @hangup_action.class.name.split('::').last.cm_underscore!
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should add wait event correctly' do
|
55
55
|
@resource.events << @wait_action
|
56
56
|
@resource.events.length.must_equal 1
|
57
|
-
@resource.events.first.action.must_equal @wait_action.class.name.split('::').last.
|
57
|
+
@resource.events.first.action.must_equal @wait_action.class.name.split('::').last.cm_underscore!
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should add multiple events correctly' do
|
@@ -66,7 +66,7 @@ describe CheckMobi::Resources::Voice::Call do
|
|
66
66
|
@resource.events.length.must_equal 3
|
67
67
|
@resource.events.concat [@hangup_action, @wait_action]
|
68
68
|
@resource.events.length.must_equal 5
|
69
|
-
@resource.events.each {|event| event.action.must_equal event.class.name.split('::').last.
|
69
|
+
@resource.events.each {|event| event.action.must_equal event.class.name.split('::').last.cm_underscore!}
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'should have attributes' do
|
@@ -144,4 +144,4 @@ describe CheckMobi::Resources::Voice::Call do
|
|
144
144
|
})
|
145
145
|
end
|
146
146
|
end
|
147
|
-
end
|
147
|
+
end
|