rpush 2.3.1-java → 2.3.2-java
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/CHANGELOG.md +6 -0
- data/README.md +36 -28
- data/lib/rpush/configuration.rb +1 -0
- data/lib/rpush/daemon/feeder.rb +16 -12
- data/lib/rpush/daemon/interruptible_sleep.rb +26 -5
- data/lib/rpush/daemon/store/active_record.rb +4 -0
- data/lib/rpush/daemon/store/interface.rb +1 -1
- data/lib/rpush/daemon/store/redis.rb +10 -0
- data/lib/rpush/embed.rb +1 -0
- data/lib/rpush/logger.rb +1 -0
- data/lib/rpush/push.rb +1 -2
- data/lib/rpush/version.rb +1 -1
- data/spec/functional/adm_spec.rb +6 -8
- data/spec/functional/apns_spec.rb +9 -9
- data/spec/functional/embed_spec.rb +3 -3
- data/spec/functional/gcm_spec.rb +6 -8
- data/spec/functional/new_app_spec.rb +5 -20
- data/spec/functional/retry_spec.rb +8 -12
- data/spec/functional/synchronization_spec.rb +1 -1
- data/spec/functional/wpns_spec.rb +7 -7
- data/spec/functional_spec_helper.rb +4 -5
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/apns_feedback_spec.rb +4 -4
- data/spec/unit/client/active_record/adm/app_spec.rb +12 -12
- data/spec/unit/client/active_record/adm/notification_spec.rb +9 -9
- data/spec/unit/client/active_record/apns/app_spec.rb +4 -4
- data/spec/unit/client/active_record/apns/feedback_spec.rb +2 -2
- data/spec/unit/client/active_record/apns/notification_spec.rb +46 -46
- data/spec/unit/client/active_record/app_spec.rb +6 -6
- data/spec/unit/client/active_record/gcm/notification_spec.rb +7 -7
- data/spec/unit/client/active_record/notification_spec.rb +2 -2
- data/spec/unit/client/active_record/wpns/notification_spec.rb +2 -8
- data/spec/unit/configuration_spec.rb +5 -5
- data/spec/unit/daemon/adm/delivery_spec.rb +69 -69
- data/spec/unit/daemon/apns/delivery_spec.rb +13 -13
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +24 -26
- data/spec/unit/daemon/app_runner_spec.rb +29 -29
- data/spec/unit/daemon/batch_spec.rb +30 -30
- data/spec/unit/daemon/delivery_error_spec.rb +2 -2
- data/spec/unit/daemon/delivery_spec.rb +6 -6
- data/spec/unit/daemon/dispatcher/http_spec.rb +5 -5
- data/spec/unit/daemon/dispatcher/tcp_spec.rb +4 -4
- data/spec/unit/daemon/dispatcher_loop_spec.rb +9 -9
- data/spec/unit/daemon/feeder_spec.rb +22 -23
- data/spec/unit/daemon/gcm/delivery_spec.rb +56 -56
- data/spec/unit/daemon/retryable_error_spec.rb +2 -2
- data/spec/unit/daemon/service_config_methods_spec.rb +5 -5
- data/spec/unit/daemon/signal_handler_spec.rb +13 -13
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +13 -13
- data/spec/unit/daemon/store/active_record_spec.rb +49 -49
- data/spec/unit/daemon/tcp_connection_spec.rb +50 -50
- data/spec/unit/daemon/wpns/delivery_spec.rb +36 -36
- data/spec/unit/daemon_spec.rb +33 -30
- data/spec/unit/deprecatable_spec.rb +3 -3
- data/spec/unit/deprecation_spec.rb +2 -2
- data/spec/unit/embed_spec.rb +7 -7
- data/spec/unit/logger_spec.rb +25 -25
- data/spec/unit/notification_shared.rb +7 -7
- data/spec/unit/plugin_spec.rb +1 -1
- data/spec/unit/push_spec.rb +8 -8
- data/spec/unit/reflectable_spec.rb +5 -5
- data/spec/unit/reflection_collection_spec.rb +2 -2
- data/spec/unit/rpush_spec.rb +1 -1
- data/spec/unit_spec_helper.rb +4 -5
- metadata +10 -4
data/spec/unit/daemon_spec.rb
CHANGED
@@ -9,58 +9,61 @@ describe Rpush::Daemon, "when starting" do
|
|
9
9
|
let(:logger) { double(:logger, info: nil, error: nil, warn: nil, internal_logger: nil) }
|
10
10
|
|
11
11
|
before do
|
12
|
-
Rpush.
|
13
|
-
Rpush::Daemon::Feeder.
|
14
|
-
Rpush::Daemon::Synchronizer.
|
15
|
-
Rpush::Daemon::AppRunner.
|
16
|
-
Rpush::Daemon.
|
17
|
-
Rpush::Daemon
|
18
|
-
|
19
|
-
|
12
|
+
allow(Rpush).to receive(:logger) { logger }
|
13
|
+
allow(Rpush::Daemon::Feeder).to receive(:start)
|
14
|
+
allow(Rpush::Daemon::Synchronizer).to receive(:sync)
|
15
|
+
allow(Rpush::Daemon::AppRunner).to receive(:stop)
|
16
|
+
allow(Rpush::Daemon).to receive(:exit)
|
17
|
+
allow(Rpush::Daemon).to receive(:puts)
|
18
|
+
allow(Rpush::Daemon::SignalHandler).to receive(:start)
|
19
|
+
allow(Rpush::Daemon::SignalHandler).to receive(:stop)
|
20
|
+
allow(Rpush::Daemon::SignalHandler).to receive(:handle_shutdown_signal)
|
21
|
+
allow(Process).to receive(:daemon)
|
22
|
+
allow(File).to receive(:open)
|
20
23
|
end
|
21
24
|
|
22
25
|
unless Rpush.jruby?
|
23
26
|
it "forks into a daemon if the foreground option is false" do
|
24
27
|
Rpush.config.foreground = false
|
25
28
|
Rpush::Daemon.common_init
|
26
|
-
Process.
|
29
|
+
expect(Process).to receive(:daemon)
|
27
30
|
Rpush::Daemon.start
|
28
31
|
end
|
29
32
|
|
30
33
|
it "does not fork into a daemon if the foreground option is true" do
|
31
34
|
Rpush.config.foreground = true
|
32
|
-
Process.
|
35
|
+
expect(Process).to_not receive(:daemon)
|
33
36
|
Rpush::Daemon.start
|
34
37
|
end
|
35
38
|
|
36
39
|
it "does not fork into a daemon if the push option is true" do
|
37
40
|
Rpush.config.push = true
|
38
|
-
Process.
|
41
|
+
expect(Process).to_not receive(:daemon)
|
39
42
|
Rpush::Daemon.start
|
40
43
|
end
|
41
44
|
|
42
45
|
it "does not fork into a daemon if the embedded option is true" do
|
43
46
|
Rpush.config.embedded = true
|
44
|
-
Process.
|
47
|
+
expect(Process).to_not receive(:daemon)
|
45
48
|
Rpush::Daemon.start
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
52
|
it 'releases the store connection' do
|
50
53
|
Rpush::Daemon.store = double
|
51
|
-
Rpush::Daemon.store.
|
54
|
+
expect(Rpush::Daemon.store).to receive(:release_connection)
|
52
55
|
Rpush::Daemon.start
|
53
56
|
end
|
54
57
|
|
55
58
|
it 'sets up setup signal traps' do
|
56
|
-
Rpush::Daemon::SignalHandler.
|
59
|
+
expect(Rpush::Daemon::SignalHandler).to receive(:start)
|
57
60
|
Rpush::Daemon.start
|
58
61
|
end
|
59
62
|
|
60
63
|
it 'instantiates the store' do
|
61
64
|
Rpush.config.client = :active_record
|
62
65
|
Rpush::Daemon.start
|
63
|
-
Rpush::Daemon.store.
|
66
|
+
expect(Rpush::Daemon.store).to be_kind_of(Rpush::Daemon::Store::ActiveRecord)
|
64
67
|
end
|
65
68
|
|
66
69
|
it 'initializes plugins' do
|
@@ -68,65 +71,65 @@ describe Rpush::Daemon, "when starting" do
|
|
68
71
|
did_init = false
|
69
72
|
plugin.init { did_init = true }
|
70
73
|
Rpush::Daemon.common_init
|
71
|
-
expect(did_init).to
|
74
|
+
expect(did_init).to eq(true)
|
72
75
|
end
|
73
76
|
|
74
77
|
it 'logs an error if the store cannot be loaded' do
|
75
78
|
Rpush.config.client = :foo_bar
|
76
|
-
Rpush.logger.
|
77
|
-
Rpush::Daemon.
|
79
|
+
expect(Rpush.logger).to receive(:error).with(kind_of(LoadError))
|
80
|
+
allow(Rpush::Daemon).to receive(:exit) { Rpush::Daemon.store = double.as_null_object }
|
78
81
|
Rpush::Daemon.start
|
79
82
|
end
|
80
83
|
|
81
84
|
it "writes the process ID to the PID file" do
|
82
|
-
Rpush::Daemon.
|
85
|
+
expect(Rpush::Daemon).to receive(:write_pid_file)
|
83
86
|
Rpush::Daemon.start
|
84
87
|
end
|
85
88
|
|
86
89
|
it "logs an error if the PID file could not be written" do
|
87
90
|
Rpush.config.pid_file = '/rails_root/rpush.pid'
|
88
|
-
File.
|
89
|
-
logger.
|
91
|
+
allow(File).to receive(:open).and_raise(Errno::ENOENT)
|
92
|
+
expect(logger).to receive(:error).with(%r{Failed to write PID to '/rails_root/rpush\.pid'})
|
90
93
|
Rpush::Daemon.start
|
91
94
|
end
|
92
95
|
|
93
96
|
it "starts the feeder" do
|
94
|
-
Rpush::Daemon::Feeder.
|
97
|
+
expect(Rpush::Daemon::Feeder).to receive(:start)
|
95
98
|
Rpush::Daemon.start
|
96
99
|
end
|
97
100
|
|
98
101
|
it "syncs apps" do
|
99
|
-
Rpush::Daemon::Synchronizer.
|
102
|
+
expect(Rpush::Daemon::Synchronizer).to receive(:sync)
|
100
103
|
Rpush::Daemon.start
|
101
104
|
end
|
102
105
|
|
103
106
|
describe "shutdown" do
|
104
107
|
it "stops the feeder" do
|
105
|
-
Rpush::Daemon::Feeder.
|
108
|
+
expect(Rpush::Daemon::Feeder).to receive(:stop)
|
106
109
|
Rpush::Daemon.shutdown
|
107
110
|
end
|
108
111
|
|
109
112
|
it "stops the app runners" do
|
110
|
-
Rpush::Daemon::AppRunner.
|
113
|
+
expect(Rpush::Daemon::AppRunner).to receive(:stop)
|
111
114
|
Rpush::Daemon.shutdown
|
112
115
|
end
|
113
116
|
|
114
117
|
it "removes the PID file if one was written" do
|
115
118
|
Rpush.config.pid_file = "/rails_root/rpush.pid"
|
116
|
-
File.
|
117
|
-
File.
|
119
|
+
allow(File).to receive(:exist?) { true }
|
120
|
+
expect(File).to receive(:delete).with("/rails_root/rpush.pid")
|
118
121
|
Rpush::Daemon.shutdown
|
119
122
|
end
|
120
123
|
|
121
124
|
it "does not attempt to remove the PID file if it does not exist" do
|
122
|
-
File.
|
123
|
-
File.
|
125
|
+
allow(File).to receive(:exist?) { false }
|
126
|
+
expect(File).to_not receive(:delete)
|
124
127
|
Rpush::Daemon.shutdown
|
125
128
|
end
|
126
129
|
|
127
130
|
it "does not attempt to remove the PID file if one was not written" do
|
128
131
|
Rpush.config.pid_file = nil
|
129
|
-
File.
|
132
|
+
expect(File).to_not receive(:delete)
|
130
133
|
Rpush::Daemon.shutdown
|
131
134
|
end
|
132
135
|
end
|
@@ -17,16 +17,16 @@ describe Rpush::Deprecatable do
|
|
17
17
|
let(:klass) { HasDeprecatedMethod.new }
|
18
18
|
|
19
19
|
before do
|
20
|
-
Rpush::Deprecation.
|
20
|
+
allow(Rpush::Deprecation).to receive(:warn)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'warns the method is deprecated when called' do
|
24
|
-
Rpush::Deprecation.
|
24
|
+
expect(Rpush::Deprecation).to receive(:warn).with(/deprecated_method is deprecated and will be removed from Rpush 4\.0\./)
|
25
25
|
klass.deprecated_method
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'calls the original method' do
|
29
29
|
klass.deprecated_method
|
30
|
-
klass.original_called
|
30
|
+
expect(klass.original_called?).to eq(true)
|
31
31
|
end
|
32
32
|
end
|
@@ -2,12 +2,12 @@ require 'unit_spec_helper'
|
|
2
2
|
|
3
3
|
describe Rpush::Deprecation do
|
4
4
|
it 'prints a warning' do
|
5
|
-
STDERR.
|
5
|
+
expect(STDERR).to receive(:puts).with("DEPRECATION WARNING: msg")
|
6
6
|
Rpush::Deprecation.warn("msg")
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'does not print a warning when muted' do
|
10
|
-
STDERR.
|
10
|
+
expect(STDERR).not_to receive(:puts)
|
11
11
|
Rpush::Deprecation.muted do
|
12
12
|
Rpush::Deprecation.warn("msg")
|
13
13
|
end
|
data/spec/unit/embed_spec.rb
CHANGED
@@ -2,19 +2,19 @@ require 'unit_spec_helper'
|
|
2
2
|
|
3
3
|
describe Rpush, 'embed' do
|
4
4
|
before do
|
5
|
-
Rpush::Daemon.
|
6
|
-
Kernel.
|
5
|
+
allow(Rpush::Daemon).to receive_messages(start: nil, shutdown: nil)
|
6
|
+
allow(Kernel).to receive(:at_exit)
|
7
7
|
end
|
8
8
|
|
9
9
|
after { Rpush.shutdown }
|
10
10
|
|
11
11
|
it 'sets the embedded config option to true' do
|
12
12
|
Rpush.embed
|
13
|
-
Rpush.config.embedded.
|
13
|
+
expect(Rpush.config.embedded).to eq(true)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'starts the daemon' do
|
17
|
-
Rpush::Daemon.
|
17
|
+
expect(Rpush::Daemon).to receive(:start)
|
18
18
|
Rpush.embed
|
19
19
|
end
|
20
20
|
|
@@ -28,7 +28,7 @@ describe Rpush, 'shutdown' do
|
|
28
28
|
before { Rpush.config.embedded = true }
|
29
29
|
|
30
30
|
it 'shuts down the daemon' do
|
31
|
-
Rpush::Daemon.
|
31
|
+
expect(Rpush::Daemon).to receive(:shutdown)
|
32
32
|
Rpush.shutdown
|
33
33
|
end
|
34
34
|
end
|
@@ -37,7 +37,7 @@ describe Rpush, 'sync' do
|
|
37
37
|
before { Rpush.config.embedded = true }
|
38
38
|
|
39
39
|
it 'syncs' do
|
40
|
-
Rpush::Daemon::Synchronizer.
|
40
|
+
expect(Rpush::Daemon::Synchronizer).to receive(:sync)
|
41
41
|
Rpush.sync
|
42
42
|
end
|
43
43
|
end
|
@@ -46,7 +46,7 @@ describe Rpush, 'debug' do
|
|
46
46
|
before { Rpush.config.embedded = true }
|
47
47
|
|
48
48
|
it 'debugs the AppRunner' do
|
49
|
-
Rpush::Daemon::AppRunner.
|
49
|
+
expect(Rpush::Daemon::AppRunner).to receive(:debug)
|
50
50
|
Rpush.debug
|
51
51
|
end
|
52
52
|
end
|
data/spec/unit/logger_spec.rb
CHANGED
@@ -9,34 +9,34 @@ describe Rpush::Logger do
|
|
9
9
|
|
10
10
|
before do
|
11
11
|
@logger_class = defined?(ActiveSupport::BufferedLogger) ? ActiveSupport::BufferedLogger : ActiveSupport::Logger
|
12
|
-
@logger = double(@logger_class.name, info: nil, error: nil, level: 0, auto_flushing:
|
13
|
-
@logger_class.
|
14
|
-
Rails.
|
15
|
-
File.
|
16
|
-
FileUtils.
|
17
|
-
STDERR.
|
12
|
+
@logger = double(@logger_class.name, info: nil, error: nil, level: 0, auto_flushing: true, :auto_flushing= => nil)
|
13
|
+
allow(@logger_class).to receive(:new).and_return(@logger)
|
14
|
+
allow(Rails).to receive_messages(logger: @logger)
|
15
|
+
allow(File).to receive_messages(open: log)
|
16
|
+
allow(FileUtils).to receive_messages(mkdir_p: nil)
|
17
|
+
allow(STDERR).to receive(:puts)
|
18
18
|
Rpush.config.foreground = true
|
19
19
|
Rpush.config.log_file = 'log/rpush.log'
|
20
20
|
end
|
21
21
|
|
22
22
|
it "disables logging if the log file cannot be opened" do
|
23
|
-
File.
|
24
|
-
STDERR.
|
23
|
+
allow(File).to receive(:open).and_raise(Errno::ENOENT)
|
24
|
+
expect(STDERR).to receive(:puts).with(/Logging disabled/)
|
25
25
|
Rpush::Logger.new
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'creates the log directory' do
|
29
|
-
FileUtils.
|
29
|
+
expect(FileUtils).to receive(:mkdir_p).with('/tmp/rails_root/log')
|
30
30
|
Rpush::Logger.new
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should open the a log file in the Rails log directory" do
|
34
|
-
File.
|
34
|
+
expect(File).to receive(:open).with('/tmp/rails_root/log/rpush.log', 'a')
|
35
35
|
Rpush::Logger.new
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'sets sync mode on the log descriptor' do
|
39
|
-
log.
|
39
|
+
expect(log).to receive(:sync=).with(true)
|
40
40
|
Rpush::Logger.new
|
41
41
|
end
|
42
42
|
|
@@ -44,28 +44,28 @@ describe Rpush::Logger do
|
|
44
44
|
my_logger = double
|
45
45
|
Rpush.config.logger = my_logger
|
46
46
|
logger = Rpush::Logger.new
|
47
|
-
my_logger.
|
47
|
+
expect(my_logger).to receive(:info)
|
48
48
|
Rpush.config.foreground = false
|
49
49
|
logger.info('test')
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'uses ActiveSupport::BufferedLogger if a user-defined logger is not set' do
|
53
53
|
if ActiveSupport.const_defined?('BufferedLogger')
|
54
|
-
ActiveSupport::BufferedLogger.
|
54
|
+
expect(ActiveSupport::BufferedLogger).to receive(:new).with(log, Rails.logger.level)
|
55
55
|
Rpush::Logger.new
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'uses ActiveSupport::Logger if BufferedLogger does not exist' do
|
60
60
|
stub_const('ActiveSupport::Logger', double)
|
61
|
-
ActiveSupport.
|
62
|
-
ActiveSupport::Logger.
|
61
|
+
allow(ActiveSupport).to receive_messages(:const_defined? => false)
|
62
|
+
expect(ActiveSupport::Logger).to receive(:new).with(log, Rails.logger.level)
|
63
63
|
Rpush::Logger.new
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should print out the msg if running in the foreground" do
|
67
67
|
logger = Rpush::Logger.new
|
68
|
-
STDOUT.
|
68
|
+
expect(STDOUT).to receive(:puts).with(/hi mom/)
|
69
69
|
logger.info("hi mom")
|
70
70
|
end
|
71
71
|
|
@@ -73,7 +73,7 @@ describe Rpush::Logger do
|
|
73
73
|
it "should not print out the msg if not running in the foreground" do
|
74
74
|
Rpush.config.foreground = false
|
75
75
|
logger = Rpush::Logger.new
|
76
|
-
STDOUT.
|
76
|
+
expect(STDOUT).not_to receive(:puts).with(/hi mom/)
|
77
77
|
logger.info("hi mom")
|
78
78
|
end
|
79
79
|
end
|
@@ -81,38 +81,38 @@ describe Rpush::Logger do
|
|
81
81
|
it "should prefix log lines with the current time" do
|
82
82
|
Rpush.config.foreground = false
|
83
83
|
now = Time.now
|
84
|
-
Time.
|
84
|
+
allow(Time).to receive(:now).and_return(now)
|
85
85
|
logger = Rpush::Logger.new
|
86
|
-
@logger.
|
86
|
+
expect(@logger).to receive(:info).with(/#{Regexp.escape("[#{now.to_s(:db)}]")}/)
|
87
87
|
logger.info("blah")
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should prefix error logs with the ERROR label" do
|
91
91
|
Rpush.config.foreground = false
|
92
92
|
logger = Rpush::Logger.new
|
93
|
-
@logger.
|
93
|
+
expect(@logger).to receive(:error).with(/#{Regexp.escape("[ERROR]")}/)
|
94
94
|
logger.error("eeek")
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should prefix warn logs with the WARNING label" do
|
98
98
|
Rpush.config.foreground = false
|
99
99
|
logger = Rpush::Logger.new
|
100
|
-
@logger.
|
100
|
+
expect(@logger).to receive(:warn).with(/#{Regexp.escape("[WARNING]")}/)
|
101
101
|
logger.warn("eeek")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should handle an Exception instance" do
|
105
105
|
Rpush.config.foreground = false
|
106
106
|
e = RuntimeError.new("hi mom")
|
107
|
-
e.
|
107
|
+
allow(e).to receive_messages(backtrace: [])
|
108
108
|
logger = Rpush::Logger.new
|
109
|
-
@logger.
|
109
|
+
expect(@logger).to receive(:error).with(/RuntimeError, hi mom/)
|
110
110
|
logger.error(e)
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'defaults auto_flushing to true if the Rails logger does not respond to auto_flushing' do
|
114
|
-
Rails.
|
114
|
+
allow(Rails).to receive_messages(logger: double(info: nil, error: nil, level: 0))
|
115
115
|
Rpush::Logger.new
|
116
|
-
@logger.auto_flushing.
|
116
|
+
expect(@logger.auto_flushing).to eq(true)
|
117
117
|
end
|
118
118
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
shared_examples_for "an Notification subclass" do
|
2
2
|
describe "when assigning data for the device" do
|
3
|
-
before { Rpush::Deprecation.
|
3
|
+
before { allow(Rpush::Deprecation).to receive(:warn) }
|
4
4
|
|
5
5
|
it "calls MultiJson.dump when multi_json responds to :dump" do
|
6
6
|
notification = notification_class.new
|
7
|
-
MultiJson.
|
8
|
-
MultiJson.
|
7
|
+
allow(MultiJson).to receive(:respond_to?).with(:dump).and_return(true)
|
8
|
+
expect(MultiJson).to receive(:dump).with(any_args)
|
9
9
|
notification.data = { pirates: 1 }
|
10
10
|
end
|
11
11
|
|
12
12
|
it "calls MultiJson.encode when multi_json does not respond to :dump" do
|
13
13
|
notification = notification_class.new
|
14
|
-
MultiJson.
|
15
|
-
MultiJson.
|
14
|
+
allow(MultiJson).to receive(:respond_to?).with(:dump).and_return(false)
|
15
|
+
expect(MultiJson).to receive(:encode).with(any_args)
|
16
16
|
notification.data = { ninjas: 1 }
|
17
17
|
end
|
18
18
|
|
@@ -24,12 +24,12 @@ shared_examples_for "an Notification subclass" do
|
|
24
24
|
|
25
25
|
it "encodes the given Hash as JSON" do
|
26
26
|
notification.data = { hi: "mom" }
|
27
|
-
notification.read_attribute(:data).
|
27
|
+
expect(notification.read_attribute(:data)).to eq("{\"hi\":\"mom\"}")
|
28
28
|
end
|
29
29
|
|
30
30
|
it "decodes the JSON when using the reader method" do
|
31
31
|
notification.data = { hi: "mom" }
|
32
|
-
notification.data.
|
32
|
+
expect(notification.data).to eq("hi" => "mom")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/spec/unit/plugin_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Rpush::Plugin do
|
|
20
20
|
plugin.configure do |config|
|
21
21
|
config.is_configured = true
|
22
22
|
end
|
23
|
-
expect(Rpush.config.plugin.test.is_configured).to
|
23
|
+
expect(Rpush.config.plugin.test.is_configured).to eq(true)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'can hook up reflections' do
|
data/spec/unit/push_spec.rb
CHANGED
@@ -2,33 +2,33 @@ require 'unit_spec_helper'
|
|
2
2
|
|
3
3
|
describe Rpush, 'push' do
|
4
4
|
before do
|
5
|
-
Rpush::Daemon::Synchronizer.
|
6
|
-
Rpush::Daemon::AppRunner.
|
7
|
-
Rpush::Daemon::Feeder.
|
5
|
+
allow(Rpush::Daemon::Synchronizer).to receive_messages(sync: nil)
|
6
|
+
allow(Rpush::Daemon::AppRunner).to receive_messages(wait: nil)
|
7
|
+
allow(Rpush::Daemon::Feeder).to receive_messages(start: nil)
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'sets the push config option to true' do
|
11
11
|
Rpush.push
|
12
|
-
Rpush.config.push.
|
12
|
+
expect(Rpush.config.push).to eq(true)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'initializes the daemon' do
|
16
|
-
Rpush::Daemon.
|
16
|
+
expect(Rpush::Daemon).to receive(:common_init)
|
17
17
|
Rpush.push
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'syncs' do
|
21
|
-
Rpush::Daemon::Synchronizer.
|
21
|
+
expect(Rpush::Daemon::Synchronizer).to receive(:sync)
|
22
22
|
Rpush.push
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'starts the feeder' do
|
26
|
-
Rpush::Daemon::Feeder.
|
26
|
+
expect(Rpush::Daemon::Feeder).to receive(:start)
|
27
27
|
Rpush.push
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'stops on the app runner' do
|
31
|
-
Rpush::Daemon::AppRunner.
|
31
|
+
expect(Rpush::Daemon::AppRunner).to receive(:stop)
|
32
32
|
Rpush.push
|
33
33
|
end
|
34
34
|
|