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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1cbb4a70ba312ae8af41cde0d9f81545ecf9e27
4
- data.tar.gz: 32c49b99bcc8925059e92ca8b49e596b1e017a11
3
+ metadata.gz: 66b8a71e8bff68ed1f22679af83b9e88ccd7ed68
4
+ data.tar.gz: 089423a35d03897e31f4bdc919acdee5b288653e
5
5
  SHA512:
6
- metadata.gz: 0d4d057119ca12e411170efa42db202cf38f41ec475fb12f85a6494491c567c7f4fea0f6f62245c368038ba6739d9d559d5a73e940cab7329ab3c37a724cd2ff
7
- data.tar.gz: 95390fb5e52d92ac44f5b434695eaaeaac055f7d33424eaa2ebb400e5a7253dbfdf70b7833aaf0cb1f3e16a23fe8323ace8368945324ac64e46990baa5a286f4
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
@@ -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 ||= NumberGenerator.instance.generate
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
@@ -21,5 +21,9 @@ module TwilioMock
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ def clean
26
+ @available_numbers = []
27
+ end
24
28
  end
25
29
  end
data/lib/twilio_mock.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'twilio_mock/testing'
2
2
  require 'twilio_mock/number_generator'
3
+ require 'twilio_mock/messages_queue'
3
4
  require 'twilio_mock/mocker'
4
5
  require 'twilio_mock/lookup_mocker'
5
6
  require 'rest'
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.1.2
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-05-30 00:00:00.000000000 Z
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: '2.3'
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: '2.3'
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