sms-spec 0.1.10 → 0.2.0
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/.gitignore +1 -0
- data/.travis.yml +14 -0
- data/README.markdown +14 -13
- data/lib/sms_spec/drivers/twilio-ruby.rb +52 -4
- data/lib/sms_spec/version.rb +1 -1
- data/sms-spec.gemspec +1 -1
- data/spec/drivers/twilio_spec.rb +70 -33
- metadata +6 -6
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4449249ef13af22e774a0f860198cb53907ec4d
|
4
|
+
data.tar.gz: 07e35f6581c2d4aac45b6c3bbf557884156b2a0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32944714927b4ae97bee2603704caee2d3661244458f13d4a25053dd2d857ad4d4c0b5f083c3ef71c9de73fd6a8ac9b799a396fc06d411040415506856e64fee
|
7
|
+
data.tar.gz: 03bd0dc1dcabab78dfac20086dbc626ef6f893240a12620a41c929904b48d9272fde876719dec18de58cd388be1ca06e6ef409ee4537b1696508a339dfed5174
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.markdown
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# SMS Spec
|
2
2
|
|
3
|
-
[](https://travis-ci.org/rosskevin/sms-spec)
|
4
|
+
[](https://codeclimate.com/github/rosskevin/sms-spec)
|
5
5
|
|
6
6
|
An RSpec DSL and Cucumber steps to test SMS interactions with your
|
7
7
|
Ruby on Rails application.
|
@@ -11,17 +11,18 @@ Currently this gem only supports testing SMS messaging using the
|
|
11
11
|
[lookout-clickatell](https://github.com/lookout/clickatell) gem.
|
12
12
|
|
13
13
|
##Setup
|
14
|
-
Add the sms-spec gem to
|
15
|
-
|
14
|
+
Add the sms-spec gem to `Gemfile`:
|
15
|
+
|
16
|
+
```ruby
|
16
17
|
group :test do
|
17
18
|
gem 'sms-spec'
|
18
19
|
end
|
19
|
-
|
20
|
+
```
|
20
21
|
|
21
22
|
## RSpec
|
22
|
-
|
23
|
+
Configure a driver and include helper and matcher methods in the `spec_helper.rb`:
|
23
24
|
|
24
|
-
|
25
|
+
```ruby
|
25
26
|
require 'sms_spec'
|
26
27
|
|
27
28
|
Spec::Runner.configure do |config|
|
@@ -30,19 +31,19 @@ Spec::Runner.configure do |config|
|
|
30
31
|
end
|
31
32
|
|
32
33
|
SmsSpec.driver = :twilio-ruby #this can be any available sms-spec driver
|
33
|
-
|
34
|
+
```
|
34
35
|
|
35
36
|
## Cucumber
|
36
|
-
Add the
|
37
|
+
Add the following to `env.rb`:
|
37
38
|
|
38
|
-
|
39
|
+
```ruby
|
39
40
|
require 'sms_spec'
|
40
41
|
require 'sms_spec/cucumber'
|
41
|
-
|
42
|
+
```
|
42
43
|
|
43
44
|
This loads the sms_spec RSpec helpers into your cucumber wold. Then,
|
44
45
|
run the following to generate the text_messsage_steps.rb file:
|
45
46
|
|
46
|
-
|
47
|
+
```ruby
|
47
48
|
rails generate sms_spec:steps
|
48
|
-
|
49
|
+
```
|
@@ -1,9 +1,37 @@
|
|
1
|
+
require 'twilio-ruby/util/configuration'
|
2
|
+
|
1
3
|
module Twilio
|
4
|
+
extend SingleForwardable
|
5
|
+
|
6
|
+
def_delegators :configuration, :account_sid, :auth_token
|
7
|
+
|
8
|
+
##
|
9
|
+
# Pre-configure with account SID and auth token so that you don't need to
|
10
|
+
# pass them to various initializers each time.
|
11
|
+
def self.configure(&block)
|
12
|
+
yield configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Returns an existing or instantiates a new configuration object.
|
17
|
+
def self.configuration
|
18
|
+
@configuration ||= Util::Configuration.new
|
19
|
+
end
|
20
|
+
private_class_method :configuration
|
21
|
+
|
2
22
|
module REST
|
3
23
|
class Client
|
4
24
|
|
5
|
-
def initialize(
|
6
|
-
|
25
|
+
def initialize(*args)
|
26
|
+
# mimic the primary class's #initialize.
|
27
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
28
|
+
@config = options #DEFAULTS.merge! options
|
29
|
+
|
30
|
+
@account_sid = args[0] || Twilio.account_sid
|
31
|
+
@auth_token = args[1] || Twilio.auth_token
|
32
|
+
if @account_sid.nil? || @auth_token.nil?
|
33
|
+
raise ArgumentError, 'Account SID and auth token are required'
|
34
|
+
end
|
7
35
|
end
|
8
36
|
|
9
37
|
class Messages
|
@@ -29,8 +57,28 @@ module Twilio
|
|
29
57
|
|
30
58
|
def account
|
31
59
|
account = Account.new
|
32
|
-
|
33
|
-
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
## Mirror method_missing approach
|
64
|
+
##
|
65
|
+
# Delegate account methods from the client. This saves having to call
|
66
|
+
# <tt>client.account</tt> every time for resources on the default
|
67
|
+
# account.
|
68
|
+
def method_missing(method_name, *args, &block)
|
69
|
+
if account.respond_to?(method_name)
|
70
|
+
account.send(method_name, *args, &block)
|
71
|
+
else
|
72
|
+
super
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def respond_to?(method_name, include_private=false)
|
77
|
+
if account.respond_to?(method_name, include_private)
|
78
|
+
true
|
79
|
+
else
|
80
|
+
super
|
81
|
+
end
|
34
82
|
end
|
35
83
|
end
|
36
84
|
end
|
data/lib/sms_spec/version.rb
CHANGED
data/sms-spec.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency 'rspec', "~>
|
21
|
+
s.add_dependency 'rspec', "~> 3.1"
|
22
22
|
s.add_development_dependency "rake"
|
23
23
|
s.add_development_dependency "twilio-ruby", "~> 3.0"
|
24
24
|
s.add_development_dependency "lookout-clickatell", "~> 0.8"
|
data/spec/drivers/twilio_spec.rb
CHANGED
@@ -1,63 +1,100 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'twilio-ruby' do
|
4
4
|
include SmsSpec::Helpers
|
5
|
+
SmsSpec.driver = :'twilio-ruby'
|
5
6
|
|
6
7
|
before :each do
|
7
8
|
SmsSpec::Data.clear_messages
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
context 'instantiation options' do
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
@account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
15
|
+
@auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
16
|
+
@client = nil
|
13
17
|
end
|
14
18
|
|
15
|
-
it
|
16
|
-
|
17
|
-
|
19
|
+
it 'with two args' do
|
20
|
+
@client = Twilio::REST::Client.new @account_sid, @auth_token
|
21
|
+
expect(@client).to_not be_nil
|
22
|
+
end
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
it 'with config' do
|
25
|
+
Twilio.configure do |config|
|
26
|
+
config.account_sid = @account_sid
|
27
|
+
config.auth_token = @auth_token
|
28
|
+
end
|
29
|
+
@client = Twilio::REST::Client.new
|
30
|
+
expect(@client).to_not be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
context 'using method_missing approach' do
|
36
|
+
|
37
|
+
before do
|
38
|
+
@account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
39
|
+
@auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
40
|
+
Twilio.configure do |config|
|
41
|
+
config.account_sid = @account_sid
|
42
|
+
config.auth_token = @auth_token
|
43
|
+
end
|
44
|
+
@client = Twilio::REST::Client.new
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'intercepts calls to twilio sms client' do
|
48
|
+
@client.messages.create(
|
49
|
+
:from => '+14159341234',
|
50
|
+
:to => '+16105557069',
|
51
|
+
:body => 'Hey there!'
|
24
52
|
)
|
25
53
|
|
26
|
-
open_last_text_message_for(
|
54
|
+
open_last_text_message_for('+16105557069')
|
27
55
|
expect(current_text_message).to_not be_nil
|
28
56
|
end
|
29
57
|
|
30
|
-
it
|
31
|
-
|
32
|
-
|
58
|
+
it 'records the from number for a message' do
|
59
|
+
@client.messages.create(
|
60
|
+
:from => '+14159341234',
|
61
|
+
:to => '+16105557069',
|
62
|
+
:body => 'Hey there!'
|
63
|
+
)
|
64
|
+
|
65
|
+
open_last_text_message_for('+16105557069')
|
66
|
+
expect(current_text_message.from).to eq('+14159341234')
|
67
|
+
end
|
68
|
+
end
|
33
69
|
|
34
|
-
|
70
|
+
context 'using .account.* methods' do
|
71
|
+
|
72
|
+
before do
|
73
|
+
@account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
74
|
+
@auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
75
|
+
@client = Twilio::REST::Client.new @account_sid, @auth_token
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'intercepts calls to twilio sms client' do
|
35
79
|
@client.account.messages.create(
|
36
|
-
|
37
|
-
|
38
|
-
|
80
|
+
:from => '+14159341234',
|
81
|
+
:to => '+16105557069',
|
82
|
+
:body => 'Hey there!'
|
39
83
|
)
|
40
84
|
|
41
|
-
open_last_text_message_for(
|
85
|
+
open_last_text_message_for('+16105557069')
|
42
86
|
expect(current_text_message).to_not be_nil
|
43
|
-
expect(@client.account).to respond_to(:sid)
|
44
|
-
expect(@client.account.sid).to be(account_sid)
|
45
87
|
end
|
46
88
|
|
47
|
-
it
|
48
|
-
account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
49
|
-
auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
50
|
-
|
51
|
-
@client = Twilio::REST::Client.new account_sid, auth_token
|
89
|
+
it 'records the from number for a message' do
|
52
90
|
@client.account.messages.create(
|
53
|
-
|
54
|
-
|
55
|
-
|
91
|
+
:from => '+14159341234',
|
92
|
+
:to => '+16105557069',
|
93
|
+
:body => 'Hey there!'
|
56
94
|
)
|
57
95
|
|
58
|
-
open_last_text_message_for(
|
96
|
+
open_last_text_message_for('+16105557069')
|
59
97
|
expect(current_text_message.from).to eq('+14159341234')
|
60
98
|
end
|
61
|
-
|
62
99
|
end
|
63
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sms-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Rittersdorf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,7 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
|
-
- ".
|
91
|
+
- ".travis.yml"
|
92
92
|
- Gemfile
|
93
93
|
- Guardfile
|
94
94
|
- README.markdown
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project: sms-spec
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.5.1
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Test SMS interactions with RSpec and Cucumber
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.1.2
|