grocer 0.5.0 → 0.6.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 +2 -0
- data/.travis.yml +10 -5
- data/CHANGELOG.md +6 -1
- data/Gemfile +13 -0
- data/README.md +7 -5
- data/grocer.gemspec +1 -2
- data/lib/grocer/notification.rb +14 -3
- data/lib/grocer/version.rb +1 -1
- data/spec/grocer/connection_spec.rb +11 -11
- data/spec/grocer/error_response_spec.rb +2 -3
- data/spec/grocer/failed_delivery_attempt_spec.rb +2 -3
- data/spec/grocer/feedback_connection_spec.rb +1 -1
- data/spec/grocer/feedback_spec.rb +3 -3
- data/spec/grocer/mobile_device_management_notification_spec.rb +2 -2
- data/spec/grocer/notification_reader_spec.rb +11 -1
- data/spec/grocer/notification_spec.rb +12 -7
- data/spec/grocer/push_connection_spec.rb +1 -1
- data/spec/grocer/pusher_spec.rb +1 -1
- data/spec/grocer/safari_notification_spec.rb +7 -7
- data/spec/grocer/ssl_connection_spec.rb +4 -4
- data/spec/grocer_spec.rb +3 -3
- data/spec/spec_helper.rb +7 -1
- metadata +20 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 907e31ec8991cc7e09d08d4eebf0a3e59e46df03
|
4
|
+
data.tar.gz: 7615fdc0dd345d9714cdb036f3feaafa94ae1d35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 799ca81894f2c703eb4997fe6d9ffaaaa41a5c3ff1105a90d27c2acb0b01f6104ecedf2730a8db0de6fed5cccc4f2e752f58e329f0cc196336be9a451249c501
|
7
|
+
data.tar.gz: fa7b760b7c12fc8992c7c2ebf6b1695403466a8128242b86ce0df365ef16ec79825c816fe2426dead79dbe51ab1d610f53f7ad10dc1f8bc7400336397c568418
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.
|
4
|
-
- 1.
|
3
|
+
- 2.1.1
|
4
|
+
- 2.1.0
|
5
5
|
- 2.0.0
|
6
|
-
-
|
7
|
-
-
|
8
|
-
|
6
|
+
- 1.9.3
|
7
|
+
- 1.9.2
|
8
|
+
- jruby-19mode
|
9
|
+
- rbx
|
10
|
+
- rbx-2
|
11
|
+
addons:
|
12
|
+
code_climate:
|
13
|
+
repo_token: d414084f17a07a6b2d7da72eaa35d92281554a4266ab8d6246fee1f6c0c161b6
|
data/CHANGELOG.md
CHANGED
@@ -2,11 +2,16 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.6.0
|
6
|
+
|
7
|
+
* Add `category` option for custom notification actions. ([Michel
|
8
|
+
Billard](https://github.com/mbillard))
|
9
|
+
|
5
10
|
## 0.5.0
|
6
11
|
|
7
12
|
* Add `Grocer::SafariNotification` for sending Safari notifications in OS X
|
8
13
|
Mavericks. ([Ben Ubois](https://github.com/benubois) and [Adam
|
9
|
-
Duke](adamvduke))
|
14
|
+
Duke](https://github.com/adamvduke))
|
10
15
|
|
11
16
|
## 0.4.1
|
12
17
|
|
data/Gemfile
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
platforms :rbx do
|
4
|
+
gem 'rubysl', '~> 2.0'
|
5
|
+
gem 'json'
|
6
|
+
gem 'rubinius-developer_tools'
|
7
|
+
end
|
8
|
+
|
3
9
|
# Specify your gem's dependencies in grocer.gemspec
|
4
10
|
gemspec
|
11
|
+
|
12
|
+
# Code coverage
|
13
|
+
gem 'codeclimate-test-reporter', :group => :test, :require => nil
|
14
|
+
|
15
|
+
# Require Simplecov explicitly. Remove this explicit dependency when
|
16
|
+
# the following is fixed: https://github.com/colszowka/simplecov/issues/281
|
17
|
+
gem 'simplecov', '~> 0.7.1'
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Grocer
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/grocer)
|
4
|
+
[](https://codeclimate.com/github/grocer/grocer)
|
5
|
+
[](https://travis-ci.org/grocer/grocer)
|
6
|
+
[](https://gemnasium.com/grocer/grocer)
|
6
7
|
|
7
8
|
**grocer** interfaces with the [Apple Push Notification
|
8
9
|
Service](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html)
|
@@ -13,7 +14,7 @@ cleanest, most extensible, and friendliest.
|
|
13
14
|
|
14
15
|
## Requirements
|
15
16
|
|
16
|
-
* Ruby/MRI 1.9.x, JRuby 1.7.x in 1.9 mode, Rubinius in 1.9 mode
|
17
|
+
* Ruby/MRI 2.1, 2.0, 1.9.x, JRuby 1.7.x in 1.9 mode, Rubinius in 1.9 mode
|
17
18
|
|
18
19
|
## Installation
|
19
20
|
|
@@ -72,9 +73,10 @@ notification = Grocer::Notification.new(
|
|
72
73
|
device_token: "fe15a27d5df3c34778defb1f4f3880265cc52c0c047682223be59fb68500a9a2",
|
73
74
|
alert: "Hello from Grocer!",
|
74
75
|
badge: 42,
|
76
|
+
category: "a category", # optional; used for custom notification actions
|
75
77
|
sound: "siren.aiff", # optional
|
76
78
|
expiry: Time.now + 60*60, # optional; 0 is default, meaning the message is not stored
|
77
|
-
identifier: 1234, # optional
|
79
|
+
identifier: 1234, # optional; must be an integer
|
78
80
|
content_available: true # optional; any truthy value will set 'content-available' to 1
|
79
81
|
)
|
80
82
|
|
data/grocer.gemspec
CHANGED
@@ -19,14 +19,13 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.homepage = 'https://github.com/grocer/grocer'
|
20
20
|
gem.license = 'MIT'
|
21
21
|
|
22
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
22
|
gem.files = `git ls-files`.split("\n")
|
24
23
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
24
|
gem.name = "grocer"
|
26
25
|
gem.require_paths = ["lib"]
|
27
26
|
gem.version = Grocer::VERSION
|
28
27
|
|
29
|
-
gem.add_development_dependency 'rspec', '~>
|
28
|
+
gem.add_development_dependency 'rspec', '~> 3.0.0.rc1'
|
30
29
|
gem.add_development_dependency 'pry', '~> 0.9.8'
|
31
30
|
gem.add_development_dependency 'mocha'
|
32
31
|
gem.add_development_dependency 'bourne'
|
data/lib/grocer/notification.rb
CHANGED
@@ -3,11 +3,11 @@ require 'json'
|
|
3
3
|
module Grocer
|
4
4
|
# Public: An object used to send notifications to APNS.
|
5
5
|
class Notification
|
6
|
-
MAX_PAYLOAD_SIZE =
|
6
|
+
MAX_PAYLOAD_SIZE = 2048
|
7
7
|
CONTENT_AVAILABLE_INDICATOR = 1
|
8
8
|
|
9
9
|
attr_accessor :identifier, :expiry, :device_token
|
10
|
-
attr_reader :alert, :badge, :custom, :sound, :content_available
|
10
|
+
attr_reader :alert, :badge, :custom, :sound, :content_available, :category
|
11
11
|
|
12
12
|
# Public: Initialize a new Grocer::Notification. You must specify at least an `alert` or `badge`.
|
13
13
|
#
|
@@ -19,6 +19,7 @@ module Grocer
|
|
19
19
|
# :expiry - The Integer representing UNIX epoch date sent to APNS as the notification expiry. (default: 0)
|
20
20
|
# :identifier - The arbitrary Integer sent to APNS to uniquely this notification. (default: 0)
|
21
21
|
# :content_available - The truthy or falsy value indicating the availability of new content for background fetch. (optional)
|
22
|
+
# :category - The String to be sent as the category portion of the payload. (optional)
|
22
23
|
def initialize(payload = {})
|
23
24
|
@identifier = 0
|
24
25
|
|
@@ -61,11 +62,20 @@ module Grocer
|
|
61
62
|
@encoded_payload = nil
|
62
63
|
end
|
63
64
|
|
65
|
+
def category=(category)
|
66
|
+
@category = category
|
67
|
+
@encoded_payload = nil
|
68
|
+
end
|
69
|
+
|
64
70
|
def content_available=(content_available)
|
65
71
|
@content_available = CONTENT_AVAILABLE_INDICATOR if content_available
|
66
72
|
@encoded_payload = nil
|
67
73
|
end
|
68
74
|
|
75
|
+
def content_available?
|
76
|
+
!!content_available
|
77
|
+
end
|
78
|
+
|
69
79
|
def validate_payload
|
70
80
|
fail NoPayloadError unless alert || badge || custom
|
71
81
|
fail PayloadTooLargeError if payload_too_large?
|
@@ -87,7 +97,8 @@ module Grocer
|
|
87
97
|
aps_hash[:alert] = alert if alert
|
88
98
|
aps_hash[:badge] = badge if badge
|
89
99
|
aps_hash[:sound] = sound if sound
|
90
|
-
aps_hash[:'content-available'] = content_available if content_available
|
100
|
+
aps_hash[:'content-available'] = content_available if content_available?
|
101
|
+
aps_hash[:category] = category if category
|
91
102
|
|
92
103
|
{ aps: aps_hash }.merge(custom || { })
|
93
104
|
end
|
data/lib/grocer/version.rb
CHANGED
@@ -35,7 +35,7 @@ describe Grocer::Connection do
|
|
35
35
|
|
36
36
|
it 'requires a gateway' do
|
37
37
|
connection_options.delete(:gateway)
|
38
|
-
|
38
|
+
expect { described_class.new(connection_options) }.to raise_error(Grocer::NoGatewayError)
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'can be initialized with a gateway' do
|
@@ -44,7 +44,7 @@ describe Grocer::Connection do
|
|
44
44
|
|
45
45
|
it 'requires a port' do
|
46
46
|
connection_options.delete(:port)
|
47
|
-
|
47
|
+
expect { described_class.new(connection_options) }.to raise_error(Grocer::NoPortError)
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'can be initialized with a port' do
|
@@ -53,12 +53,12 @@ describe Grocer::Connection do
|
|
53
53
|
|
54
54
|
it 'can open the connection to the apple push notification service' do
|
55
55
|
subject.connect
|
56
|
-
ssl.
|
56
|
+
expect(ssl).to have_received(:connect)
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'raises CertificateExpiredError for OpenSSL::SSL::SSLError with /certificate expired/i message' do
|
60
60
|
ssl.stubs(:write).raises(OpenSSL::SSL::SSLError.new('certificate expired'))
|
61
|
-
|
61
|
+
expect {subject.write('abc123')}.to raise_error(Grocer::CertificateExpiredError)
|
62
62
|
end
|
63
63
|
|
64
64
|
context 'an open SSLConnection' do
|
@@ -68,12 +68,12 @@ describe Grocer::Connection do
|
|
68
68
|
|
69
69
|
it '#write delegates to open SSLConnection' do
|
70
70
|
subject.write('Apples to Oranges')
|
71
|
-
ssl.
|
71
|
+
expect(ssl).to have_received(:write).with('Apples to Oranges')
|
72
72
|
end
|
73
73
|
|
74
74
|
it '#read delegates to open SSLConnection' do
|
75
75
|
subject.read(42, 'IO')
|
76
|
-
ssl.
|
76
|
+
expect(ssl).to have_received(:read).with(42, 'IO')
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -84,14 +84,14 @@ describe Grocer::Connection do
|
|
84
84
|
|
85
85
|
it '#write connects SSLConnection and delegates to it' do
|
86
86
|
subject.write('Apples to Oranges')
|
87
|
-
ssl.
|
88
|
-
ssl.
|
87
|
+
expect(ssl).to have_received(:connect)
|
88
|
+
expect(ssl).to have_received(:write).with('Apples to Oranges')
|
89
89
|
end
|
90
90
|
|
91
91
|
it '#read connects SSLConnection delegates to open SSLConnection' do
|
92
92
|
subject.read(42, 'IO')
|
93
|
-
ssl.
|
94
|
-
ssl.
|
93
|
+
expect(ssl).to have_received(:connect)
|
94
|
+
expect(ssl).to have_received(:read).with(42, 'IO')
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -110,7 +110,7 @@ describe Grocer::Connection do
|
|
110
110
|
it 'raises the error if none of the retries work' do
|
111
111
|
connection_options[:retries] = 1
|
112
112
|
ssl.stubs(:read).raises(error).then.raises(error)
|
113
|
-
|
113
|
+
expect { subject.read }.to raise_error(error)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -4,7 +4,7 @@ describe Grocer::ErrorResponse do
|
|
4
4
|
let(:status_code) { 1 }
|
5
5
|
let(:identifier) { 8342 }
|
6
6
|
let(:binary_tuple) { [described_class::COMMAND, status_code, identifier].pack('CCN') }
|
7
|
-
let(:invalid_binary_tuple) { '
|
7
|
+
let(:invalid_binary_tuple) { 'short' }
|
8
8
|
|
9
9
|
subject(:error_response) { described_class.new(binary_tuple) }
|
10
10
|
|
@@ -15,8 +15,7 @@ describe Grocer::ErrorResponse do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'raises an exception when there are problems decoding' do
|
18
|
-
|
19
|
-
raise_error(Grocer::InvalidFormatError)
|
18
|
+
expect { described_class.new(invalid_binary_tuple) }.to raise_error(Grocer::InvalidFormatError)
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
@@ -5,7 +5,7 @@ describe Grocer::FailedDeliveryAttempt do
|
|
5
5
|
let(:timestamp) { Time.utc(1995, 12, 21) }
|
6
6
|
let(:device_token) { 'fe15a27d5df3c34778defb1f4f3980265cc52c0c047682223be59fb68500a9a2' }
|
7
7
|
let(:binary_tuple) { [timestamp.to_i, 32, device_token].pack('NnH64') }
|
8
|
-
let(:invalid_binary_tuple) { '
|
8
|
+
let(:invalid_binary_tuple) { 's' }
|
9
9
|
|
10
10
|
describe 'decoding' do
|
11
11
|
it 'accepts a binary tuple and sets each attribute' do
|
@@ -15,8 +15,7 @@ describe Grocer::FailedDeliveryAttempt do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'raises an exception when there are problems decoding' do
|
18
|
-
|
19
|
-
raise_error(Grocer::InvalidFormatError)
|
18
|
+
expect{ described_class.new(invalid_binary_tuple) }.to raise_error(Grocer::InvalidFormatError)
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
@@ -4,7 +4,7 @@ require 'grocer/feedback_connection'
|
|
4
4
|
describe Grocer::FeedbackConnection do
|
5
5
|
subject { described_class.new(options) }
|
6
6
|
let(:options) { { certificate: '/path/to/cert.pem' } }
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double('Connection') }
|
8
8
|
|
9
9
|
it 'delegates reading to the Connection' do
|
10
10
|
Grocer::Connection.any_instance.expects(:read).with(42, 'lolIO')
|
@@ -18,16 +18,16 @@ describe Grocer::Feedback do
|
|
18
18
|
let(:jan2) { Time.utc(2012, 1, 2) }
|
19
19
|
let(:device_token) { 'fe15a27d5df3c34778defb1f4f3880265cc52c0c047682223be59fb68500a9a2' }
|
20
20
|
|
21
|
-
subject { described_class.new(connection) }
|
21
|
+
subject(:feedback) { described_class.new(connection) }
|
22
22
|
|
23
23
|
it 'is enumerable' do
|
24
|
-
expect(
|
24
|
+
expect(feedback).to be_kind_of(Enumerable)
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'reads failed delivery attempt messages from the connection' do
|
28
28
|
stub_feedback
|
29
29
|
|
30
|
-
delivery_attempts =
|
30
|
+
delivery_attempts = feedback.to_a
|
31
31
|
|
32
32
|
expect(delivery_attempts[0].timestamp).to eq(jan1)
|
33
33
|
expect(delivery_attempts[0].device_token).to eq(device_token)
|
@@ -24,7 +24,7 @@ describe Grocer::MobileDeviceManagementNotification do
|
|
24
24
|
let(:notification) { Grocer::MobileDeviceManagementNotification.new(device_token: "token", alert: "Moo") }
|
25
25
|
|
26
26
|
it 'should raise a payload error' do
|
27
|
-
|
27
|
+
expect { notification.to_bytes }.to raise_error(Grocer::NoPayloadError)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ describe Grocer::MobileDeviceManagementNotification do
|
|
32
32
|
let(:notification) { Grocer::MobileDeviceManagementNotification.new(device_token: "token", push_magic: "00000000-1111-3333-4444-555555555555", alert: "test") }
|
33
33
|
|
34
34
|
it 'should raise a format error' do
|
35
|
-
|
35
|
+
expect { payload_dictionary_from_bytes }.to raise_error(Grocer::InvalidFormatError)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -68,7 +68,17 @@ describe Grocer::NotificationReader do
|
|
68
68
|
io.rewind
|
69
69
|
|
70
70
|
notification = subject.first
|
71
|
-
expect(notification.content_available).to
|
71
|
+
expect(notification.content_available).to be_truthy
|
72
|
+
expect(notification.content_available?).to be true
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'reports content not available when non is provided' do
|
76
|
+
io.write(Grocer::Notification.new(alert: 'Foo').to_bytes)
|
77
|
+
io.rewind
|
78
|
+
|
79
|
+
notification = subject.first
|
80
|
+
expect(notification.content_available).to be_falsey
|
81
|
+
expect(notification.content_available?).to be false
|
72
82
|
end
|
73
83
|
end
|
74
84
|
end
|
@@ -5,7 +5,7 @@ require 'grocer/shared_examples_for_notifications'
|
|
5
5
|
|
6
6
|
describe Grocer::Notification do
|
7
7
|
describe 'binary format' do
|
8
|
-
let(:payload_options) { { alert: 'hi', badge: 2, sound: 'siren.aiff' } }
|
8
|
+
let(:payload_options) { { alert: 'hi', badge: 2, sound: 'siren.aiff', category: 'a category' } }
|
9
9
|
let(:payload) { payload_hash(notification) }
|
10
10
|
|
11
11
|
include_examples 'a notification'
|
@@ -25,6 +25,11 @@ describe Grocer::Notification do
|
|
25
25
|
expect(payload[:aps][:sound]).to eq('siren.aiff')
|
26
26
|
end
|
27
27
|
|
28
|
+
it 'encodes category as part of the payload' do
|
29
|
+
notification.category = 'a different category'
|
30
|
+
expect(payload[:aps][:category]).to eq('a different category')
|
31
|
+
end
|
32
|
+
|
28
33
|
it 'encodes custom payload attributes' do
|
29
34
|
notification.custom = { :foo => 'bar' }
|
30
35
|
expect(payload[:foo]).to eq('bar')
|
@@ -56,18 +61,18 @@ describe Grocer::Notification do
|
|
56
61
|
end
|
57
62
|
|
58
63
|
it "is valid" do
|
59
|
-
expect(notification.valid?).to
|
64
|
+
expect(notification.valid?).to be true
|
60
65
|
end
|
61
66
|
|
62
67
|
context 'missing payload' do
|
63
68
|
let(:payload_options) { Hash.new }
|
64
69
|
|
65
70
|
it 'raises an error when none of alert, badge, or custom are specified' do
|
66
|
-
|
71
|
+
expect { notification.to_bytes }.to raise_error(Grocer::NoPayloadError)
|
67
72
|
end
|
68
73
|
|
69
74
|
it 'is not valid' do
|
70
|
-
expect(notification.valid?).to
|
75
|
+
expect(notification.valid?).to be false
|
71
76
|
end
|
72
77
|
|
73
78
|
[{alert: 'hi'}, {badge: 1}, {custom: {a: 'b'}}].each do |payload|
|
@@ -75,7 +80,7 @@ describe Grocer::Notification do
|
|
75
80
|
let(:payload_options) { payload }
|
76
81
|
|
77
82
|
it 'does not raise an error' do
|
78
|
-
|
83
|
+
expect { notification.to_bytes }.not_to raise_error
|
79
84
|
end
|
80
85
|
end
|
81
86
|
end
|
@@ -85,11 +90,11 @@ describe Grocer::Notification do
|
|
85
90
|
let(:payload_options) { { alert: 'a' * (Grocer::Notification::MAX_PAYLOAD_SIZE + 1) } }
|
86
91
|
|
87
92
|
it 'raises an error when the size of the payload in bytes is too large' do
|
88
|
-
|
93
|
+
expect { notification.to_bytes }.to raise_error(Grocer::PayloadTooLargeError)
|
89
94
|
end
|
90
95
|
|
91
96
|
it 'is not valid' do
|
92
|
-
expect(notification.valid?).to
|
97
|
+
expect(notification.valid?).to be false
|
93
98
|
end
|
94
99
|
end
|
95
100
|
end
|
@@ -4,7 +4,7 @@ require 'grocer/push_connection'
|
|
4
4
|
describe Grocer::PushConnection do
|
5
5
|
subject { described_class.new(options) }
|
6
6
|
let(:options) { { certificate: '/path/to/cert.pem' } }
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double('Connection') }
|
8
8
|
|
9
9
|
it 'delegates reading to the Connection' do
|
10
10
|
Grocer::Connection.any_instance.expects(:read).with(42, 'lolIO')
|
data/spec/grocer/pusher_spec.rb
CHANGED
@@ -38,7 +38,7 @@ describe Grocer::SafariNotification do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'is valid' do
|
41
|
-
expect(notification.valid?).to
|
41
|
+
expect(notification.valid?).to be true
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'missing parameters' do
|
@@ -46,11 +46,11 @@ describe Grocer::SafariNotification do
|
|
46
46
|
let(:payload_options) { { alert: { body: 'This is a body' } } }
|
47
47
|
|
48
48
|
it 'raises an error when title is missing' do
|
49
|
-
|
49
|
+
expect { notification.to_bytes }.to raise_error(ArgumentError)
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'is not valid' do
|
53
|
-
expect(notification.valid?).to
|
53
|
+
expect(notification.valid?).to be false
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -58,11 +58,11 @@ describe Grocer::SafariNotification do
|
|
58
58
|
let(:payload_options) { { alert: { title: 'This is a title' } } }
|
59
59
|
|
60
60
|
it 'raises an error when body is missing' do
|
61
|
-
|
61
|
+
expect { notification.to_bytes }.to raise_error(ArgumentError)
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'is not valid' do
|
65
|
-
expect(notification.valid?).to
|
65
|
+
expect(notification.valid?).to be false
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -71,11 +71,11 @@ describe Grocer::SafariNotification do
|
|
71
71
|
let(:payload_options) { { alert: { title: 'Test', body: 'a' * (Grocer::Notification::MAX_PAYLOAD_SIZE + 1) } } }
|
72
72
|
|
73
73
|
it 'raises an error when the size of the payload in bytes is too large' do
|
74
|
-
|
74
|
+
expect { notification.to_bytes }.to raise_error(Grocer::PayloadTooLargeError)
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'is not valid' do
|
78
|
-
expect(notification.valid?).to
|
78
|
+
expect(notification.valid?).to be false
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -67,13 +67,13 @@ describe Grocer::SSLConnection do
|
|
67
67
|
|
68
68
|
it 'sets up an socket connection' do
|
69
69
|
subject.connect
|
70
|
-
TCPSocket.
|
70
|
+
expect(TCPSocket).to have_received(:new).with(connection_options[:gateway],
|
71
71
|
connection_options[:port])
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'sets up an SSL connection' do
|
75
75
|
subject.connect
|
76
|
-
OpenSSL::SSL::SSLSocket.
|
76
|
+
expect(OpenSSL::SSL::SSLSocket).to have_received(:new).with(mock_socket, anything)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -87,7 +87,7 @@ describe Grocer::SSLConnection do
|
|
87
87
|
subject.connect
|
88
88
|
subject.write('abc123')
|
89
89
|
|
90
|
-
mock_ssl.
|
90
|
+
expect(mock_ssl).to have_received(:write).with('abc123')
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -101,7 +101,7 @@ describe Grocer::SSLConnection do
|
|
101
101
|
subject.connect
|
102
102
|
subject.read(42)
|
103
103
|
|
104
|
-
mock_ssl.
|
104
|
+
expect(mock_ssl).to have_received(:read).with(42)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
data/spec/grocer_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe Grocer do
|
|
40
40
|
|
41
41
|
it 'passes the connection options on to the underlying Connection' do
|
42
42
|
subject.pusher(connection_options)
|
43
|
-
Grocer::PushConnection.
|
43
|
+
expect(Grocer::PushConnection).to have_received(:new).with(connection_options)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -55,7 +55,7 @@ describe Grocer do
|
|
55
55
|
|
56
56
|
it 'passes the connection options on to the underlying Connection' do
|
57
57
|
subject.feedback(connection_options)
|
58
|
-
Grocer::FeedbackConnection.
|
58
|
+
expect(Grocer::FeedbackConnection).to have_received(:new).with(connection_options)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -71,7 +71,7 @@ describe Grocer do
|
|
71
71
|
|
72
72
|
it 'passes the connection options on to the underlying SSLServer' do
|
73
73
|
subject.server(connection_options)
|
74
|
-
Grocer::SSLServer.
|
74
|
+
expect(Grocer::SSLServer).to have_received(:new).with(connection_options)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
ENV['RACK_ENV'] = 'test'
|
2
|
+
|
3
|
+
if ENV['CODECLIMATE_REPO_TOKEN']
|
4
|
+
require 'codeclimate-test-reporter'
|
5
|
+
CodeClimate::TestReporter.start
|
6
|
+
end
|
7
|
+
|
2
8
|
require 'mocha/api'
|
3
9
|
require 'bourne'
|
4
10
|
require 'support/notification_helpers'
|
11
|
+
require 'grocer'
|
5
12
|
|
6
13
|
RSpec.configure do |config|
|
7
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
14
|
config.run_all_when_everything_filtered = true
|
9
15
|
config.filter_run :focus
|
10
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grocer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Lindeman
|
@@ -10,76 +10,76 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.0.0.rc1
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 3.0.0.rc1
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: pry
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: 0.9.8
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 0.9.8
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: mocha
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: bourne
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rake
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
description: |2
|
@@ -100,9 +100,9 @@ executables: []
|
|
100
100
|
extensions: []
|
101
101
|
extra_rdoc_files: []
|
102
102
|
files:
|
103
|
-
- .gitignore
|
104
|
-
- .rspec
|
105
|
-
- .travis.yml
|
103
|
+
- ".gitignore"
|
104
|
+
- ".rspec"
|
105
|
+
- ".travis.yml"
|
106
106
|
- CHANGELOG.md
|
107
107
|
- Gemfile
|
108
108
|
- LICENSE
|
@@ -165,17 +165,17 @@ require_paths:
|
|
165
165
|
- lib
|
166
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- -
|
168
|
+
- - ">="
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
172
|
requirements:
|
173
|
-
- -
|
173
|
+
- - ">="
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.1
|
178
|
+
rubygems_version: 2.4.1
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Pushing Apple notifications since 2012.
|
@@ -204,4 +204,3 @@ test_files:
|
|
204
204
|
- spec/grocer_spec.rb
|
205
205
|
- spec/spec_helper.rb
|
206
206
|
- spec/support/notification_helpers.rb
|
207
|
-
has_rdoc:
|