twilio_mock 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/twilio_mock/messages_queue.rb +21 -0
- data/lib/twilio_mock/mocker.rb +20 -1
- data/lib/twilio_mock/number_generator.rb +4 -0
- data/lib/twilio_mock.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b8a71e8bff68ed1f22679af83b9e88ccd7ed68
|
4
|
+
data.tar.gz: 089423a35d03897e31f4bdc919acdee5b288653e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92bb976b83bd696d979a6395b1865f026db0ffac7cc3c009a99da93c172da87d52f431e11f123c847c481691c193680ab9dafa332b12b5c25508e381171ca04a
|
7
|
+
data.tar.gz: c21c91776602d67958e2c34a7dc13575d38d58207fc9059c4e17ca33ce66150cd910537f7c9bcaa595161724a2a69fd7d56d2a71aa20e5eca7598f556e2322d6
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module TwilioMock
|
4
|
+
class MessagesQueue
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
attr_reader :messages
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@messages = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add(message)
|
14
|
+
@messages << message
|
15
|
+
end
|
16
|
+
|
17
|
+
def clean
|
18
|
+
@messages = []
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/twilio_mock/mocker.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'twilio-ruby'
|
2
2
|
require 'webmock'
|
3
3
|
require_relative 'number_generator'
|
4
|
+
require 'ostruct'
|
4
5
|
|
5
6
|
module TwilioMock
|
6
7
|
class Mocker
|
@@ -15,6 +16,7 @@ module TwilioMock
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def create_message(attrs)
|
19
|
+
messages_queue.add OpenStruct.new(attrs)
|
18
20
|
prepare_stub(attrs, 'Messages.json')
|
19
21
|
end
|
20
22
|
|
@@ -29,6 +31,15 @@ module TwilioMock
|
|
29
31
|
prepare_stub(attrs, 'IncomingPhoneNumbers.json')
|
30
32
|
end
|
31
33
|
|
34
|
+
def messages
|
35
|
+
messages_queue.messages
|
36
|
+
end
|
37
|
+
|
38
|
+
def clean
|
39
|
+
number_generator.clean
|
40
|
+
messages_queue.clean
|
41
|
+
end
|
42
|
+
|
32
43
|
private
|
33
44
|
|
34
45
|
def response
|
@@ -61,11 +72,19 @@ module TwilioMock
|
|
61
72
|
end
|
62
73
|
|
63
74
|
def available_number_response(number)
|
64
|
-
number ||=
|
75
|
+
number ||= number_generator.generate
|
65
76
|
{
|
66
77
|
sid: @username,
|
67
78
|
available_phone_numbers: [{ 'PhoneNumber' => number }]
|
68
79
|
}.to_json
|
69
80
|
end
|
81
|
+
|
82
|
+
def number_generator
|
83
|
+
NumberGenerator.instance
|
84
|
+
end
|
85
|
+
|
86
|
+
def messages_queue
|
87
|
+
MessagesQueue.instance
|
88
|
+
end
|
70
89
|
end
|
71
90
|
end
|
data/lib/twilio_mock.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twilio_mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maicol Bentancor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twilio-ruby
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '3.0'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '2'
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '3.0'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '2'
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/rest.rb
|
60
60
|
- lib/twilio_mock.rb
|
61
61
|
- lib/twilio_mock/lookup_mocker.rb
|
62
|
+
- lib/twilio_mock/messages_queue.rb
|
62
63
|
- lib/twilio_mock/mocker.rb
|
63
64
|
- lib/twilio_mock/number_generator.rb
|
64
65
|
- lib/twilio_mock/testing.rb
|