Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove rapns.yml in favour of command-line switches.

  • Loading branch information...
commit 972a92d9a03445349c1b2ec23de39eb25f0d0c0f 1 parent aeaa3c2
@ileitch authored
View
34 README.md
@@ -61,11 +61,17 @@ The APNs environment is automatically detected from the app certificate, you do
## Starting the rapns Daemon
cd /path/to/rails/app
- bundle exec rapns <Rails environment>
+ bundle exec rapns <Rails environment> [options]
### Options
-* `--foreground` will prevent rapns from forking into a daemon.
+* `-f` `--foreground` Prevent rapns from forking into a daemon.
+* '-P N' '--db-poll N' Frequency in seconds to check for new notifications. Default: 2.
+* '-F N' '--feedback-poll N' Frequency in seconds to check for feedback. Default: 60.
+* '-e' '--no-error-checks' Disables [error checking](#immediately-when-processing-a-notification-for-delivery) after notification delivery. You may want to disable this if you are sending a very high number of notifications.
+* '-n' '--no-airbrake-notify' Disables error notifications via Airbrake.
+* '-p PATH' '--pid-file PATH' Path to write PID file. Relative to Rails root unless absolute.
+* '-b N' '--batch-size N' ActiveRecord batch size of notifications. Increase for possible higher throughput but higher memory footprint. Default: 5000.
## Sending a Notification
@@ -96,28 +102,6 @@ The APNs environment is automatically detected from the app certificate, you do
Please refer to Apple's [documentation](http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1) (Tables 3-1 and 3-2).
-## Configuration
-
-Environment configuration lives in `config/rapns/rapns.yml`. For common setups you probably wont need to change this file.
-
-If you want to use rapns in environments other than development or production, you will need to create an entry for it. Simply duplicate the configuration for development or production, depending on which iOS Push Certificate you wish to use.
-
-### Options
-
-* `push` this section contains options to configure the delivery of notifications.
- * `poll` (default: 2) Frequency in seconds to check for new notifications to deliver.
-
-* `feedback` this section contains options to configure feedback checking.
- * `poll` (default: 60) Frequency in seconds to check for new feedback.
-
-* `airbrake_notify` (default: true) Enables/disables error notifications via Airbrake.
-* `pid_file` (default: blank) the file that rapns will write its process ID to. Paths are relative to your project's RAILS_ROOT unless an absolute path is given.
-
-#### Advanced Options
-
-* `check_for_errors` (default: true) Enables/disables [error checking](#immediately-when-processing-a-notification-for-delivery) after notification delivery. You may want to disable this if you are sending a very high number of notifications.
-* `feeder_batch_size` (default: 5000) Sets the ActiveRecord batch size of notifications. Increase for possible higher throughput but higher memory footprint.
-
## Hot App Updates
If you signal the rapns process with `HUP` it will synchronize with the current `Rapns::App` configurations. This includes adding an app, removing and increasing/decreasing the number of connections an app uses.
@@ -153,7 +137,7 @@ It is your responsibility to avoid creating new notifications for devices that n
## Updating rapns
-After updating you should run `rails g rapns` to check for any new migrations or configuration changes.
+After updating you should run `rails g rapns` to check for any new migrations.
## Wiki
View
24 bin/rapns
@@ -3,12 +3,26 @@
require 'optparse'
require 'rapns'
-foreground = false
environment = ARGV[0]
+
+config = Struct.new(:foreground, :push_poll, :feedback_poll, :airbrake_notify, :check_for_errors, :pid_file, :batch_size).new
+config.foreground = false
+config.push_poll = 2
+config.feedback_poll = 60
+config.airbrake_notify = true
+config.check_for_errors = true
+config.batch_size = 5000
+
banner = 'Usage: rapns <Rails environment> [options]'
ARGV.options do |opts|
opts.banner = banner
- opts.on('-f', '--foreground', 'Run in the foreground.') { foreground = true }
+ opts.on('-f', '--foreground', 'Run in the foreground.') { config.foreground = true }
+ opts.on('-P N', '--db-poll N', Integer, "Frequency in seconds to check for new notifications. Default: #{config.push_poll}.") { |n| config.push_poll = n }
+ opts.on('-F N', '--feedback-poll N', Integer, "Frequency in seconds to check for feedback. Default: #{config.feedback_poll}.") { |n| config.feedback_poll = n }
+ opts.on('-e', '--no-error-checks', 'Disable error checking after notification delivery.') { config.airbrake_notify = false }
+ opts.on('-n', '--no-airbrake-notify', 'Disables error notifications via Airbrake.') { config.check_for_errors = false }
+ opts.on('-p PATH', '--pid-file PATH', String, 'Path to write PID file. Relative to Rails root unless absolute.') { |path| config.pid_file = path }
+ opts.on('-b N', '--batch-size N', Integer, 'ActiveRecord notifications batch size.') { |n| config.batch_size = n }
opts.on('-v', '--version', 'Print this version of rapns.') { puts "rapns #{Rapns::VERSION}"; exit }
opts.on('-h', '--help', 'You\'re looking at it.') { puts opts; exit }
opts.parse!
@@ -25,4 +39,8 @@ load 'config/environment.rb'
require 'rapns/daemon'
require 'rapns/patches'
-Rapns::Daemon.start(environment, foreground)
+if config.pid_file && !Pathname.new(config.pid_file).absolute?
+ config.pid_file = File.join(Rails.root, config.pid_file)
+end
+
+Rapns::Daemon.start(environment, config)
View
4 lib/generators/rapns_generator.rb
@@ -17,10 +17,6 @@ def copy_migration
add_rapns_migration('create_rapns_apps')
end
- def copy_config
- copy_file 'rapns.yml', 'config/rapns/rapns.yml'
- end
-
protected
def add_rapns_migration(template)
View
24 lib/generators/templates/rapns.yml
@@ -1,24 +0,0 @@
-development:
- push:
- host: gateway.sandbox.push.apple.com
- port: 2195
- poll: 2
-
- feedback:
- host: feedback.sandbox.push.apple.com
- port: 2196
- poll: 60
-
-production:
- airbrake_notify: true
- pid_file: tmp/pids/rapns.pid
-
- push:
- host: gateway.push.apple.com
- port: 2195
- poll: 2
-
- feedback:
- host: feedback.push.apple.com
- port: 2196
- poll: 60
View
22 lib/rapns/daemon.rb
@@ -3,7 +3,6 @@
require 'pathname'
require 'rapns/daemon/interruptible_sleep'
-require 'rapns/daemon/configuration'
require 'rapns/daemon/delivery_error'
require 'rapns/daemon/disconnection_error'
require 'rapns/daemon/connection'
@@ -21,16 +20,15 @@ module Daemon
extend DatabaseReconnectable
class << self
- attr_accessor :logger, :configuration
+ attr_accessor :logger, :config
end
- def self.start(environment, foreground)
+ def self.start(environment, config)
+ self.config = config
+ self.logger = Logger.new(:foreground => config.foreground, :airbrake_notify => config.airbrake_notify)
setup_signal_hooks
- self.configuration = Configuration.load(environment, File.join(Rails.root, 'config', 'rapns', 'rapns.yml'))
- self.logger = Logger.new(:foreground => foreground, :airbrake_notify => configuration.airbrake_notify)
-
- unless foreground
+ unless config.foreground
daemonize
reconnect_database
end
@@ -38,7 +36,7 @@ def self.start(environment, foreground)
write_pid_file
ensure_upgraded
AppRunner.sync
- Feeder.start(configuration.push.poll)
+ Feeder.start(config.push_poll)
end
protected
@@ -106,17 +104,17 @@ def self.daemonize
end
def self.write_pid_file
- if !configuration.pid_file.blank?
+ if !config.pid_file.blank?
begin
- File.open(configuration.pid_file, 'w') { |f| f.puts Process.pid }
+ File.open(config.pid_file, 'w') { |f| f.puts Process.pid }
rescue SystemCallError => e
- logger.error("Failed to write PID to '#{configuration.pid_file}': #{e.inspect}")
+ logger.error("Failed to write PID to '#{config.pid_file}': #{e.inspect}")
end
end
end
def self.delete_pid_file
- pid_file = configuration.pid_file
+ pid_file = config.pid_file
File.delete(pid_file) if !pid_file.blank? && File.exists?(pid_file)
end
end
View
4 lib/rapns/daemon/app_runner.rb
@@ -42,8 +42,8 @@ def self.sync
next unless environment
push_host, push_port = HOSTS[environment][:push]
feedback_host, feedback_port = HOSTS[environment][:feedback]
- feedback = Rapns::Daemon.configuration.feedback
- runner = AppRunner.new(app, push_host, push_port, feedback_host, feedback_port, feedback.poll)
+ feedback_poll = Rapns::Daemon.config.feedback_poll
+ runner = AppRunner.new(app, push_host, push_port, feedback_host, feedback_port, feedback_poll)
runner.start
@all[app.key] = runner
end
View
90 lib/rapns/daemon/configuration.rb
@@ -1,90 +0,0 @@
-require 'yaml'
-
-module Rapns
- class ConfigurationError < StandardError; end
-
- module Daemon
- class Configuration
- attr_accessor :push, :feedback
- attr_accessor :airbrake_notify, :pid_file, :check_for_errors, :feeder_batch_size
-
- def self.load(environment, config_path)
- configuration = new(environment, config_path)
- configuration.load
- configuration
- end
-
- def initialize(environment, config_path)
- @environment = environment
- @config_path = config_path
-
- self.push = Struct.new(:poll).new
- self.feedback = Struct.new(:poll).new
- end
-
- def load
- config = read_config
- ensure_environment_configured(config)
- config = config[@environment]
-
- load_push(config)
- load_feedback(config)
- load_defaults(config)
- end
-
- def load_push(config)
- set_variable(push, :push, :poll, config, :optional => true, :default => 2)
- end
-
- def load_feedback(config)
- set_variable(feedback, :feedback, :poll, config, :optional => true, :default => 60)
- end
-
- def load_defaults(config)
- set_variable(self, nil, :airbrake_notify, config, :optional => true, :default => true)
- set_variable(self, nil, :pid_file, config, :optional => true, :default => nil, :path => Rails.root)
- set_variable(self, nil, :check_for_errors, config, :optional => true, :default => true)
- set_variable(self, nil, :feeder_batch_size, config, :optional => true, :default => 5000)
- end
-
- protected
-
- def read_config
- ensure_config_exists
- File.open(@config_path) { |fd| YAML.load(fd) }
- end
-
- def set_variable(base, base_key, key, config, options = {})
- if base_key
- value = config.key?(base_key.to_s) ? config[base_key.to_s][key.to_s] : nil
- else
- value = config[key.to_s]
- end
-
- if value.to_s.strip == ""
- if options[:optional]
- base.send("#{key}=", options[:default])
- else
- key_path = base_key ? "#{base_key}.#{key}" : key
- raise Rapns::ConfigurationError, "'#{key_path}' not defined for environment '#{@environment}' in #{@config_path}. You may need to run 'rails g rapns' after updating."
- end
- else
- value = File.join(options[:path], value) if options[:path] && !Pathname.new(value).absolute?
- base.send("#{key}=", value)
- end
- end
-
- def ensure_config_exists
- if !File.exists?(@config_path)
- raise Rapns::ConfigurationError, "#{@config_path} does not exist. Have you run 'rails g rapns'?"
- end
- end
-
- def ensure_environment_configured(config)
- if !config.key?(@environment)
- raise Rapns::ConfigurationError, "Configuration for environment '#{@environment}' not defined in #{@config_path}"
- end
- end
- end
- end
-end
View
2  lib/rapns/daemon/delivery_handler.rb
@@ -46,7 +46,7 @@ def stop
def deliver(notification)
begin
@connection.write(notification.to_binary)
- check_for_error if Rapns::Daemon.configuration.check_for_errors
+ check_for_error if Rapns::Daemon.config.check_for_errors
with_database_reconnect_and_retry do
notification.delivered = true
View
2  lib/rapns/daemon/feeder.rb
@@ -27,7 +27,7 @@ def self.enqueue_notifications
begin
with_database_reconnect_and_retry do
ready_apps = Rapns::Daemon::AppRunner.ready
- batch_size = Rapns::Daemon.configuration.feeder_batch_size
+ batch_size = Rapns::Daemon.config.batch_size
Rapns::Notification.ready_for_delivery.find_each(:batch_size => batch_size) do |notification|
Rapns::Daemon::AppRunner.deliver(notification) if ready_apps.include?(notification.app)
end
View
9 spec/rapns/daemon/app_runner_spec.rb
@@ -145,11 +145,10 @@
let(:runner) { stub(:sync => nil, :stop => nil) }
let(:new_runner) { stub }
let(:logger) { stub(:error => nil) }
- let(:feedback_config) { stub(:poll => 60) }
- let(:configuration) { stub(:feedback => feedback_config) }
+ let(:config) { stub(:feedback_poll => 60) }
before do
- Rapns::Daemon.stub(:configuration => configuration, :logger => logger)
+ Rapns::Daemon.stub(:config => config, :logger => logger)
Rapns::Daemon::AppRunner.all['app'] = runner
Rapns::App.stub(:all => [app])
end
@@ -171,7 +170,7 @@
Rapns::App.stub(:all => [new_app])
new_runner = stub
Rapns::Daemon::AppRunner.should_receive(:new).with(new_app, 'gateway.push.apple.com', 2195,
- 'feedback.push.apple.com', 2196, feedback_config.poll).and_return(new_runner)
+ 'feedback.push.apple.com', 2196, config.feedback_poll).and_return(new_runner)
new_runner.should_receive(:start)
Rapns::Daemon::AppRunner.sync
end
@@ -181,7 +180,7 @@
Rapns::App.stub(:all => [new_app])
new_runner = stub
Rapns::Daemon::AppRunner.should_receive(:new).with(new_app, 'gateway.sandbox.push.apple.com', 2195,
- 'feedback.sandbox.push.apple.com', 2196, feedback_config.poll).and_return(new_runner)
+ 'feedback.sandbox.push.apple.com', 2196, config.feedback_poll).and_return(new_runner)
new_runner.should_receive(:start)
Rapns::Daemon::AppRunner.sync
end
View
117 spec/rapns/daemon/configuration_spec.rb
@@ -1,117 +0,0 @@
-require "spec_helper"
-
-describe Rapns::Daemon::Configuration do
- module Rails
- end
-
- let(:config) do
- {
- "airbrake_notify" => false,
- "pid_file" => "rapns.pid",
- "push" => {
- "poll" => 4
- },
- "feedback" => {
- "poll" => 30
- }
- }
- end
-
- let(:configuration) { Rapns::Daemon::Configuration.load("production", "/some/config.yml") }
-
- before do
- File.stub(:exists? => true)
- File.stub(:open => {"production" => config})
- Rails.stub(:root).and_return("/rails_root")
- end
-
- it 'opens the config from the given path' do
- YAML.stub(:load => {"production" => config})
- fd = stub(:read => nil)
- File.should_receive(:open).with("/tmp/rapns-non-existant-file").and_yield(fd)
- config = Rapns::Daemon::Configuration.new("production", "/tmp/rapns-non-existant-file")
- config.stub(:ensure_config_exists)
- config.load
- end
-
- it 'reads the config as YAML' do
- YAML.should_receive(:load).and_return({"production" => config})
- fd = stub(:read => nil)
- File.stub(:open).and_yield(fd)
- config = Rapns::Daemon::Configuration.new("production", "/tmp/rapns-non-existant-file")
- config.stub(:ensure_config_exists)
- config.load
- end
-
- it "raises an error if the configuration file does not exist" do
- File.stub(:exists? => false)
- expect { Rapns::Daemon::Configuration.new("production", "/tmp/rapns-non-existant-file").load }.to raise_error(Rapns::ConfigurationError, "/tmp/rapns-non-existant-file does not exist. Have you run 'rails g rapns'?")
- end
-
- it "raises an error if the environment is not configured" do
- configuration = Rapns::Daemon::Configuration.new("development", "/some/config.yml")
- configuration.stub(:read_config).and_return({"production" => {}})
- expect { configuration.load }.to raise_error(Rapns::ConfigurationError, "Configuration for environment 'development' not defined in /some/config.yml")
- end
-
- it "sets the airbrake notify flag" do
- configuration.airbrake_notify.should == false
- end
-
- it "defaults the airbrake notify flag to true if not set" do
- config.delete('airbrake_notify')
- configuration.airbrake_notify.should == true
- end
-
- it "sets the push poll frequency" do
- configuration.push.poll.should == 4
- end
-
- it "sets the feedback poll frequency" do
- configuration.feedback.poll.should == 30
- end
-
- it "defaults the push poll frequency to 2 if not set" do
- config["push"]["poll"] = nil
- configuration.push.poll.should == 2
- end
-
- it "defaults the feedback poll frequency to 60 if not set" do
- config["feedback"]["poll"] = nil
- configuration.feedback.poll.should == 60
- end
-
- it "sets the PID file path" do
- configuration.pid_file.should == "/rails_root/rapns.pid"
- end
-
- it "keeps the absolute path of the PID file if it has one" do
- config["pid_file"] = "/some/absolue/path/rapns.pid"
- configuration.pid_file.should == "/some/absolue/path/rapns.pid"
- end
-
- it "returns nil if no PID file was set" do
- config["pid_file"] = ""
- configuration.pid_file.should be_nil
- end
-
- it 'sets check_for_errors' do
- config['check_for_errors'] = false
- configuration.check_for_errors.should be_false
- end
-
- it 'sets check_for_errors to true by default' do
- config.delete('check_for_errors')
- configuration.check_for_errors.should be_true
- end
-
- it 'sets feeder_batch_size' do
- config['feeder_batch_size'] = 1000
- configuration.feeder_batch_size.should == 1000
- end
-
- it 'sets feeder_batch_size to 5000 by default' do
- config.delete('feeder_batch_size')
- configuration.feeder_batch_size.should == 5000
- end
-end
View
6 spec/rapns/daemon/delivery_handler_spec.rb
@@ -11,12 +11,12 @@
let(:connection) { stub(:select => false, :write => nil, :reconnect => nil, :close => nil, :connect => nil) }
let(:logger) { stub(:error => nil, :info => nil) }
let(:notification) { stub.as_null_object }
- let(:configuration) { stub(:check_for_errors => true) }
+ let(:config) { stub(:check_for_errors => true) }
let(:delivery_queues) { [] }
before do
Rapns::Daemon::Connection.stub(:new => connection)
- Rapns::Daemon.stub(:delivery_queues => delivery_queues, :logger => logger, :configuration => configuration)
+ Rapns::Daemon.stub(:delivery_queues => delivery_queues, :logger => logger, :config => config)
queue.push(notification)
end
@@ -86,7 +86,7 @@
end
it 'does not check for errors if check_for_errors config option is false' do
- configuration.stub(:check_for_errors => false)
+ config.stub(:check_for_errors => false)
delivery_handler.should_not_receive(:check_for_error)
delivery_handler.send(:handle_next_notification)
end
View
4 spec/rapns/daemon/feeder_spec.rb
@@ -2,14 +2,14 @@
describe Rapns::Daemon::Feeder do
let(:poll) { 2 }
- let(:configuration) { stub(:feeder_batch_size => 5000) }
+ let(:config) { stub(:batch_size => 5000) }
let(:notification) { Rapns::Notification.create!(:device_token => "a" * 64, :app => 'my_app') }
let(:logger) { stub }
before do
Rapns::Daemon::Feeder.stub(:sleep)
Rapns::Daemon::Feeder.stub(:interruptible_sleep)
- Rapns::Daemon.stub(:logger => logger, :configuration => configuration)
+ Rapns::Daemon.stub(:logger => logger, :config => config)
Rapns::Daemon::Feeder.instance_variable_set("@stop", false)
Rapns::Daemon::AppRunner.stub(:ready => ['my_app'])
Rapns::Daemon::AppRunner.stub(:ready => ['my_app'])
View
4 spec/rapns/daemon/logger_spec.rb
@@ -22,14 +22,14 @@ def self.notify(e)
describe Rapns::Daemon::Logger do
let(:log) { stub(:sync= => true) }
+ let(:config) { stub(:airbrake_notify => true) }
before do
Rails.stub(:root).and_return("/rails_root")
@buffered_logger = mock("BufferedLogger", :info => nil, :error => nil, :level => 0, :auto_flushing => 1, :auto_flushing= => nil)
Rails.logger = @buffered_logger
ActiveSupport::BufferedLogger.stub(:new).and_return(@buffered_logger)
- configuration = mock("Configuration", :airbrake_notify? => true)
- Rapns::Daemon.stub(:configuration).and_return(configuration)
+ Rapns::Daemon.stub(:config => config)
File.stub(:open => log)
end
View
45 spec/rapns/daemon_spec.rb
@@ -5,14 +5,10 @@ module Rails; end
let(:certificate) { stub }
let(:password) { stub }
- let(:feedback_config) { stub(:poll => 60) }
- let(:push_config) { stub(:poll => 2) }
- let(:configuration) { stub(:pid_file => nil, :push => push_config, :airbrake_notify => false,
- :feedback => feedback_config) }
+ let(:config) { stub(:pid_file => nil, :push_poll => 2, :airbrake_notify => false, :foreground => true) }
let(:logger) { stub(:info => nil, :error => nil) }
before do
- Rapns::Daemon::Configuration.stub(:load).and_return(configuration)
Rapns::Daemon::Feeder.stub(:start)
Rapns::Daemon::Logger.stub(:new).and_return(logger)
Rapns::Daemon::AppRunner.stub(:sync => nil, :stop => nil)
@@ -21,75 +17,72 @@ module Rails; end
Rails.stub(:root).and_return("/rails_root")
end
- it "loads the configuration" do
- Rapns::Daemon::Configuration.should_receive(:load).with("development", "/rails_root/config/rapns/rapns.yml")
- Rapns::Daemon.start("development", {})
- end
-
it "forks into a daemon if the foreground option is false" do
+ config.stub(:foreground => false)
ActiveRecord::Base.stub(:establish_connection)
Rapns::Daemon.should_receive(:daemonize)
- Rapns::Daemon.start("development", false)
+ Rapns::Daemon.start("development", config)
end
it "does not fork into a daemon if the foreground option is true" do
+ config.stub(:foreground => true)
Rapns::Daemon.should_not_receive(:daemonize)
- Rapns::Daemon.start("development", true)
+ Rapns::Daemon.start("development", config)
end
it "writes the process ID to the PID file" do
Rapns::Daemon.should_receive(:write_pid_file)
- Rapns::Daemon.start("development", {})
+ Rapns::Daemon.start("development", config)
end
it "logs an error if the PID file could not be written" do
- configuration.stub(:pid_file => '/rails_root/rapns.pid')
+ config.stub(:pid_file => '/rails_root/rapns.pid')
File.stub(:open).and_raise(Errno::ENOENT)
logger.should_receive(:error).with("Failed to write PID to '/rails_root/rapns.pid': #<Errno::ENOENT: No such file or directory>")
- Rapns::Daemon.start("development", {})
+ Rapns::Daemon.start("development", config)
end
it "starts the feeder" do
Rapns::Daemon::Feeder.should_receive(:start).with(2)
- Rapns::Daemon.start("development", true)
+ Rapns::Daemon.start("development", config)
end
it "syncs apps" do
Rapns::Daemon::AppRunner.should_receive(:sync)
- Rapns::Daemon.start("development", true)
+ Rapns::Daemon.start("development", config)
end
it "sets up the logger" do
- configuration.stub(:airbrake_notify => true)
+ config.stub(:airbrake_notify => true)
Rapns::Daemon::Logger.should_receive(:new).with(:foreground => true, :airbrake_notify => true)
- Rapns::Daemon.start("development", true)
+ Rapns::Daemon.start("development", config)
end
it "makes the logger accessible" do
- Rapns::Daemon.start("development", true)
+ Rapns::Daemon.start("development", config)
Rapns::Daemon.logger.should == logger
end
- it 'prints a warning exists if there are no apps' do
+ it 'prints a warning if there are no apps' do
Rapns::App.stub(:count => 0)
Rapns::Daemon.should_receive(:puts).any_number_of_times
Rapns::Daemon.should_receive(:exit).with(1)
- Rapns::Daemon.start("development", true)
+ Rapns::Daemon.start("development", config)
end
it 'prints a warning exists if rapns has not been upgraded' do
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
Rapns::Daemon.should_receive(:puts).any_number_of_times
Rapns::Daemon.should_receive(:exit).with(1)
- Rapns::Daemon.start("development", true)
+ Rapns::Daemon.start("development", config)
end
end
describe Rapns::Daemon, "when being shutdown" do
- let(:configuration) { stub(:pid_file => '/rails_root/rapns.pid') }
+ let(:config) { stub(:pid_file => '/rails_root/rapns.pid') }
before do
- Rapns::Daemon.stub(:configuration => configuration, :puts => nil)
+ Rapns::Daemon.stub(:config => config, :puts => nil)
Rapns::Daemon::Feeder.stub(:stop)
Rapns::Daemon::AppRunner.stub(:stop)
end
@@ -117,7 +110,7 @@ module Rails; end
end
it "does not attempt to remove the PID file if one was not written" do
- configuration.stub(:pid_file).and_return(nil)
+ config.stub(:pid_file).and_return(nil)
File.should_not_receive(:delete)
Rapns::Daemon.send(:shutdown)
end
Please sign in to comment.
Something went wrong with that request. Please try again.