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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c34ed4c16eee1805f81392619bf8c1600044f83
4
- data.tar.gz: 4881f53d715ae43c5133da25cabf156928fa515d
3
+ metadata.gz: f4449249ef13af22e774a0f860198cb53907ec4d
4
+ data.tar.gz: 07e35f6581c2d4aac45b6c3bbf557884156b2a0f
5
5
  SHA512:
6
- metadata.gz: a3474a9046254133ab9bee3782217cf2ec8a7b47e1d34c2512009b72eaf2bf2af2d24373576af5bf38fa788e3bb06ca127775d2675a28f3c8949828ba6c4a6cd
7
- data.tar.gz: 1f7792d5316d188d1a6a0c43edd286c238e4e365e68a6f53dc2a113d316e66b72a9df8def6bd7043ee1072d9dff474e657e5150dafaa1e6740308c6e345fabbe
6
+ metadata.gz: 32944714927b4ae97bee2603704caee2d3661244458f13d4a25053dd2d857ad4d4c0b5f083c3ef71c9de73fd6a8ac9b799a396fc06d411040415506856e64fee
7
+ data.tar.gz: 03bd0dc1dcabab78dfac20086dbc626ef6f893240a12620a41c929904b48d9272fde876719dec18de58cd388be1ca06e6ef409ee4537b1696508a339dfed5174
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .rvmrc
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ - ruby-head
5
+ - jruby-head
6
+ - rbx-head
7
+
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: ruby-head
11
+ - rvm: jruby-head
12
+ - rvm: rbx-head
13
+
14
+ script: rake
@@ -1,7 +1,7 @@
1
1
  # SMS Spec
2
2
 
3
- [![Build Status](https://travis-ci.org/manlycode/sms-spec.svg)](https://travis-ci.org/manlycode/sms-spec)
4
- [![Code Climate](https://codeclimate.com/github/manlycode/sms-spec/badges/gpa.svg)](https://codeclimate.com/github/manlycode/sms-spec)
3
+ [![Build Status](https://travis-ci.org/rosskevin/sms-spec.svg)](https://travis-ci.org/rosskevin/sms-spec)
4
+ [![Code Climate](https://codeclimate.com/github/rosskevin/sms-spec/badges/gpa.svg)](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 your Gemfile:
15
- <pre>
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
- </pre>
20
+ ```
20
21
 
21
22
  ## RSpec
22
- In your spec_helper.rb file configure a driver and include helper and matcher methods.
23
+ Configure a driver and include helper and matcher methods in the `spec_helper.rb`:
23
24
 
24
- <pre>
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
- </pre>
34
+ ```
34
35
 
35
36
  ## Cucumber
36
- Add the folloing to you env.rb file:
37
+ Add the following to `env.rb`:
37
38
 
38
- <pre>
39
+ ```ruby
39
40
  require 'sms_spec'
40
41
  require 'sms_spec/cucumber'
41
- </pre>
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
- <pre>
47
+ ```ruby
47
48
  rails generate sms_spec:steps
48
- </pre>
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(account_sid, auth_token)
6
- $account_sid = account_sid
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
- account.class.send(:define_method, :sid, lambda { $account_sid })
33
- account
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
@@ -1,3 +1,3 @@
1
1
  module SmsSpec
2
- VERSION = "0.1.10"
2
+ VERSION = '0.2.0'
3
3
  end
@@ -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', "~> 2.11"
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"
@@ -1,63 +1,100 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SmsSpec do
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
- describe "the twilio-ruby driver" do
11
- it "is assignable" do
12
- SmsSpec.driver = :"twilio-ruby"
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 "intercepts calls to twilio's sms client" do
16
- account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
17
- auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
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
- @client = Twilio::REST::Client.new account_sid, auth_token
20
- @client.account.messages.create(
21
- :from => '+14159341234',
22
- :to => '+16105557069',
23
- :body => 'Hey there!'
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("+16105557069")
54
+ open_last_text_message_for('+16105557069')
27
55
  expect(current_text_message).to_not be_nil
28
56
  end
29
57
 
30
- it "allows for sid method calls on the account object" do
31
- account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
32
- auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
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
- @client = Twilio::REST::Client.new account_sid, auth_token
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
- :from => '+14159341234',
37
- :to => '+16105557069',
38
- :body => 'Hey there!'
80
+ :from => '+14159341234',
81
+ :to => '+16105557069',
82
+ :body => 'Hey there!'
39
83
  )
40
84
 
41
- open_last_text_message_for("+16105557069")
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 "records the from number for a message" do
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
- :from => '+14159341234',
54
- :to => '+16105557069',
55
- :body => 'Hey there!'
91
+ :from => '+14159341234',
92
+ :to => '+16105557069',
93
+ :body => 'Hey there!'
56
94
  )
57
95
 
58
- open_last_text_message_for("+16105557069")
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.1.10
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: 2014-09-17 00:00:00.000000000 Z
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: '2.11'
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: '2.11'
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
- - ".ruby-version"
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.4.1
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
@@ -1 +0,0 @@
1
- 2.1.2